Use unique_ptr instead of delete in a few places
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 12 Oct 2013 14:15:33 +0000 (14:15 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 12 Oct 2013 14:15:33 +0000 (14:15 +0000)
commitd6406ee06385f2d43a3a065945a346ae5845bf51
tree739f8e72014fca025dd27fd7ba30b929a36a60a2
parentc91649cc0038827b8d0c146d9af8d58a1367d4bf
Use unique_ptr instead of delete in a few places
https://bugs.webkit.org/show_bug.cgi?id=122639

Reviewed by Anders Carlsson.

Source/WebCore:

* Modules/webdatabase/DatabaseBackendBase.cpp:
(WebCore::guidToDatabaseMap): Use NeverDestroyed instead of DEFINE_STATIC_LOCAL.
(WebCore::guidForOriginAndName): Ditto.
(WebCore::DatabaseBackendBase::DatabaseBackendBase): Removed unneeded initialization
of m_guid, which is set in the body of the constructor explicitly anyway. Use emptyString.
Use unique_ptr for the values in the map. Use the add idiom instead of the get/set idiom.
(WebCore::DatabaseBackendBase::closeDatabase): Use the find/remove idiom instead of the
get/remove idiom.
(WebCore::DatabaseBackendBase::performOpenAndVerify): Use auto here to avoid having to
use the map type by name.

* loader/cache/CachedFont.cpp:
(WebCore::CachedFont::CachedFont): Don't initialize m_fontData to 0; unique_ptr will do that.
(WebCore::CachedFont::~CachedFont): Don't delete m_fontData. unique_ptr will do that.
(WebCore::CachedFont::ensureCustomFontData): Add a get.
(WebCore::CachedFont::allClientsRemoved): Don't delete m_fontData. Use nullptr instead of 0.
* loader/cache/CachedFont.h: Changed m_fontData to a unique_ptr.

* platform/graphics/BitmapImage.cpp:
(WebCore::BitmapImage::BitmapImage): Don't initialize m_frameTimer to 0; unique_ptr will do that.
(WebCore::BitmapImage::startAnimation): Use make_unique to create the timer.
(WebCore::BitmapImage::stopAnimation): Don't delete m_frameTimer. Use nullptr instead of 0.
* platform/graphics/BitmapImage.h: Changed m_FrameTimer to a unique_ptr.
* platform/graphics/cg/BitmapImageCG.cpp:
(WebCore::BitmapImage::BitmapImage): Don't initialize m_frameTimer to 0; unique_ptr will do that.

* platform/graphics/mac/FontCustomPlatformData.cpp:
(WebCore::FontCustomPlatformData::~FontCustomPlatformData): Don't call CGFontRelease on m_cgFont.
(WebCore::FontCustomPlatformData::fontPlatformData): Use get on m_cgFont.
(WebCore::createFontCustomPlatformData): Use nullptr instead of 0, and make_unique instead of new.
* platform/graphics/mac/FontCustomPlatformData.h: Chnaged m_cgFont to be a RetainPtr, and the
return value from createFontCustomPlatformData to be a unique_ptr.

* platform/graphics/blackberry/FontCustomPlatformData.h:
* platform/graphics/blackberry/FontCustomPlatformDataBlackBerry.cpp:
(WebCore::createFontCustomPlatformData):
* platform/graphics/cairo/BitmapImageCairo.cpp:
(WebCore::BitmapImage::BitmapImage):
* platform/graphics/cairo/FontCustomPlatformData.h:
* platform/graphics/cg/BitmapImageCG.cpp:
(WebCore::BitmapImage::BitmapImage):
* platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp:
(WebCore::createFontCustomPlatformData):
* platform/graphics/win/FontCustomPlatformData.cpp:
(WebCore::createFontCustomPlatformData):
* platform/graphics/win/FontCustomPlatformData.h:
* platform/graphics/win/FontCustomPlatformDataCairo.cpp:
(WebCore::createFontCustomPlatformData):
* platform/graphics/wince/FontCustomPlatformData.cpp:
(WebCore::createFontCustomPlatformData):
* platform/graphics/wince/FontCustomPlatformData.h:
Same thing on all the other platforms.

* platform/network/NetworkStorageSession.h: Changed return value of createPrivateBrowsingSession
to a unique_ptr, and made constructors public.

* platform/network/cf/NetworkStorageSessionCFNet.cpp:
(WebCore::NetworkStorageSession::createPrivateBrowsingSession): Use make_unique.

* platform/network/soup/NetworkStorageSessionSoup.cpp:
(WebCore::defaultSession):
(WebCore::NetworkStorageSession::defaultStorageSession):
(WebCore::NetworkStorageSession::createPrivateBrowsingSession):
(WebCore::NetworkStorageSession::switchToNewTestingSession):
Same thing on all the other platforms.

Source/WebKit/mac:

* History/WebHistory.mm:
(-[WebHistoryPrivate init]): Use make_unique.
(-[WebHistoryPrivate dealloc]): Don't delete.
(-[WebHistoryPrivate finalize]): Don't delete.
(-[WebHistoryPrivate data]): Use get.

* WebCoreSupport/WebFrameNetworkingContext.mm:
(privateSession): Use NeverDestroyed here instead of a raw pointer.
(WebFrameNetworkingContext::ensurePrivateBrowsingSession): Use the
new function instead of direct global variable access.
(WebFrameNetworkingContext::destroyPrivateBrowsingSession): Ditto.
(WebFrameNetworkingContext::storageSession): Ditto.

* WebView/WebFrame.mm:
(-[WebFramePrivate dealloc]): Don't delete.
(-[WebFramePrivate finalize]): Don't delete.
(-[WebFrame _attachScriptDebugger]): Use make_unique.
(-[WebFrame _detachScriptDebugger]): Don't delete.
* WebView/WebFrameInternal.h: Use unique_ptr.

Source/WebKit/win:

* WebCoreSupport/WebFrameNetworkingContext.cpp:
(privateSession):
(identifierBase):
(WebFrameNetworkingContext::setCookieAcceptPolicyForAllContexts):
(WebFrameNetworkingContext::setPrivateBrowsingStorageSessionIdentifierBase):
(WebFrameNetworkingContext::ensurePrivateBrowsingSession):
(WebFrameNetworkingContext::destroyPrivateBrowsingSession):
(WebFrameNetworkingContext::storageSession):

Source/WebKit2:

* NetworkProcess/mac/RemoteNetworkingContext.mm:
(WebKit::privateBrowsingStorageSession): Use NeverDestroyed and unique_ptr.
(WebKit::RemoteNetworkingContext::ensurePrivateBrowsingSession): Use std::move.

* Shared/Downloads/DownloadManager.cpp:
(WebKit::DownloadManager::startDownload): Use std::move. Also add instead of set.
(WebKit::DownloadManager::convertHandleToDownload): Ditto.
(WebKit::DownloadManager::downloadFinished): Don't delete.

* Shared/Downloads/DownloadManager.h: Changed m_downloads to hold unique_ptr instead
of raw pointers.

* Shared/SandboxExtension.h: Use std::unique_ptr for m_data.

* Shared/mac/SandboxExtensionMac.mm:
(WebKit::SandboxExtension::HandleArray::HandleArray): Don't initialize m_data to 0.
(WebKit::SandboxExtension::HandleArray::~HandleArray): Don't delete m_data.
(WebKit::SandboxExtension::HandleArray::allocate): Use make_unique to allocate m_data.

* WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm:
(WebKit::privateSession): Use NeverDestroyed and unique_ptr.
(WebKit::identifierBase): Use NeverDestroyed.
(WebKit::WebFrameNetworkingContext::setPrivateBrowsingStorageSessionIdentifierBase):
Updated to use the above.
(WebKit::WebFrameNetworkingContext::ensurePrivateBrowsingSession): Ditto.
(WebKit::WebFrameNetworkingContext::destroyPrivateBrowsingSession): Ditto.
(WebKit::WebFrameNetworkingContext::setCookieAcceptPolicyForAllContexts): Ditto.
(WebKit::WebFrameNetworkingContext::storageSession): Ditto.

* WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.cpp:
(WebKit::privateSession):
(WebKit::WebFrameNetworkingContext::ensurePrivateBrowsingSession):
(WebKit::WebFrameNetworkingContext::destroyPrivateBrowsingSession):
(WebKit::WebFrameNetworkingContext::storageSession):
(WebKit::WebFrameNetworkingContext::webFrameLoaderClient):
More of the same.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@157337 268f45cc-cd09-0410-ab3c-d52691b4dbfc
37 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/webdatabase/DatabaseBackendBase.cpp
Source/WebCore/loader/cache/CachedFont.cpp
Source/WebCore/loader/cache/CachedFont.h
Source/WebCore/platform/graphics/BitmapImage.cpp
Source/WebCore/platform/graphics/BitmapImage.h
Source/WebCore/platform/graphics/blackberry/FontCustomPlatformData.h
Source/WebCore/platform/graphics/blackberry/FontCustomPlatformDataBlackBerry.cpp
Source/WebCore/platform/graphics/cairo/BitmapImageCairo.cpp
Source/WebCore/platform/graphics/cairo/FontCustomPlatformData.h
Source/WebCore/platform/graphics/cg/BitmapImageCG.cpp
Source/WebCore/platform/graphics/freetype/FontCustomPlatformDataFreeType.cpp
Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp
Source/WebCore/platform/graphics/mac/FontCustomPlatformData.h
Source/WebCore/platform/graphics/win/FontCustomPlatformData.cpp
Source/WebCore/platform/graphics/win/FontCustomPlatformData.h
Source/WebCore/platform/graphics/win/FontCustomPlatformDataCairo.cpp
Source/WebCore/platform/graphics/wince/FontCustomPlatformData.cpp
Source/WebCore/platform/graphics/wince/FontCustomPlatformData.h
Source/WebCore/platform/network/NetworkStorageSession.h
Source/WebCore/platform/network/cf/NetworkStorageSessionCFNet.cpp
Source/WebCore/platform/network/soup/NetworkStorageSessionSoup.cpp
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/History/WebHistory.mm
Source/WebKit/mac/WebCoreSupport/WebFrameNetworkingContext.mm
Source/WebKit/mac/WebView/WebFrame.mm
Source/WebKit/mac/WebView/WebFrameInternal.h
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebCoreSupport/WebFrameNetworkingContext.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/mac/RemoteNetworkingContext.mm
Source/WebKit2/Shared/Downloads/DownloadManager.cpp
Source/WebKit2/Shared/Downloads/DownloadManager.h
Source/WebKit2/Shared/SandboxExtension.h
Source/WebKit2/Shared/mac/SandboxExtensionMac.mm
Source/WebKit2/WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm
Source/WebKit2/WebProcess/WebCoreSupport/soup/WebFrameNetworkingContext.cpp