Added a makeRef<T> helper
authorggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Jul 2016 21:51:07 +0000 (21:51 +0000)
committerggaren@apple.com <ggaren@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Jul 2016 21:51:07 +0000 (21:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=159835

Reviewed by Andreas Kling.

Anders told me to!

Source/JavaScriptCore:

* inspector/InjectedScriptHost.cpp:
(Inspector::InjectedScriptHost::wrapper):

Source/WebCore:

* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::putOrAddOnServer):
* Modules/indexeddb/shared/InProcessIDBServer.cpp:
(WebCore::InProcessIDBServer::deleteDatabase):
(WebCore::InProcessIDBServer::didDeleteDatabase):
(WebCore::InProcessIDBServer::openDatabase):
(WebCore::InProcessIDBServer::didOpenDatabase):
(WebCore::InProcessIDBServer::didAbortTransaction):
(WebCore::InProcessIDBServer::didCommitTransaction):
(WebCore::InProcessIDBServer::didCreateObjectStore):
(WebCore::InProcessIDBServer::didDeleteObjectStore):
(WebCore::InProcessIDBServer::didClearObjectStore):
(WebCore::InProcessIDBServer::didCreateIndex):
(WebCore::InProcessIDBServer::didDeleteIndex):
(WebCore::InProcessIDBServer::didPutOrAdd):
(WebCore::InProcessIDBServer::didGetRecord):
(WebCore::InProcessIDBServer::didGetCount):
(WebCore::InProcessIDBServer::didDeleteRecord):
(WebCore::InProcessIDBServer::didOpenCursor):
(WebCore::InProcessIDBServer::didIterateCursor):
(WebCore::InProcessIDBServer::abortTransaction):
(WebCore::InProcessIDBServer::commitTransaction):
(WebCore::InProcessIDBServer::didFinishHandlingVersionChangeTransaction):
(WebCore::InProcessIDBServer::createObjectStore):
(WebCore::InProcessIDBServer::deleteObjectStore):
(WebCore::InProcessIDBServer::clearObjectStore):
(WebCore::InProcessIDBServer::createIndex):
(WebCore::InProcessIDBServer::deleteIndex):
(WebCore::InProcessIDBServer::putOrAdd):
(WebCore::InProcessIDBServer::getRecord):
(WebCore::InProcessIDBServer::getCount):
(WebCore::InProcessIDBServer::deleteRecord):
(WebCore::InProcessIDBServer::openCursor):
(WebCore::InProcessIDBServer::iterateCursor):
(WebCore::InProcessIDBServer::establishTransaction):
(WebCore::InProcessIDBServer::fireVersionChangeEvent):
(WebCore::InProcessIDBServer::didStartTransaction):
(WebCore::InProcessIDBServer::didCloseFromServer):
(WebCore::InProcessIDBServer::notifyOpenDBRequestBlocked):
(WebCore::InProcessIDBServer::databaseConnectionClosed):
(WebCore::InProcessIDBServer::abortOpenAndUpgradeNeeded):
(WebCore::InProcessIDBServer::didFireVersionChangeEvent):
(WebCore::InProcessIDBServer::openDBRequestCancelled):
(WebCore::InProcessIDBServer::confirmDidCloseFromServer):
(WebCore::InProcessIDBServer::getAllDatabaseNames):
(WebCore::InProcessIDBServer::didGetAllDatabaseNames):
* Modules/mediastream/MediaDevicesRequest.cpp:
(WebCore::MediaDevicesRequest::didCompleteTrackSourceInfoRequest):
* Modules/mediastream/UserMediaRequest.cpp:
(WebCore::UserMediaRequest::constraintsValidated):
(WebCore::UserMediaRequest::userMediaAccessGranted):
* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::scheduleNodeDeletion):
(WebCore::AudioContext::isPlayingAudioDidChange):
(WebCore::AudioContext::suspend):
(WebCore::AudioContext::resume):
(WebCore::AudioContext::close):
(WebCore::AudioContext::suspendPlayback):
(WebCore::AudioContext::mayResumePlayback):
* Modules/websockets/ThreadableWebSocketChannelClientWrapper.cpp:
(WebCore::ThreadableWebSocketChannelClientWrapper::didConnect):
(WebCore::ThreadableWebSocketChannelClientWrapper::didReceiveMessage):
(WebCore::ThreadableWebSocketChannelClientWrapper::didReceiveBinaryData):
(WebCore::ThreadableWebSocketChannelClientWrapper::didUpdateBufferedAmount):
(WebCore::ThreadableWebSocketChannelClientWrapper::didStartClosingHandshake):
(WebCore::ThreadableWebSocketChannelClientWrapper::didClose):
(WebCore::ThreadableWebSocketChannelClientWrapper::didReceiveMessageError):
(WebCore::ThreadableWebSocketChannelClientWrapper::processPendingTasks):
* Modules/websockets/WebSocket.cpp:
(WebCore::WebSocket::connect):
* bindings/js/JSEventListener.h:
(WebCore::JSEventListener::jsFunction):
* dom/Node.cpp:
(WebCore::Node::setTextContent):
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::layoutSizeChanged):
* inspector/CommandLineAPIHost.cpp:
(WebCore::CommandLineAPIHost::wrapper):
* platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm:
(WebCore::AudioSourceProviderAVFObjC::prepare):
* platform/graphics/avfoundation/cf/WebCoreAVCFResourceLoader.cpp:
(WebCore::WebCoreAVCFResourceLoader::invalidate):
* platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm:
(WebCore::WebCoreAVFResourceLoader::invalidate):
* platform/ios/WebVideoFullscreenControllerAVKit.mm:
(WebVideoFullscreenControllerContext::setExternalPlayback):
* platform/network/BlobResourceHandle.cpp:
(WebCore::BlobResourceHandle::start):
(WebCore::BlobResourceHandle::notifyFinish):
* platform/network/SocketStreamHandleBase.cpp:
(WebCore::SocketStreamHandleBase::disconnect):
* platform/network/curl/CurlDownload.cpp:
(WebCore::CurlDownload::didReceiveHeader):

Source/WebKit2:

* NetworkProcess/NetworkConnectionToWebProcess.cpp:
(WebKit::NetworkConnectionToWebProcess::writeBlobsToTemporaryFiles):
* NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::tryStoreAsCacheEntry):
* Platform/IPC/Connection.cpp:
(IPC::Connection::addWorkQueueMessageReceiver):
(IPC::Connection::removeWorkQueueMessageReceiver):
(IPC::Connection::invalidate):
(IPC::Connection::sendMessage):
(IPC::Connection::processIncomingMessage):
(IPC::Connection::postConnectionDidCloseOnConnectionWorkQueue):
(IPC::Connection::connectionDidClose):
(IPC::Connection::enqueueIncomingMessage):
* Platform/IPC/mac/ConnectionMac.mm:
(IPC::Connection::receiveSourceEventHandler):
* Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
(WebKit::ThreadedCompositor::setNativeSurfaceHandleForCompositing):
(WebKit::ThreadedCompositor::setDeviceScaleFactor):
(WebKit::ThreadedCompositor::didChangeViewportSize):
(WebKit::ThreadedCompositor::didChangeViewportAttribute):
(WebKit::ThreadedCompositor::didChangeContentsSize):
(WebKit::ThreadedCompositor::scrollTo):
(WebKit::ThreadedCompositor::scrollBy):
(WebKit::ThreadedCompositor::didChangeVisibleRect):
* UIProcess/API/APIUserContentExtensionStore.cpp:
(API::UserContentExtensionStore::lookupContentExtension):
(API::UserContentExtensionStore::compileContentExtension):
(API::UserContentExtensionStore::removeContentExtension):
* UIProcess/Launcher/ProcessLauncher.cpp:
(WebKit::ProcessLauncher::ProcessLauncher):
* UIProcess/Storage/LocalStorageDatabaseTracker.cpp:
(WebKit::LocalStorageDatabaseTracker::LocalStorageDatabaseTracker):
* UIProcess/Storage/StorageManager.cpp:
(WebKit::StorageManager::createSessionStorageNamespace):
(WebKit::StorageManager::destroySessionStorageNamespace):
(WebKit::StorageManager::setAllowedSessionStorageNamespaceConnection):
(WebKit::StorageManager::cloneSessionStorageNamespace):
(WebKit::StorageManager::processDidCloseConnection):
(WebKit::StorageManager::getSessionStorageOrigins):
(WebKit::StorageManager::deleteSessionStorageOrigins):
(WebKit::StorageManager::deleteSessionStorageEntriesForOrigins):
(WebKit::StorageManager::getLocalStorageOrigins):
(WebKit::StorageManager::getLocalStorageOriginDetails):
(WebKit::StorageManager::deleteLocalStorageEntriesForOrigin):
(WebKit::StorageManager::deleteLocalStorageOriginsModifiedSince):
(WebKit::StorageManager::deleteLocalStorageEntriesForOrigins):
* UIProcess/WebResourceLoadStatisticsStore.cpp:
(WebKit::WebResourceLoadStatisticsStore::readDataFromDiskIfNeeded):
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::fetchData):
* WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
(WebKit::NetscapePlugin::pluginThreadAsyncCall):
* WebProcess/WebPage/EventDispatcher.cpp:
(WebKit::EventDispatcher::wheelEvent):
(WebKit::EventDispatcher::gestureEvent):
(WebKit::EventDispatcher::touchEvent):
* WebProcess/WebPage/ViewUpdateDispatcher.cpp:
(WebKit::ViewUpdateDispatcher::visibleContentRectUpdate):

Source/WTF:

* wtf/Ref.h:
(WTF::makeRef): Helper function to do type inference for you.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@203303 268f45cc-cd09-0410-ab3c-d52691b4dbfc

38 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/InjectedScriptHost.cpp
Source/WTF/ChangeLog
Source/WTF/wtf/Ref.h
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/IDBTransaction.cpp
Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.cpp
Source/WebCore/Modules/mediastream/MediaDevicesRequest.cpp
Source/WebCore/Modules/mediastream/UserMediaRequest.cpp
Source/WebCore/Modules/webaudio/AudioContext.cpp
Source/WebCore/Modules/websockets/ThreadableWebSocketChannelClientWrapper.cpp
Source/WebCore/Modules/websockets/WebSocket.cpp
Source/WebCore/bindings/js/JSEventListener.h
Source/WebCore/dom/Node.cpp
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/inspector/CommandLineAPIHost.cpp
Source/WebCore/platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm
Source/WebCore/platform/graphics/avfoundation/cf/WebCoreAVCFResourceLoader.cpp
Source/WebCore/platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm
Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm
Source/WebCore/platform/network/BlobResourceHandle.cpp
Source/WebCore/platform/network/SocketStreamHandleBase.cpp
Source/WebCore/platform/network/curl/CurlDownload.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/NetworkConnectionToWebProcess.cpp
Source/WebKit2/NetworkProcess/NetworkResourceLoader.cpp
Source/WebKit2/Platform/IPC/Connection.cpp
Source/WebKit2/Platform/IPC/mac/ConnectionMac.mm
Source/WebKit2/Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp
Source/WebKit2/UIProcess/API/APIUserContentExtensionStore.cpp
Source/WebKit2/UIProcess/Launcher/ProcessLauncher.cpp
Source/WebKit2/UIProcess/Storage/LocalStorageDatabaseTracker.cpp
Source/WebKit2/UIProcess/Storage/StorageManager.cpp
Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.cpp
Source/WebKit2/UIProcess/WebsiteData/WebsiteDataStore.cpp
Source/WebKit2/WebProcess/Plugins/Netscape/NetscapePlugin.cpp
Source/WebKit2/WebProcess/WebPage/EventDispatcher.cpp
Source/WebKit2/WebProcess/WebPage/ViewUpdateDispatcher.cpp

index 1033b19..594b670 100644 (file)
@@ -1,3 +1,15 @@
+2016-07-15  Geoffrey Garen  <ggaren@apple.com>
+
+        Added a makeRef<T> helper
+        https://bugs.webkit.org/show_bug.cgi?id=159835
+
+        Reviewed by Andreas Kling.
+
+        Anders told me to!
+
+        * inspector/InjectedScriptHost.cpp:
+        (Inspector::InjectedScriptHost::wrapper):
+
 2016-07-15  Mark Lam  <mark.lam@apple.com>
 
         FunctionOverride's parseClause() needs to keep the CString instance in scope while its data is being used.
index 657ba19..433174f 100644 (file)
@@ -45,7 +45,7 @@ JSValue InjectedScriptHost::wrapper(ExecState* exec, JSGlobalObject* globalObjec
 
     JSObject* prototype = JSInjectedScriptHost::createPrototype(exec->vm(), globalObject);
     Structure* structure = JSInjectedScriptHost::createStructure(exec->vm(), globalObject, prototype);
-    JSInjectedScriptHost* injectedScriptHost = JSInjectedScriptHost::create(exec->vm(), structure, Ref<InjectedScriptHost>(*this));
+    JSInjectedScriptHost* injectedScriptHost = JSInjectedScriptHost::create(exec->vm(), structure, makeRef(*this));
     m_wrappers.addWrapper(globalObject, injectedScriptHost);
 
     return injectedScriptHost;
index 0cb97b4..d6249e1 100644 (file)
@@ -1,3 +1,15 @@
+2016-07-15  Geoffrey Garen  <ggaren@apple.com>
+
+        Added a makeRef<T> helper
+        https://bugs.webkit.org/show_bug.cgi?id=159835
+
+        Reviewed by Andreas Kling.
+
+        Anders told me to!
+
+        * wtf/Ref.h:
+        (WTF::makeRef): Helper function to do type inference for you.
+
 2016-07-15  Ryan Haddad  <ryanhaddad@apple.com>
 
         Unreviewed, rolling out r203266.
index bd632db..e81b69f 100644 (file)
@@ -217,6 +217,12 @@ inline Ref<T> adoptRef(T& reference)
     return Ref<T>(reference, Ref<T>::Adopt);
 }
 
+template<typename T>
+inline Ref<T> makeRef(T& reference)
+{
+    return Ref<T>(reference);
+}
+
 template<typename ExpectedType, typename ArgType> inline bool is(Ref<ArgType>& source)
 {
     return is<ExpectedType>(source.get());
@@ -231,6 +237,7 @@ template<typename ExpectedType, typename ArgType> inline bool is(const Ref<ArgTy
 
 using WTF::Ref;
 using WTF::adoptRef;
+using WTF::makeRef;
 using WTF::static_reference_cast;
 
 #endif // WTF_Ref_h
index 49060fb..f50bff7 100644 (file)
@@ -1,3 +1,106 @@
+2016-07-15  Geoffrey Garen  <ggaren@apple.com>
+
+        Added a makeRef<T> helper
+        https://bugs.webkit.org/show_bug.cgi?id=159835
+
+        Reviewed by Andreas Kling.
+
+        Anders told me to!
+
+        * Modules/indexeddb/IDBTransaction.cpp:
+        (WebCore::IDBTransaction::putOrAddOnServer):
+        * Modules/indexeddb/shared/InProcessIDBServer.cpp:
+        (WebCore::InProcessIDBServer::deleteDatabase):
+        (WebCore::InProcessIDBServer::didDeleteDatabase):
+        (WebCore::InProcessIDBServer::openDatabase):
+        (WebCore::InProcessIDBServer::didOpenDatabase):
+        (WebCore::InProcessIDBServer::didAbortTransaction):
+        (WebCore::InProcessIDBServer::didCommitTransaction):
+        (WebCore::InProcessIDBServer::didCreateObjectStore):
+        (WebCore::InProcessIDBServer::didDeleteObjectStore):
+        (WebCore::InProcessIDBServer::didClearObjectStore):
+        (WebCore::InProcessIDBServer::didCreateIndex):
+        (WebCore::InProcessIDBServer::didDeleteIndex):
+        (WebCore::InProcessIDBServer::didPutOrAdd):
+        (WebCore::InProcessIDBServer::didGetRecord):
+        (WebCore::InProcessIDBServer::didGetCount):
+        (WebCore::InProcessIDBServer::didDeleteRecord):
+        (WebCore::InProcessIDBServer::didOpenCursor):
+        (WebCore::InProcessIDBServer::didIterateCursor):
+        (WebCore::InProcessIDBServer::abortTransaction):
+        (WebCore::InProcessIDBServer::commitTransaction):
+        (WebCore::InProcessIDBServer::didFinishHandlingVersionChangeTransaction):
+        (WebCore::InProcessIDBServer::createObjectStore):
+        (WebCore::InProcessIDBServer::deleteObjectStore):
+        (WebCore::InProcessIDBServer::clearObjectStore):
+        (WebCore::InProcessIDBServer::createIndex):
+        (WebCore::InProcessIDBServer::deleteIndex):
+        (WebCore::InProcessIDBServer::putOrAdd):
+        (WebCore::InProcessIDBServer::getRecord):
+        (WebCore::InProcessIDBServer::getCount):
+        (WebCore::InProcessIDBServer::deleteRecord):
+        (WebCore::InProcessIDBServer::openCursor):
+        (WebCore::InProcessIDBServer::iterateCursor):
+        (WebCore::InProcessIDBServer::establishTransaction):
+        (WebCore::InProcessIDBServer::fireVersionChangeEvent):
+        (WebCore::InProcessIDBServer::didStartTransaction):
+        (WebCore::InProcessIDBServer::didCloseFromServer):
+        (WebCore::InProcessIDBServer::notifyOpenDBRequestBlocked):
+        (WebCore::InProcessIDBServer::databaseConnectionClosed):
+        (WebCore::InProcessIDBServer::abortOpenAndUpgradeNeeded):
+        (WebCore::InProcessIDBServer::didFireVersionChangeEvent):
+        (WebCore::InProcessIDBServer::openDBRequestCancelled):
+        (WebCore::InProcessIDBServer::confirmDidCloseFromServer):
+        (WebCore::InProcessIDBServer::getAllDatabaseNames):
+        (WebCore::InProcessIDBServer::didGetAllDatabaseNames):
+        * Modules/mediastream/MediaDevicesRequest.cpp:
+        (WebCore::MediaDevicesRequest::didCompleteTrackSourceInfoRequest):
+        * Modules/mediastream/UserMediaRequest.cpp:
+        (WebCore::UserMediaRequest::constraintsValidated):
+        (WebCore::UserMediaRequest::userMediaAccessGranted):
+        * Modules/webaudio/AudioContext.cpp:
+        (WebCore::AudioContext::scheduleNodeDeletion):
+        (WebCore::AudioContext::isPlayingAudioDidChange):
+        (WebCore::AudioContext::suspend):
+        (WebCore::AudioContext::resume):
+        (WebCore::AudioContext::close):
+        (WebCore::AudioContext::suspendPlayback):
+        (WebCore::AudioContext::mayResumePlayback):
+        * Modules/websockets/ThreadableWebSocketChannelClientWrapper.cpp:
+        (WebCore::ThreadableWebSocketChannelClientWrapper::didConnect):
+        (WebCore::ThreadableWebSocketChannelClientWrapper::didReceiveMessage):
+        (WebCore::ThreadableWebSocketChannelClientWrapper::didReceiveBinaryData):
+        (WebCore::ThreadableWebSocketChannelClientWrapper::didUpdateBufferedAmount):
+        (WebCore::ThreadableWebSocketChannelClientWrapper::didStartClosingHandshake):
+        (WebCore::ThreadableWebSocketChannelClientWrapper::didClose):
+        (WebCore::ThreadableWebSocketChannelClientWrapper::didReceiveMessageError):
+        (WebCore::ThreadableWebSocketChannelClientWrapper::processPendingTasks):
+        * Modules/websockets/WebSocket.cpp:
+        (WebCore::WebSocket::connect):
+        * bindings/js/JSEventListener.h:
+        (WebCore::JSEventListener::jsFunction):
+        * dom/Node.cpp:
+        (WebCore::Node::setTextContent):
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::layoutSizeChanged):
+        * inspector/CommandLineAPIHost.cpp:
+        (WebCore::CommandLineAPIHost::wrapper):
+        * platform/graphics/avfoundation/AudioSourceProviderAVFObjC.mm:
+        (WebCore::AudioSourceProviderAVFObjC::prepare):
+        * platform/graphics/avfoundation/cf/WebCoreAVCFResourceLoader.cpp:
+        (WebCore::WebCoreAVCFResourceLoader::invalidate):
+        * platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm:
+        (WebCore::WebCoreAVFResourceLoader::invalidate):
+        * platform/ios/WebVideoFullscreenControllerAVKit.mm:
+        (WebVideoFullscreenControllerContext::setExternalPlayback):
+        * platform/network/BlobResourceHandle.cpp:
+        (WebCore::BlobResourceHandle::start):
+        (WebCore::BlobResourceHandle::notifyFinish):
+        * platform/network/SocketStreamHandleBase.cpp:
+        (WebCore::SocketStreamHandleBase::disconnect):
+        * platform/network/curl/CurlDownload.cpp:
+        (WebCore::CurlDownload::didReceiveHeader):
+
 2016-07-15  Chris Dumez  <cdumez@apple.com>
 
         Use fastGetAttribute() / setAttributeWithoutSynchronization() when possible
index 7376639..e8371d7 100644 (file)
@@ -967,7 +967,7 @@ void IDBTransaction::putOrAddOnServer(IDBClient::TransactionOperation& operation
         return;
     }
 
-    value->writeBlobsToDiskForIndexedDB([protectedThis = Ref<IDBTransaction>(*this), this, protectedOperation = Ref<IDBClient::TransactionOperation>(operation), keyData = IDBKeyData(key.get()).isolatedCopy(), overwriteMode](const IDBValue& idbValue) mutable {
+    value->writeBlobsToDiskForIndexedDB([protectedThis = makeRef(*this), this, protectedOperation = Ref<IDBClient::TransactionOperation>(operation), keyData = IDBKeyData(key.get()).isolatedCopy(), overwriteMode](const IDBValue& idbValue) mutable {
         ASSERT(currentThread() == originThreadID());
         ASSERT(isMainThread());
         if (idbValue.data().data()) {
index 0903733..610c77f 100644 (file)
@@ -91,301 +91,301 @@ IDBServer::IDBConnectionToClient& InProcessIDBServer::connectionToClient() const
 
 void InProcessIDBServer::deleteDatabase(const IDBRequestData& requestData)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), requestData] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), requestData] {
         m_server->deleteDatabase(requestData);
     });
 }
 
 void InProcessIDBServer::didDeleteDatabase(const IDBResultData& resultData)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), resultData] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), resultData] {
         m_connectionToServer->didDeleteDatabase(resultData);
     });
 }
 
 void InProcessIDBServer::openDatabase(const IDBRequestData& requestData)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), requestData] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), requestData] {
         m_server->openDatabase(requestData);
     });
 }
 
 void InProcessIDBServer::didOpenDatabase(const IDBResultData& resultData)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), resultData] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), resultData] {
         m_connectionToServer->didOpenDatabase(resultData);
     });
 }
 
 void InProcessIDBServer::didAbortTransaction(const IDBResourceIdentifier& transactionIdentifier, const IDBError& error)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), transactionIdentifier, error] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), transactionIdentifier, error] {
         m_connectionToServer->didAbortTransaction(transactionIdentifier, error);
     });
 }
 
 void InProcessIDBServer::didCommitTransaction(const IDBResourceIdentifier& transactionIdentifier, const IDBError& error)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), transactionIdentifier, error] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), transactionIdentifier, error] {
         m_connectionToServer->didCommitTransaction(transactionIdentifier, error);
     });
 }
 
 void InProcessIDBServer::didCreateObjectStore(const IDBResultData& resultData)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), resultData] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), resultData] {
         m_connectionToServer->didCreateObjectStore(resultData);
     });
 }
 
 void InProcessIDBServer::didDeleteObjectStore(const IDBResultData& resultData)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), resultData] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), resultData] {
         m_connectionToServer->didDeleteObjectStore(resultData);
     });
 }
 
 void InProcessIDBServer::didClearObjectStore(const IDBResultData& resultData)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), resultData] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), resultData] {
         m_connectionToServer->didClearObjectStore(resultData);
     });
 }
 
 void InProcessIDBServer::didCreateIndex(const IDBResultData& resultData)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), resultData] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), resultData] {
         m_connectionToServer->didCreateIndex(resultData);
     });
 }
 
 void InProcessIDBServer::didDeleteIndex(const IDBResultData& resultData)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), resultData] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), resultData] {
         m_connectionToServer->didDeleteIndex(resultData);
     });
 }
 
 void InProcessIDBServer::didPutOrAdd(const IDBResultData& resultData)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), resultData] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), resultData] {
         m_connectionToServer->didPutOrAdd(resultData);
     });
 }
 
 void InProcessIDBServer::didGetRecord(const IDBResultData& resultData)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), resultData] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), resultData] {
         m_connectionToServer->didGetRecord(resultData);
     });
 }
 
 void InProcessIDBServer::didGetCount(const IDBResultData& resultData)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), resultData] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), resultData] {
         m_connectionToServer->didGetCount(resultData);
     });
 }
 
 void InProcessIDBServer::didDeleteRecord(const IDBResultData& resultData)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), resultData] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), resultData] {
         m_connectionToServer->didDeleteRecord(resultData);
     });
 }
 
 void InProcessIDBServer::didOpenCursor(const IDBResultData& resultData)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), resultData] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), resultData] {
         m_connectionToServer->didOpenCursor(resultData);
     });
 }
 
 void InProcessIDBServer::didIterateCursor(const IDBResultData& resultData)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), resultData] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), resultData] {
         m_connectionToServer->didIterateCursor(resultData);
     });
 }
 
 void InProcessIDBServer::abortTransaction(const IDBResourceIdentifier& resourceIdentifier)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), resourceIdentifier] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), resourceIdentifier] {
         m_server->abortTransaction(resourceIdentifier);
     });
 }
 
 void InProcessIDBServer::commitTransaction(const IDBResourceIdentifier& resourceIdentifier)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), resourceIdentifier] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), resourceIdentifier] {
         m_server->commitTransaction(resourceIdentifier);
     });
 }
 
 void InProcessIDBServer::didFinishHandlingVersionChangeTransaction(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& transactionIdentifier)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), databaseConnectionIdentifier, transactionIdentifier] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), databaseConnectionIdentifier, transactionIdentifier] {
         m_server->didFinishHandlingVersionChangeTransaction(databaseConnectionIdentifier, transactionIdentifier);
     });
 }
 
 void InProcessIDBServer::createObjectStore(const IDBRequestData& resultData, const IDBObjectStoreInfo& info)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), resultData, info] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), resultData, info] {
         m_server->createObjectStore(resultData, info);
     });
 }
 
 void InProcessIDBServer::deleteObjectStore(const IDBRequestData& requestData, const String& objectStoreName)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), requestData, objectStoreName] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), requestData, objectStoreName] {
         m_server->deleteObjectStore(requestData, objectStoreName);
     });
 }
 
 void InProcessIDBServer::clearObjectStore(const IDBRequestData& requestData, uint64_t objectStoreIdentifier)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), requestData, objectStoreIdentifier] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), requestData, objectStoreIdentifier] {
         m_server->clearObjectStore(requestData, objectStoreIdentifier);
     });
 }
 
 void InProcessIDBServer::createIndex(const IDBRequestData& requestData, const IDBIndexInfo& info)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), requestData, info] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), requestData, info] {
         m_server->createIndex(requestData, info);
     });
 }
 
 void InProcessIDBServer::deleteIndex(const IDBRequestData& requestData, uint64_t objectStoreIdentifier, const String& indexName)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), requestData, objectStoreIdentifier, indexName] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), requestData, objectStoreIdentifier, indexName] {
         m_server->deleteIndex(requestData, objectStoreIdentifier, indexName);
     });
 }
 
 void InProcessIDBServer::putOrAdd(const IDBRequestData& requestData, const IDBKeyData& keyData, const IDBValue& value, const IndexedDB::ObjectStoreOverwriteMode overwriteMode)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), requestData, keyData, value, overwriteMode] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), requestData, keyData, value, overwriteMode] {
         m_server->putOrAdd(requestData, keyData, value, overwriteMode);
     });
 }
 
 void InProcessIDBServer::getRecord(const IDBRequestData& requestData, const IDBKeyRangeData& keyRangeData)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), requestData, keyRangeData] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), requestData, keyRangeData] {
         m_server->getRecord(requestData, keyRangeData);
     });
 }
 
 void InProcessIDBServer::getCount(const IDBRequestData& requestData, const IDBKeyRangeData& keyRangeData)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), requestData, keyRangeData] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), requestData, keyRangeData] {
         m_server->getCount(requestData, keyRangeData);
     });
 }
 
 void InProcessIDBServer::deleteRecord(const IDBRequestData& requestData, const IDBKeyRangeData& keyRangeData)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), requestData, keyRangeData] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), requestData, keyRangeData] {
         m_server->deleteRecord(requestData, keyRangeData);
     });
 }
 
 void InProcessIDBServer::openCursor(const IDBRequestData& requestData, const IDBCursorInfo& info)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), requestData, info] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), requestData, info] {
         m_server->openCursor(requestData, info);
     });
 }
 
 void InProcessIDBServer::iterateCursor(const IDBRequestData& requestData, const IDBKeyData& key, unsigned long count)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), requestData, key, count] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), requestData, key, count] {
         m_server->iterateCursor(requestData, key, count);
     });
 }
 
 void InProcessIDBServer::establishTransaction(uint64_t databaseConnectionIdentifier, const IDBTransactionInfo& info)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), databaseConnectionIdentifier, info] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), databaseConnectionIdentifier, info] {
         m_server->establishTransaction(databaseConnectionIdentifier, info);
     });
 }
 
 void InProcessIDBServer::fireVersionChangeEvent(IDBServer::UniqueIDBDatabaseConnection& connection, const IDBResourceIdentifier& requestIdentifier, uint64_t requestedVersion)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), databaseConnectionIdentifier = connection.identifier(), requestIdentifier, requestedVersion] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), databaseConnectionIdentifier = connection.identifier(), requestIdentifier, requestedVersion] {
         m_connectionToServer->fireVersionChangeEvent(databaseConnectionIdentifier, requestIdentifier, requestedVersion);
     });
 }
 
 void InProcessIDBServer::didStartTransaction(const IDBResourceIdentifier& transactionIdentifier, const IDBError& error)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), transactionIdentifier, error] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), transactionIdentifier, error] {
         m_connectionToServer->didStartTransaction(transactionIdentifier, error);
     });
 }
 
 void InProcessIDBServer::didCloseFromServer(IDBServer::UniqueIDBDatabaseConnection& connection, const IDBError& error)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), databaseConnectionIdentifier = connection.identifier(), error] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), databaseConnectionIdentifier = connection.identifier(), error] {
         m_connectionToServer->didCloseFromServer(databaseConnectionIdentifier, error);
     });
 }
 
 void InProcessIDBServer::notifyOpenDBRequestBlocked(const IDBResourceIdentifier& requestIdentifier, uint64_t oldVersion, uint64_t newVersion)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), requestIdentifier, oldVersion, newVersion] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), requestIdentifier, oldVersion, newVersion] {
         m_connectionToServer->notifyOpenDBRequestBlocked(requestIdentifier, oldVersion, newVersion);
     });
 }
 
 void InProcessIDBServer::databaseConnectionClosed(uint64_t databaseConnectionIdentifier)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), databaseConnectionIdentifier] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), databaseConnectionIdentifier] {
         m_server->databaseConnectionClosed(databaseConnectionIdentifier);
     });
 }
 
 void InProcessIDBServer::abortOpenAndUpgradeNeeded(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& transactionIdentifier)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), databaseConnectionIdentifier, transactionIdentifier] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), databaseConnectionIdentifier, transactionIdentifier] {
         m_server->abortOpenAndUpgradeNeeded(databaseConnectionIdentifier, transactionIdentifier);
     });
 }
 
 void InProcessIDBServer::didFireVersionChangeEvent(uint64_t databaseConnectionIdentifier, const IDBResourceIdentifier& requestIdentifier)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), databaseConnectionIdentifier, requestIdentifier] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), databaseConnectionIdentifier, requestIdentifier] {
         m_server->didFireVersionChangeEvent(databaseConnectionIdentifier, requestIdentifier);
     });
 }
 
 void InProcessIDBServer::openDBRequestCancelled(const IDBRequestData& requestData)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), requestData] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), requestData] {
         m_server->openDBRequestCancelled(requestData);
     });
 }
 
 void InProcessIDBServer::confirmDidCloseFromServer(uint64_t databaseConnectionIdentifier)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), databaseConnectionIdentifier] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), databaseConnectionIdentifier] {
         m_server->confirmDidCloseFromServer(databaseConnectionIdentifier);
     });
 }
 
 void InProcessIDBServer::getAllDatabaseNames(const SecurityOriginData& mainFrameOrigin, const SecurityOriginData& openingOrigin, uint64_t callbackID)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), mainFrameOrigin, openingOrigin, callbackID] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), mainFrameOrigin, openingOrigin, callbackID] {
         m_server->getAllDatabaseNames(m_connectionToServer->identifier(), mainFrameOrigin, openingOrigin, callbackID);
     });
 }
 
 void InProcessIDBServer::didGetAllDatabaseNames(uint64_t callbackID, const Vector<String>& databaseNames)
 {
-    RunLoop::current().dispatch([this, protectedThis = Ref<InProcessIDBServer>(*this), callbackID, databaseNames] {
+    RunLoop::current().dispatch([this, protectedThis = makeRef(*this), callbackID, databaseNames] {
         m_connectionToServer->didGetAllDatabaseNames(callbackID, databaseNames);
     });
 }
index 228570b..4646a59 100644 (file)
@@ -160,7 +160,7 @@ void MediaDevicesRequest::didCompleteTrackSourceInfoRequest(const TrackSourceInf
         devices.append(MediaDeviceInfo::create(scriptExecutionContext(), label, id, groupId, deviceType));
     }
 
-    callOnMainThread([protectedThis = Ref<MediaDevicesRequest>(*this), devices = WTFMove(devices)]() mutable {
+    callOnMainThread([protectedThis = makeRef(*this), devices = WTFMove(devices)]() mutable {
         protectedThis->m_promise.resolve(devices);
     });
     m_protector = nullptr;
index b96b7a0..78ba239 100644 (file)
@@ -135,7 +135,7 @@ void UserMediaRequest::constraintsValidated(const Vector<RefPtr<RealtimeMediaSou
     for (auto& videoTrack : videoTracks)
         m_videoDeviceUIDs.append(videoTrack->persistentID());
 
-    callOnMainThread([protectedThis = Ref<UserMediaRequest>(*this)]() mutable {
+    callOnMainThread([protectedThis = makeRef(*this)]() mutable {
         // 2 - The constraints are valid, ask the user for access to media.
         if (UserMediaController* controller = protectedThis->m_controller)
             controller->requestUserMediaAccess(protectedThis.get());
@@ -147,7 +147,7 @@ void UserMediaRequest::userMediaAccessGranted(const String& audioDeviceUID, cons
     m_allowedVideoDeviceUID = videoDeviceUID;
     m_audioDeviceUIDAllowed = audioDeviceUID;
 
-    callOnMainThread([protectedThis = Ref<UserMediaRequest>(*this), audioDeviceUID, videoDeviceUID]() mutable {
+    callOnMainThread([protectedThis = makeRef(*this), audioDeviceUID, videoDeviceUID]() mutable {
         // 3 - the user granted access, ask platform to create the media stream descriptors.
         RealtimeMediaSourceCenter::singleton().createMediaStream(protectedThis.ptr(), audioDeviceUID, videoDeviceUID);
     });
index b759c5f..144709a 100644 (file)
@@ -797,7 +797,7 @@ void AudioContext::scheduleNodeDeletion()
 
         m_isDeletionScheduled = true;
 
-        callOnMainThread([protectedThis = Ref<AudioContext>(*this)]() mutable {
+        callOnMainThread([protectedThis = makeRef(*this)]() mutable {
             protectedThis->deleteMarkedNodes();
         });
     }
@@ -1001,7 +1001,7 @@ void AudioContext::isPlayingAudioDidChange()
 {
     // Make sure to call Document::updateIsPlayingMedia() on the main thread, since
     // we could be on the audio I/O thread here and the call into WebCore could block.
-    callOnMainThread([protectedThis = Ref<AudioContext>(*this)] {
+    callOnMainThread([protectedThis = makeRef(*this)] {
         if (protectedThis->document())
             protectedThis->document()->updateIsPlayingMedia();
     });
@@ -1061,7 +1061,7 @@ void AudioContext::suspend(Promise&& promise)
 
     lazyInitialize();
 
-    m_destinationNode->suspend([this, protectedThis = Ref<AudioContext>(*this)] {
+    m_destinationNode->suspend([this, protectedThis = makeRef(*this)] {
         setState(State::Suspended);
     });
 }
@@ -1090,7 +1090,7 @@ void AudioContext::resume(Promise&& promise)
 
     lazyInitialize();
 
-    m_destinationNode->resume([this, protectedThis = Ref<AudioContext>(*this)] {
+    m_destinationNode->resume([this, protectedThis = makeRef(*this)] {
         setState(State::Running);
     });
 }
@@ -1111,7 +1111,7 @@ void AudioContext::close(Promise&& promise)
 
     lazyInitialize();
 
-    m_destinationNode->close([this, protectedThis = Ref<AudioContext>(*this)] {
+    m_destinationNode->close([this, protectedThis = makeRef(*this)] {
         setState(State::Closed);
         uninitialize();
     });
@@ -1131,7 +1131,7 @@ void AudioContext::suspendPlayback()
 
     lazyInitialize();
 
-    m_destinationNode->suspend([this, protectedThis = Ref<AudioContext>(*this)] {
+    m_destinationNode->suspend([this, protectedThis = makeRef(*this)] {
         bool interrupted = m_mediaSession->state() == PlatformMediaSession::Interrupted;
         setState(interrupted ? State::Interrupted : State::Suspended);
     });
@@ -1152,7 +1152,7 @@ void AudioContext::mayResumePlayback(bool shouldResume)
 
     lazyInitialize();
 
-    m_destinationNode->resume([this, protectedThis = Ref<AudioContext>(*this)] {
+    m_destinationNode->resume([this, protectedThis = makeRef(*this)] {
         setState(State::Running);
     });
 }
index b9a4682..3d10569 100644 (file)
@@ -154,7 +154,7 @@ void ThreadableWebSocketChannelClientWrapper::clearClient()
 
 void ThreadableWebSocketChannelClientWrapper::didConnect()
 {
-    m_pendingTasks.append(std::make_unique<ScriptExecutionContext::Task>([this, protectedThis = Ref<ThreadableWebSocketChannelClientWrapper>(*this)] (ScriptExecutionContext&) {
+    m_pendingTasks.append(std::make_unique<ScriptExecutionContext::Task>([this, protectedThis = makeRef(*this)] (ScriptExecutionContext&) {
         if (m_client)
             m_client->didConnect();
     }));
@@ -165,7 +165,7 @@ void ThreadableWebSocketChannelClientWrapper::didConnect()
 
 void ThreadableWebSocketChannelClientWrapper::didReceiveMessage(const String& message)
 {
-    m_pendingTasks.append(std::make_unique<ScriptExecutionContext::Task>([this, protectedThis = Ref<ThreadableWebSocketChannelClientWrapper>(*this), message = message.isolatedCopy()] (ScriptExecutionContext&) {
+    m_pendingTasks.append(std::make_unique<ScriptExecutionContext::Task>([this, protectedThis = makeRef(*this), message = message.isolatedCopy()] (ScriptExecutionContext&) {
         if (m_client)
             m_client->didReceiveMessage(message);
     }));
@@ -176,7 +176,7 @@ void ThreadableWebSocketChannelClientWrapper::didReceiveMessage(const String& me
 
 void ThreadableWebSocketChannelClientWrapper::didReceiveBinaryData(Vector<uint8_t>&& binaryData)
 {
-    m_pendingTasks.append(std::make_unique<ScriptExecutionContext::Task>([this, protectedThis = Ref<ThreadableWebSocketChannelClientWrapper>(*this), binaryData = WTFMove(binaryData)] (ScriptExecutionContext&) mutable {
+    m_pendingTasks.append(std::make_unique<ScriptExecutionContext::Task>([this, protectedThis = makeRef(*this), binaryData = WTFMove(binaryData)] (ScriptExecutionContext&) mutable {
         if (m_client)
             m_client->didReceiveBinaryData(WTFMove(binaryData));
     }));
@@ -187,7 +187,7 @@ void ThreadableWebSocketChannelClientWrapper::didReceiveBinaryData(Vector<uint8_
 
 void ThreadableWebSocketChannelClientWrapper::didUpdateBufferedAmount(unsigned bufferedAmount)
 {
-    m_pendingTasks.append(std::make_unique<ScriptExecutionContext::Task>([this, protectedThis = Ref<ThreadableWebSocketChannelClientWrapper>(*this), bufferedAmount] (ScriptExecutionContext&) {
+    m_pendingTasks.append(std::make_unique<ScriptExecutionContext::Task>([this, protectedThis = makeRef(*this), bufferedAmount] (ScriptExecutionContext&) {
         if (m_client)
             m_client->didUpdateBufferedAmount(bufferedAmount);
     }));
@@ -198,7 +198,7 @@ void ThreadableWebSocketChannelClientWrapper::didUpdateBufferedAmount(unsigned b
 
 void ThreadableWebSocketChannelClientWrapper::didStartClosingHandshake()
 {
-    m_pendingTasks.append(std::make_unique<ScriptExecutionContext::Task>([this, protectedThis = Ref<ThreadableWebSocketChannelClientWrapper>(*this)] (ScriptExecutionContext&) {
+    m_pendingTasks.append(std::make_unique<ScriptExecutionContext::Task>([this, protectedThis = makeRef(*this)] (ScriptExecutionContext&) {
         if (m_client)
             m_client->didStartClosingHandshake();
     }));
@@ -209,7 +209,7 @@ void ThreadableWebSocketChannelClientWrapper::didStartClosingHandshake()
 
 void ThreadableWebSocketChannelClientWrapper::didClose(unsigned unhandledBufferedAmount, WebSocketChannelClient::ClosingHandshakeCompletionStatus closingHandshakeCompletion, unsigned short code, const String& reason)
 {
-    m_pendingTasks.append(std::make_unique<ScriptExecutionContext::Task>([this, protectedThis = Ref<ThreadableWebSocketChannelClientWrapper>(*this), unhandledBufferedAmount, closingHandshakeCompletion, code, reason = reason.isolatedCopy()] (ScriptExecutionContext&) {
+    m_pendingTasks.append(std::make_unique<ScriptExecutionContext::Task>([this, protectedThis = makeRef(*this), unhandledBufferedAmount, closingHandshakeCompletion, code, reason = reason.isolatedCopy()] (ScriptExecutionContext&) {
             if (m_client)
                 m_client->didClose(unhandledBufferedAmount, closingHandshakeCompletion, code, reason);
         }));
@@ -220,7 +220,7 @@ void ThreadableWebSocketChannelClientWrapper::didClose(unsigned unhandledBuffere
 
 void ThreadableWebSocketChannelClientWrapper::didReceiveMessageError()
 {
-    m_pendingTasks.append(std::make_unique<ScriptExecutionContext::Task>([this, protectedThis = Ref<ThreadableWebSocketChannelClientWrapper>(*this)] (ScriptExecutionContext&) {
+    m_pendingTasks.append(std::make_unique<ScriptExecutionContext::Task>([this, protectedThis = makeRef(*this)] (ScriptExecutionContext&) {
         if (m_client)
             m_client->didReceiveMessageError();
     }));
@@ -247,7 +247,7 @@ void ThreadableWebSocketChannelClientWrapper::processPendingTasks()
     if (!m_syncMethodDone) {
         // When a synchronous operation is in progress (i.e. the execution stack contains
         // WorkerThreadableWebSocketChannel::waitForMethodCompletion()), we cannot invoke callbacks in this run loop.
-        m_context.postTask([this, protectedThis = Ref<ThreadableWebSocketChannelClientWrapper>(*this)] (ScriptExecutionContext& context) {
+        m_context.postTask([this, protectedThis = makeRef(*this)] (ScriptExecutionContext& context) {
             ASSERT_UNUSED(context, context.isWorkerGlobalScope());
             processPendingTasks();
         });
index b0c1bac..4480aef 100644 (file)
@@ -306,7 +306,7 @@ void WebSocket::connect(const String& url, const Vector<String>& protocols, Exce
                 });
             });
 #else
-            RunLoop::main().dispatch([this, protectedThis = Ref<WebSocket>(*this)]() {
+            RunLoop::main().dispatch([this, protectedThis = makeRef(*this)]() {
                 dispatchOrQueueErrorEvent();
                 stop();
             });
index e55a25b..138bb20 100644 (file)
@@ -111,7 +111,7 @@ inline JSC::JSObject* JSEventListener::jsFunction(ScriptExecutionContext* script
 {
     // initializeJSFunction can trigger code that deletes this event listener
     // before we're done. It should always return 0 in this case.
-    Ref<JSEventListener> protect(const_cast<JSEventListener&>(*this));
+    auto protect = makeRef(const_cast<JSEventListener&>(*this));
     JSC::Strong<JSC::JSObject> wrapper(m_isolatedWorld->vm(), m_wrapper.get());
 
     if (!m_jsFunction) {
index 156e353..d4b0d30 100644 (file)
@@ -1480,7 +1480,7 @@ void Node::setTextContent(const String& text, ExceptionCode& ec)
         case ELEMENT_NODE:
         case ATTRIBUTE_NODE:
         case DOCUMENT_FRAGMENT_NODE: {
-            Ref<ContainerNode> container(downcast<ContainerNode>(*this));
+            auto container = makeRef(downcast<ContainerNode>(*this));
             ChildListMutationScope mutation(container);
             container->removeChildren();
             if (!text.isEmpty())
index 5f8d8bb..e28d908 100644 (file)
@@ -4016,7 +4016,7 @@ void HTMLMediaElement::updateCaptionContainer()
 void HTMLMediaElement::layoutSizeChanged()
 {
 #if ENABLE(MEDIA_CONTROLS_SCRIPT)
-    auto task = [this, protectedThis = Ref<Element>(*this)] {
+    auto task = [this, protectedThis = makeRef(*this)] {
         if (ShadowRoot* root = userAgentShadowRoot())
             root->dispatchEvent(Event::create("resize", false, false));
     };
index 4adacd9..9a4049b 100644 (file)
@@ -144,7 +144,7 @@ JSValue CommandLineAPIHost::wrapper(ExecState* exec, JSDOMGlobalObject* globalOb
 
     JSObject* prototype = JSCommandLineAPIHost::createPrototype(exec->vm(), globalObject);
     Structure* structure = JSCommandLineAPIHost::createStructure(exec->vm(), globalObject, prototype);
-    JSCommandLineAPIHost* commandLineAPIHost = JSCommandLineAPIHost::create(structure, globalObject, Ref<CommandLineAPIHost>(*this));
+    JSCommandLineAPIHost* commandLineAPIHost = JSCommandLineAPIHost::create(structure, globalObject, makeRef(*this));
     m_wrappers.addWrapper(globalObject, commandLineAPIHost);
 
     return commandLineAPIHost;
index 522aa36..56a993b 100644 (file)
@@ -323,7 +323,7 @@ void AudioSourceProviderAVFObjC::prepare(CMItemCount maxFrames, const AudioStrea
     memset(m_list.get(), 0, bufferListSize);
     m_list->mNumberBuffers = numberOfChannels;
 
-    callOnMainThread([protectedThis = Ref<AudioSourceProviderAVFObjC>(*this), numberOfChannels, sampleRate] {
+    callOnMainThread([protectedThis = makeRef(*this), numberOfChannels, sampleRate] {
         protectedThis->m_client->setFormat(numberOfChannels, sampleRate);
     });
 }
index 7a97ada..11000da 100644 (file)
@@ -104,7 +104,7 @@ void WebCoreAVCFResourceLoader::invalidate()
 
     m_parent = nullptr;
 
-    callOnMainThread([protectedThis = Ref<WebCoreAVCFResourceLoader>(*this)] () mutable {
+    callOnMainThread([protectedThis = makeRef(*this)] () mutable {
         protectedThis->stopLoading();
     });
 }
index 9f075ec..f43cc01 100644 (file)
@@ -101,7 +101,7 @@ void WebCoreAVFResourceLoader::invalidate()
 
     m_parent = nullptr;
 
-    callOnMainThread([protectedThis = Ref<WebCoreAVFResourceLoader>(*this)] () mutable {
+    callOnMainThread([protectedThis = makeRef(*this)] () mutable {
         protectedThis->stopLoading();
     });
 }
index 314e4d1..d621680 100644 (file)
@@ -435,7 +435,7 @@ void WebVideoFullscreenControllerContext::setLegibleMediaSelectionOptions(const
 void WebVideoFullscreenControllerContext::setExternalPlayback(bool enabled, ExternalPlaybackTargetType type, String localizedDeviceName)
 {
     ASSERT(WebThreadIsCurrent());
-    callOnMainThread([protectedThis = Ref<WebVideoFullscreenControllerContext>(*this), this, enabled, type, localizedDeviceName = localizedDeviceName.isolatedCopy()] {
+    callOnMainThread([protectedThis = makeRef(*this), this, enabled, type, localizedDeviceName = localizedDeviceName.isolatedCopy()] {
         if (m_interface)
             m_interface->setExternalPlayback(enabled, type, localizedDeviceName);
     });
index 74749da..92ece09 100644 (file)
@@ -178,7 +178,7 @@ void BlobResourceHandle::start()
     }
 
     // Finish this async call quickly and return.
-    callOnMainThread([protectedThis = Ref<BlobResourceHandle>(*this)]() mutable {
+    callOnMainThread([protectedThis = makeRef(*this)]() mutable {
         protectedThis->doStart();
     });
 }
@@ -652,7 +652,7 @@ void BlobResourceHandle::notifyFinish()
 
     // Schedule to notify the client from a standalone function because the client might dispose the handle immediately from the callback function
     // while we still have BlobResourceHandle calls in the stack.
-    callOnMainThread([protectedThis = Ref<BlobResourceHandle>(*this)]() mutable {
+    callOnMainThread([protectedThis = makeRef(*this)]() mutable {
         doNotifyFinish(protectedThis);
     });
 
index 6ae4b4a..e3844e7 100644 (file)
@@ -91,7 +91,7 @@ void SocketStreamHandleBase::close()
 
 void SocketStreamHandleBase::disconnect()
 {
-    Ref<SocketStreamHandle> protect(static_cast<SocketStreamHandle&>(*this)); // platformClose calls the client, which may make the handle get deallocated immediately.
+    auto protect = makeRef(static_cast<SocketStreamHandle&>(*this)); // platformClose calls the client, which may make the handle get deallocated immediately.
 
     platformClose();
     m_state = Closed;
index 3c9c462..4408cd1 100644 (file)
@@ -403,7 +403,7 @@ void CurlDownload::didReceiveHeader(const String& header)
 
         if (httpCode >= 200 && httpCode < 300) {
             URL url = getCurlEffectiveURL(m_curlHandle);
-            callOnMainThread([this, url = url.isolatedCopy(), protectedThis = Ref<CurlDownload>(*this)] {
+            callOnMainThread([this, url = url.isolatedCopy(), protectedThis = makeRef(*this)] {
                 m_response.setURL(url);
                 m_response.setMimeType(extractMIMETypeFromMediaType(m_response.httpHeaderField(HTTPHeaderName::ContentType)));
                 m_response.setTextEncodingName(extractCharsetFromMediaType(m_response.httpHeaderField(HTTPHeaderName::ContentType)));
@@ -412,7 +412,7 @@ void CurlDownload::didReceiveHeader(const String& header)
             });
         }
     } else {
-        callOnMainThread([this, header = header.isolatedCopy(), protectedThis = Ref<CurlDownload>(*this)] {
+        callOnMainThread([this, header = header.isolatedCopy(), protectedThis = makeRef(*this)] {
             int splitPos = header.find(":");
             if (splitPos != -1)
                 m_response.setHTTPHeaderField(header.left(splitPos), header.substring(splitPos + 1).stripWhiteSpace());
index b210ef9..8a45154 100644 (file)
@@ -1,3 +1,71 @@
+2016-07-15  Geoffrey Garen  <ggaren@apple.com>
+
+        Added a makeRef<T> helper
+        https://bugs.webkit.org/show_bug.cgi?id=159835
+
+        Reviewed by Andreas Kling.
+
+        Anders told me to!
+
+        * NetworkProcess/NetworkConnectionToWebProcess.cpp:
+        (WebKit::NetworkConnectionToWebProcess::writeBlobsToTemporaryFiles):
+        * NetworkProcess/NetworkResourceLoader.cpp:
+        (WebKit::NetworkResourceLoader::tryStoreAsCacheEntry):
+        * Platform/IPC/Connection.cpp:
+        (IPC::Connection::addWorkQueueMessageReceiver):
+        (IPC::Connection::removeWorkQueueMessageReceiver):
+        (IPC::Connection::invalidate):
+        (IPC::Connection::sendMessage):
+        (IPC::Connection::processIncomingMessage):
+        (IPC::Connection::postConnectionDidCloseOnConnectionWorkQueue):
+        (IPC::Connection::connectionDidClose):
+        (IPC::Connection::enqueueIncomingMessage):
+        * Platform/IPC/mac/ConnectionMac.mm:
+        (IPC::Connection::receiveSourceEventHandler):
+        * Shared/CoordinatedGraphics/threadedcompositor/ThreadedCompositor.cpp:
+        (WebKit::ThreadedCompositor::setNativeSurfaceHandleForCompositing):
+        (WebKit::ThreadedCompositor::setDeviceScaleFactor):
+        (WebKit::ThreadedCompositor::didChangeViewportSize):
+        (WebKit::ThreadedCompositor::didChangeViewportAttribute):
+        (WebKit::ThreadedCompositor::didChangeContentsSize):
+        (WebKit::ThreadedCompositor::scrollTo):
+        (WebKit::ThreadedCompositor::scrollBy):
+        (WebKit::ThreadedCompositor::didChangeVisibleRect):
+        * UIProcess/API/APIUserContentExtensionStore.cpp:
+        (API::UserContentExtensionStore::lookupContentExtension):
+        (API::UserContentExtensionStore::compileContentExtension):
+        (API::UserContentExtensionStore::removeContentExtension):
+        * UIProcess/Launcher/ProcessLauncher.cpp:
+        (WebKit::ProcessLauncher::ProcessLauncher):
+        * UIProcess/Storage/LocalStorageDatabaseTracker.cpp:
+        (WebKit::LocalStorageDatabaseTracker::LocalStorageDatabaseTracker):
+        * UIProcess/Storage/StorageManager.cpp:
+        (WebKit::StorageManager::createSessionStorageNamespace):
+        (WebKit::StorageManager::destroySessionStorageNamespace):
+        (WebKit::StorageManager::setAllowedSessionStorageNamespaceConnection):
+        (WebKit::StorageManager::cloneSessionStorageNamespace):
+        (WebKit::StorageManager::processDidCloseConnection):
+        (WebKit::StorageManager::getSessionStorageOrigins):
+        (WebKit::StorageManager::deleteSessionStorageOrigins):
+        (WebKit::StorageManager::deleteSessionStorageEntriesForOrigins):
+        (WebKit::StorageManager::getLocalStorageOrigins):
+        (WebKit::StorageManager::getLocalStorageOriginDetails):
+        (WebKit::StorageManager::deleteLocalStorageEntriesForOrigin):
+        (WebKit::StorageManager::deleteLocalStorageOriginsModifiedSince):
+        (WebKit::StorageManager::deleteLocalStorageEntriesForOrigins):
+        * UIProcess/WebResourceLoadStatisticsStore.cpp:
+        (WebKit::WebResourceLoadStatisticsStore::readDataFromDiskIfNeeded):
+        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+        (WebKit::WebsiteDataStore::fetchData):
+        * WebProcess/Plugins/Netscape/NetscapePlugin.cpp:
+        (WebKit::NetscapePlugin::pluginThreadAsyncCall):
+        * WebProcess/WebPage/EventDispatcher.cpp:
+        (WebKit::EventDispatcher::wheelEvent):
+        (WebKit::EventDispatcher::gestureEvent):
+        (WebKit::EventDispatcher::touchEvent):
+        * WebProcess/WebPage/ViewUpdateDispatcher.cpp:
+        (WebKit::ViewUpdateDispatcher::visibleContentRectUpdate):
+
 2016-07-15  Chris Dumez  <cdumez@apple.com>
 
         Use fastGetAttribute() / setAttributeWithoutSynchronization() when possible
index f37ee4b..fc0229c 100644 (file)
@@ -315,7 +315,7 @@ void NetworkConnectionToWebProcess::writeBlobsToTemporaryFiles(const Vector<Stri
     for (auto& file : fileReferences)
         file->prepareForFileAccess();
 
-    NetworkBlobRegistry::singleton().writeBlobsToTemporaryFiles(blobURLs, [this, protectedThis = Ref<NetworkConnectionToWebProcess>(*this), requestIdentifier, fileReferences = WTFMove(fileReferences)](auto& fileNames) mutable {
+    NetworkBlobRegistry::singleton().writeBlobsToTemporaryFiles(blobURLs, [this, protectedThis = makeRef(*this), requestIdentifier, fileReferences = WTFMove(fileReferences)](auto& fileNames) mutable {
         for (auto& file : fileReferences)
             file->revokeFileAccess();
 
index e944b2c..6b3186f 100644 (file)
@@ -529,7 +529,7 @@ void NetworkResourceLoader::tryStoreAsCacheEntry()
     if (!m_bufferedDataForCache)
         return;
 
-    NetworkCache::singleton().store(m_networkLoad->currentRequest(), m_response, WTFMove(m_bufferedDataForCache), [loader = Ref<NetworkResourceLoader>(*this)](auto& mappedBody) mutable {
+    NetworkCache::singleton().store(m_networkLoad->currentRequest(), m_response, WTFMove(m_bufferedDataForCache), [loader = makeRef(*this)](auto& mappedBody) mutable {
 #if ENABLE(SHAREABLE_RESOURCE)
         if (mappedBody.shareableResourceHandle.isNull())
             return;
index 07be405..2d7328b 100644 (file)
@@ -253,7 +253,7 @@ void Connection::addWorkQueueMessageReceiver(StringReference messageReceiverName
 {
     ASSERT(RunLoop::isMain());
 
-    m_connectionQueue->dispatch([protectedThis = Ref<Connection>(*this), messageReceiverName = WTFMove(messageReceiverName), workQueue, workQueueMessageReceiver]() mutable {
+    m_connectionQueue->dispatch([protectedThis = makeRef(*this), messageReceiverName = WTFMove(messageReceiverName), workQueue, workQueueMessageReceiver]() mutable {
         ASSERT(!protectedThis->m_workQueueMessageReceivers.contains(messageReceiverName));
 
         protectedThis->m_workQueueMessageReceivers.add(messageReceiverName, std::make_pair(workQueue, workQueueMessageReceiver));
@@ -264,7 +264,7 @@ void Connection::removeWorkQueueMessageReceiver(StringReference messageReceiverN
 {
     ASSERT(RunLoop::isMain());
 
-    m_connectionQueue->dispatch([protectedThis = Ref<Connection>(*this), messageReceiverName = WTFMove(messageReceiverName)]() mutable {
+    m_connectionQueue->dispatch([protectedThis = makeRef(*this), messageReceiverName = WTFMove(messageReceiverName)]() mutable {
         ASSERT(protectedThis->m_workQueueMessageReceivers.contains(messageReceiverName));
         protectedThis->m_workQueueMessageReceivers.remove(messageReceiverName);
     });
@@ -317,7 +317,7 @@ void Connection::invalidate()
     
     m_client = nullptr;
 
-    m_connectionQueue->dispatch([protectedThis = Ref<Connection>(*this)]() mutable {
+    m_connectionQueue->dispatch([protectedThis = makeRef(*this)]() mutable {
         protectedThis->platformInvalidate();
     });
 }
@@ -374,7 +374,7 @@ bool Connection::sendMessage(std::unique_ptr<MessageEncoder> encoder, unsigned m
     }
     
     // FIXME: We should add a boolean flag so we don't call this when work has already been scheduled.
-    m_connectionQueue->dispatch([protectedThis = Ref<Connection>(*this)]() mutable {
+    m_connectionQueue->dispatch([protectedThis = makeRef(*this)]() mutable {
         protectedThis->sendOutgoingMessages();
     });
     return true;
@@ -647,7 +647,7 @@ void Connection::processIncomingMessage(std::unique_ptr<MessageDecoder> message)
         StringReference messageNameReference = message->messageName();
         String messageName(messageNameReference.isEmpty() ? "<unknown message>" : String(messageNameReference.data(), messageNameReference.size()));
 
-        RunLoop::main().dispatch([protectedThis = Ref<Connection>(*this), messageReceiverName = WTFMove(messageReceiverName), messageName = WTFMove(messageName)]() mutable {
+        RunLoop::main().dispatch([protectedThis = makeRef(*this), messageReceiverName = WTFMove(messageReceiverName), messageName = WTFMove(messageName)]() mutable {
             protectedThis->dispatchDidReceiveInvalidMessage(messageReceiverName.utf8(), messageName.utf8());
         });
         return;
@@ -655,7 +655,7 @@ void Connection::processIncomingMessage(std::unique_ptr<MessageDecoder> message)
 
     auto it = m_workQueueMessageReceivers.find(message->messageReceiverName());
     if (it != m_workQueueMessageReceivers.end()) {
-        it->value.first->dispatch([protectedThis = Ref<Connection>(*this), workQueueMessageReceiver = it->value.second, decoder = WTFMove(message)]() mutable {
+        it->value.first->dispatch([protectedThis = makeRef(*this), workQueueMessageReceiver = it->value.second, decoder = WTFMove(message)]() mutable {
             protectedThis->dispatchWorkQueueMessageReceiverMessage(*workQueueMessageReceiver, *decoder);
         });
         return;
@@ -739,7 +739,7 @@ bool Connection::hasIncomingSyncMessage()
 
 void Connection::postConnectionDidCloseOnConnectionWorkQueue()
 {
-    m_connectionQueue->dispatch([protectedThis = Ref<Connection>(*this)]() mutable {
+    m_connectionQueue->dispatch([protectedThis = makeRef(*this)]() mutable {
         protectedThis->connectionDidClose();
     });
 }
@@ -772,7 +772,7 @@ void Connection::connectionDidClose()
     if (m_didCloseOnConnectionWorkQueueCallback)
         m_didCloseOnConnectionWorkQueueCallback(this);
 
-    RunLoop::main().dispatch([protectedThis = Ref<Connection>(*this)]() mutable {
+    RunLoop::main().dispatch([protectedThis = makeRef(*this)]() mutable {
         // If the connection has been explicitly invalidated before dispatchConnectionDidClose was called,
         // then the client will be null here.
         if (!protectedThis->m_client)
@@ -877,7 +877,7 @@ void Connection::enqueueIncomingMessage(std::unique_ptr<MessageDecoder> incoming
         m_incomingMessages.append(WTFMove(incomingMessage));
     }
 
-    RunLoop::main().dispatch([protectedThis = Ref<Connection>(*this)]() mutable {
+    RunLoop::main().dispatch([protectedThis = makeRef(*this)]() mutable {
         protectedThis->dispatchOneMessage();
     });
 }
index 5fe0bfb..ff666ff 100644 (file)
@@ -523,7 +523,7 @@ void Connection::receiveSourceEventHandler()
             StringReference messageNameReference = decoder->messageName();
             String messageName(String(messageNameReference.data(), messageNameReference.size()));
 
-            RunLoop::main().dispatch([protectedThis = Ref<Connection>(*this), messageReceiverName = WTFMove(messageReceiverName), messageName = WTFMove(messageName)]() mutable {
+            RunLoop::main().dispatch([protectedThis = makeRef(*this), messageReceiverName = WTFMove(messageReceiverName), messageName = WTFMove(messageName)]() mutable {
                 protectedThis->dispatchDidReceiveInvalidMessage(messageReceiverName.utf8(), messageName.utf8());
             });
             return;
index 22fe3b9..5bee40c 100644 (file)
@@ -62,7 +62,7 @@ ThreadedCompositor::~ThreadedCompositor()
 void ThreadedCompositor::setNativeSurfaceHandleForCompositing(uint64_t handle)
 {
     m_compositingRunLoop->stopUpdateTimer();
-    m_compositingRunLoop->performTaskSync([this, protectedThis = Ref<ThreadedCompositor>(*this), handle] {
+    m_compositingRunLoop->performTaskSync([this, protectedThis = makeRef(*this), handle] {
         m_scene->setActive(!!handle);
 
         // A new native handle can't be set without destroying the previous one first if any.
@@ -75,7 +75,7 @@ void ThreadedCompositor::setNativeSurfaceHandleForCompositing(uint64_t handle)
 
 void ThreadedCompositor::setDeviceScaleFactor(float scale)
 {
-    m_compositingRunLoop->performTask([this, protectedThis = Ref<ThreadedCompositor>(*this), scale] {
+    m_compositingRunLoop->performTask([this, protectedThis = makeRef(*this), scale] {
         m_deviceScaleFactor = scale;
         scheduleDisplayImmediately();
     });
@@ -83,35 +83,35 @@ void ThreadedCompositor::setDeviceScaleFactor(float scale)
 
 void ThreadedCompositor::didChangeViewportSize(const IntSize& size)
 {
-    m_compositingRunLoop->performTaskSync([this, protectedThis = Ref<ThreadedCompositor>(*this), size] {
+    m_compositingRunLoop->performTaskSync([this, protectedThis = makeRef(*this), size] {
         m_viewportController->didChangeViewportSize(size);
     });
 }
 
 void ThreadedCompositor::didChangeViewportAttribute(const ViewportAttributes& attr)
 {
-    m_compositingRunLoop->performTask([this, protectedThis = Ref<ThreadedCompositor>(*this), attr] {
+    m_compositingRunLoop->performTask([this, protectedThis = makeRef(*this), attr] {
         m_viewportController->didChangeViewportAttribute(attr);
     });
 }
 
 void ThreadedCompositor::didChangeContentsSize(const IntSize& size)
 {
-    m_compositingRunLoop->performTask([this, protectedThis = Ref<ThreadedCompositor>(*this), size] {
+    m_compositingRunLoop->performTask([this, protectedThis = makeRef(*this), size] {
         m_viewportController->didChangeContentsSize(size);
     });
 }
 
 void ThreadedCompositor::scrollTo(const IntPoint& position)
 {
-    m_compositingRunLoop->performTask([this, protectedThis = Ref<ThreadedCompositor>(*this), position] {
+    m_compositingRunLoop->performTask([this, protectedThis = makeRef(*this), position] {
         m_viewportController->scrollTo(position);
     });
 }
 
 void ThreadedCompositor::scrollBy(const IntSize& delta)
 {
-    m_compositingRunLoop->performTask([this, protectedThis = Ref<ThreadedCompositor>(*this), delta] {
+    m_compositingRunLoop->performTask([this, protectedThis = makeRef(*this), delta] {
         m_viewportController->scrollBy(delta);
     });
 }
@@ -173,7 +173,7 @@ void ThreadedCompositor::scheduleDisplayImmediately()
 
 void ThreadedCompositor::didChangeVisibleRect()
 {
-    RunLoop::main().dispatch([this, protectedThis = Ref<ThreadedCompositor>(*this), visibleRect = m_viewportController->visibleContentsRect(), scale = m_viewportController->pageScaleFactor()] {
+    RunLoop::main().dispatch([this, protectedThis = makeRef(*this), visibleRect = m_viewportController->visibleContentsRect(), scale = m_viewportController->pageScaleFactor()] {
         m_client->setVisibleContentsRect(visibleRect, FloatPoint::zero(), scale);
     });
 
index 0824e12..86c3324 100644 (file)
@@ -306,7 +306,7 @@ static RefPtr<API::UserContentExtension> createExtension(const String& identifie
 
 void UserContentExtensionStore::lookupContentExtension(const WTF::String& identifier, std::function<void(RefPtr<API::UserContentExtension>, std::error_code)> completionHandler)
 {
-    m_readQueue->dispatch([protectedThis = Ref<Object>(*this), identifier = identifier.isolatedCopy(), storePath = m_storePath.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable {
+    m_readQueue->dispatch([protectedThis = makeRef(*this), identifier = identifier.isolatedCopy(), storePath = m_storePath.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable {
         auto path = constructedPath(storePath, identifier);
         
         ContentExtensionMetaData metaData;
@@ -334,7 +334,7 @@ void UserContentExtensionStore::lookupContentExtension(const WTF::String& identi
 
 void UserContentExtensionStore::compileContentExtension(const WTF::String& identifier, WTF::String&& json, std::function<void(RefPtr<API::UserContentExtension>, std::error_code)> completionHandler)
 {
-    m_compileQueue->dispatch([protectedThis = Ref<Object>(*this), identifier = identifier.isolatedCopy(), json = json.isolatedCopy(), storePath = m_storePath.isolatedCopy(), completionHandler = WTFMove(completionHandler)] () mutable {
+    m_compileQueue->dispatch([protectedThis = makeRef(*this), identifier = identifier.isolatedCopy(), json = json.isolatedCopy(), storePath = m_storePath.isolatedCopy(), completionHandler = WTFMove(completionHandler)] () mutable {
         auto path = constructedPath(storePath, identifier);
 
         ContentExtensionMetaData metaData;
@@ -356,7 +356,7 @@ void UserContentExtensionStore::compileContentExtension(const WTF::String& ident
 
 void UserContentExtensionStore::removeContentExtension(const WTF::String& identifier, std::function<void(std::error_code)> completionHandler)
 {
-    m_removeQueue->dispatch([protectedThis = Ref<Object>(*this), identifier = identifier.isolatedCopy(), storePath = m_storePath.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable {
+    m_removeQueue->dispatch([protectedThis = makeRef(*this), identifier = identifier.isolatedCopy(), storePath = m_storePath.isolatedCopy(), completionHandler = WTFMove(completionHandler)]() mutable {
         auto path = constructedPath(storePath, identifier);
 
         if (!WebCore::deleteFile(path)) {
index a903db7..f8584c9 100644 (file)
@@ -45,7 +45,7 @@ ProcessLauncher::ProcessLauncher(Client* client, const LaunchOptions& launchOpti
 {
     m_isLaunching = true;
 
-    processLauncherWorkQueue().dispatch([processLauncher = Ref<ProcessLauncher>(*this)]() mutable {
+    processLauncherWorkQueue().dispatch([processLauncher = makeRef(*this)]() mutable {
         processLauncher->launchProcess();
     });
 }
index 036c8ed..fa3fa6e 100644 (file)
@@ -52,7 +52,7 @@ LocalStorageDatabaseTracker::LocalStorageDatabaseTracker(PassRefPtr<WorkQueue> q
     // Make sure the encoding is initialized before we start dispatching things to the queue.
     UTF8Encoding();
 
-    m_queue->dispatch([protectedThis = Ref<LocalStorageDatabaseTracker>(*this)]() mutable {
+    m_queue->dispatch([protectedThis = makeRef(*this)]() mutable {
         protectedThis->importOriginIdentifiers();
     });
 }
index 15c98ea..be0598d 100644 (file)
@@ -473,7 +473,7 @@ StorageManager::~StorageManager()
 
 void StorageManager::createSessionStorageNamespace(uint64_t storageNamespaceID, unsigned quotaInBytes)
 {
-    m_queue->dispatch([this, protectedThis = Ref<StorageManager>(*this), storageNamespaceID, quotaInBytes]() mutable {
+    m_queue->dispatch([this, protectedThis = makeRef(*this), storageNamespaceID, quotaInBytes]() mutable {
         ASSERT(!m_sessionStorageNamespaces.contains(storageNamespaceID));
 
         m_sessionStorageNamespaces.set(storageNamespaceID, SessionStorageNamespace::create(quotaInBytes));
@@ -482,7 +482,7 @@ void StorageManager::createSessionStorageNamespace(uint64_t storageNamespaceID,
 
 void StorageManager::destroySessionStorageNamespace(uint64_t storageNamespaceID)
 {
-    m_queue->dispatch([this, protectedThis = Ref<StorageManager>(*this), storageNamespaceID] {
+    m_queue->dispatch([this, protectedThis = makeRef(*this), storageNamespaceID] {
         ASSERT(m_sessionStorageNamespaces.contains(storageNamespaceID));
         m_sessionStorageNamespaces.remove(storageNamespaceID);
     });
@@ -490,7 +490,7 @@ void StorageManager::destroySessionStorageNamespace(uint64_t storageNamespaceID)
 
 void StorageManager::setAllowedSessionStorageNamespaceConnection(uint64_t storageNamespaceID, IPC::Connection* allowedConnection)
 {
-    m_queue->dispatch([this, protectedThis = Ref<StorageManager>(*this), connection = RefPtr<IPC::Connection>(allowedConnection), storageNamespaceID]() mutable {
+    m_queue->dispatch([this, protectedThis = makeRef(*this), connection = RefPtr<IPC::Connection>(allowedConnection), storageNamespaceID]() mutable {
         ASSERT(m_sessionStorageNamespaces.contains(storageNamespaceID));
 
         m_sessionStorageNamespaces.get(storageNamespaceID)->setAllowedConnection(connection.get());
@@ -499,7 +499,7 @@ void StorageManager::setAllowedSessionStorageNamespaceConnection(uint64_t storag
 
 void StorageManager::cloneSessionStorageNamespace(uint64_t storageNamespaceID, uint64_t newStorageNamespaceID)
 {
-    m_queue->dispatch([this, protectedThis = Ref<StorageManager>(*this), storageNamespaceID, newStorageNamespaceID] {
+    m_queue->dispatch([this, protectedThis = makeRef(*this), storageNamespaceID, newStorageNamespaceID] {
         SessionStorageNamespace* sessionStorageNamespace = m_sessionStorageNamespaces.get(storageNamespaceID);
         if (!sessionStorageNamespace) {
             // FIXME: We can get into this situation if someone closes the originating page from within a
@@ -524,7 +524,7 @@ void StorageManager::processDidCloseConnection(WebProcessProxy&, IPC::Connection
 {
     connection.removeWorkQueueMessageReceiver(Messages::StorageManager::messageReceiverName());
 
-    m_queue->dispatch([this, protectedThis = Ref<StorageManager>(*this), connection = Ref<IPC::Connection>(connection)]() mutable {
+    m_queue->dispatch([this, protectedThis = makeRef(*this), connection = Ref<IPC::Connection>(connection)]() mutable {
         Vector<std::pair<RefPtr<IPC::Connection>, uint64_t>> connectionAndStorageMapIDPairsToRemove;
         for (auto& storageArea : m_storageAreasByConnection) {
             if (storageArea.key.first != connection.ptr())
@@ -543,7 +543,7 @@ void StorageManager::getSessionStorageOrigins(std::function<void (HashSet<RefPtr
 {
     RefPtr<StorageManager> storageManager(this);
 
-    m_queue->dispatch([this, protectedThis = Ref<StorageManager>(*this), completionHandler = WTFMove(completionHandler)]() mutable {
+    m_queue->dispatch([this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)]() mutable {
         HashSet<RefPtr<SecurityOrigin>> origins;
 
         for (const auto& sessionStorageNamespace : m_sessionStorageNamespaces.values()) {
@@ -559,7 +559,7 @@ void StorageManager::getSessionStorageOrigins(std::function<void (HashSet<RefPtr
 
 void StorageManager::deleteSessionStorageOrigins(std::function<void ()>&& completionHandler)
 {
-    m_queue->dispatch([this, protectedThis = Ref<StorageManager>(*this), completionHandler = WTFMove(completionHandler)]() mutable {
+    m_queue->dispatch([this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)]() mutable {
         for (auto& sessionStorageNamespace : m_sessionStorageNamespaces.values())
             sessionStorageNamespace->clearAllStorageAreas();
 
@@ -575,7 +575,7 @@ void StorageManager::deleteSessionStorageEntriesForOrigins(const Vector<RefPtr<W
     for (auto& origin : origins)
         copiedOrigins.uncheckedAppend(origin->isolatedCopy());
 
-    m_queue->dispatch([this, protectedThis = Ref<StorageManager>(*this), copiedOrigins = WTFMove(copiedOrigins), completionHandler = WTFMove(completionHandler)]() mutable {
+    m_queue->dispatch([this, protectedThis = makeRef(*this), copiedOrigins = WTFMove(copiedOrigins), completionHandler = WTFMove(completionHandler)]() mutable {
         for (auto& origin : copiedOrigins) {
             for (auto& sessionStorageNamespace : m_sessionStorageNamespaces.values())
                 sessionStorageNamespace->clearStorageAreasMatchingOrigin(*origin);
@@ -587,7 +587,7 @@ void StorageManager::deleteSessionStorageEntriesForOrigins(const Vector<RefPtr<W
 
 void StorageManager::getLocalStorageOrigins(std::function<void (HashSet<RefPtr<WebCore::SecurityOrigin>>&&)>&& completionHandler)
 {
-    m_queue->dispatch([this, protectedThis = Ref<StorageManager>(*this), completionHandler = WTFMove(completionHandler)]() mutable {
+    m_queue->dispatch([this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)]() mutable {
         HashSet<RefPtr<SecurityOrigin>> origins;
 
         for (auto& origin : m_localStorageDatabaseTracker->origins())
@@ -606,7 +606,7 @@ void StorageManager::getLocalStorageOrigins(std::function<void (HashSet<RefPtr<W
 
 void StorageManager::getLocalStorageOriginDetails(std::function<void (Vector<LocalStorageDatabaseTracker::OriginDetails>)>&& completionHandler)
 {
-    m_queue->dispatch([this, protectedThis = Ref<StorageManager>(*this), completionHandler = WTFMove(completionHandler)]() mutable {
+    m_queue->dispatch([this, protectedThis = makeRef(*this), completionHandler = WTFMove(completionHandler)]() mutable {
         auto originDetails = m_localStorageDatabaseTracker->originDetails();
 
         RunLoop::main().dispatch([originDetails = WTFMove(originDetails), completionHandler = WTFMove(completionHandler)]() mutable {
@@ -617,7 +617,7 @@ void StorageManager::getLocalStorageOriginDetails(std::function<void (Vector<Loc
 
 void StorageManager::deleteLocalStorageEntriesForOrigin(const SecurityOrigin& securityOrigin)
 {
-    m_queue->dispatch([this, protectedThis = Ref<StorageManager>(*this), copiedOrigin = securityOrigin.isolatedCopy()]() mutable {
+    m_queue->dispatch([this, protectedThis = makeRef(*this), copiedOrigin = securityOrigin.isolatedCopy()]() mutable {
         for (auto& localStorageNamespace : m_localStorageNamespaces.values())
             localStorageNamespace->clearStorageAreasMatchingOrigin(copiedOrigin);
 
@@ -630,7 +630,7 @@ void StorageManager::deleteLocalStorageEntriesForOrigin(const SecurityOrigin& se
 
 void StorageManager::deleteLocalStorageOriginsModifiedSince(std::chrono::system_clock::time_point time, std::function<void ()>&& completionHandler)
 {
-    m_queue->dispatch([this, protectedThis = Ref<StorageManager>(*this), time, completionHandler = WTFMove(completionHandler)]() mutable {
+    m_queue->dispatch([this, protectedThis = makeRef(*this), time, completionHandler = WTFMove(completionHandler)]() mutable {
         auto deletedOrigins = m_localStorageDatabaseTracker->deleteDatabasesModifiedSince(time);
 
         for (const auto& origin : deletedOrigins) {
@@ -653,7 +653,7 @@ void StorageManager::deleteLocalStorageEntriesForOrigins(const Vector<RefPtr<Web
     for (auto& origin : origins)
         copiedOrigins.uncheckedAppend(origin->isolatedCopy());
 
-    m_queue->dispatch([this, protectedThis = Ref<StorageManager>(*this), copiedOrigins = WTFMove(copiedOrigins), completionHandler = WTFMove(completionHandler)]() mutable {
+    m_queue->dispatch([this, protectedThis = makeRef(*this), copiedOrigins = WTFMove(copiedOrigins), completionHandler = WTFMove(completionHandler)]() mutable {
         for (auto& origin : copiedOrigins) {
             for (auto& localStorageNamespace : m_localStorageNamespaces.values())
                 localStorageNamespace->clearStorageAreasMatchingOrigin(*origin);
index 45597c6..96db5c3 100644 (file)
@@ -117,7 +117,7 @@ void WebResourceLoadStatisticsStore::readDataFromDiskIfNeeded()
     if (!m_resourceLoadStatisticsEnabled)
         return;
 
-    m_statisticsQueue->dispatch([this, protectedThis = Ref<WebResourceLoadStatisticsStore>(*this)] {
+    m_statisticsQueue->dispatch([this, protectedThis = makeRef(*this)] {
         coreStore().clear();
 
         auto decoder = createDecoderFromDisk("full_browsing_session");
index a2db58a..d8aa0d5 100644 (file)
@@ -231,7 +231,7 @@ void WebsiteDataStore::fetchData(OptionSet<WebsiteDataType> dataTypes, OptionSet
             if (pendingCallbacks)
                 return;
 
-            RunLoop::main().dispatch([callbackAggregator = Ref<CallbackAggregator>(*this)]() mutable {
+            RunLoop::main().dispatch([callbackAggregator = makeRef(*this)]() mutable {
 
                 WTF::Vector<WebsiteDataRecord> records;
                 records.reserveInitialCapacity(callbackAggregator->m_websiteDataRecords.size());
index 8f15d35..6569550 100644 (file)
@@ -302,7 +302,7 @@ void NetscapePlugin::popPopupsEnabledState()
 
 void NetscapePlugin::pluginThreadAsyncCall(void (*function)(void*), void* userData)
 {
-    RunLoop::main().dispatch([protectedThis = Ref<NetscapePlugin>(*this), function, userData] {
+    RunLoop::main().dispatch([protectedThis = makeRef(*this), function, userData] {
         if (!protectedThis->m_isStarted)
             return;
 
index dd6defb..44929d1 100644 (file)
@@ -138,7 +138,7 @@ void EventDispatcher::wheelEvent(uint64_t pageID, const WebWheelEvent& wheelEven
     UNUSED_PARAM(canRubberBandAtBottom);
 #endif
 
-    RunLoop::main().dispatch([protectedThis = Ref<EventDispatcher>(*this), pageID, wheelEvent]() mutable {
+    RunLoop::main().dispatch([protectedThis = makeRef(*this), pageID, wheelEvent]() mutable {
         protectedThis->dispatchWheelEvent(pageID, wheelEvent);
     }); 
 }
@@ -146,7 +146,7 @@ void EventDispatcher::wheelEvent(uint64_t pageID, const WebWheelEvent& wheelEven
 #if ENABLE(MAC_GESTURE_EVENTS)
 void EventDispatcher::gestureEvent(uint64_t pageID, const WebKit::WebGestureEvent& gestureEvent)
 {
-    RunLoop::main().dispatch([protectedThis = Ref<EventDispatcher>(*this), pageID, gestureEvent]() mutable {
+    RunLoop::main().dispatch([protectedThis = makeRef(*this), pageID, gestureEvent]() mutable {
         protectedThis->dispatchGestureEvent(pageID, gestureEvent);
     });
 }
@@ -189,7 +189,7 @@ void EventDispatcher::touchEvent(uint64_t pageID, const WebKit::WebTouchEvent& t
     }
 
     if (updateListWasEmpty) {
-        RunLoop::main().dispatch([protectedThis = Ref<EventDispatcher>(*this)]() mutable {
+        RunLoop::main().dispatch([protectedThis = makeRef(*this)]() mutable {
             protectedThis->dispatchTouchEvents();
         });
     }
index 7d9c0b8..4e3e8c8 100644 (file)
@@ -67,7 +67,7 @@ void ViewUpdateDispatcher::visibleContentRectUpdate(uint64_t pageID, const Visib
             iterator->value.visibleContentRectUpdateInfo = visibleContentRectUpdateInfo;
     }
     if (updateListWasEmpty) {
-        RunLoop::main().dispatch([protectedThis = Ref<ViewUpdateDispatcher>(*this)]() mutable {
+        RunLoop::main().dispatch([protectedThis = makeRef(*this)]() mutable {
             protectedThis->dispatchVisibleContentRectUpdate();
         });
     }