Title: [201594] trunk/Source
Revision
201594
Author
beid...@apple.com
Date
2016-06-01 22:47:12 -0700 (Wed, 01 Jun 2016)

Log Message

Get rid of StringCapture.
https://bugs.webkit.org/show_bug.cgi?id=158285

Reviewed by Chris Dumez.

Source/WebCore:

No new tests (Refactor, no behavior change).

* dom/Document.cpp:
(WebCore::Document::addConsoleMessage):
(WebCore::Document::addMessage):

* dom/ScriptExecutionContext.h:
(WebCore::ScriptExecutionContext::AddConsoleMessageTask::AddConsoleMessageTask):

* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::installContentFilterUnblockHandler):

* loader/WorkerThreadableLoader.cpp:
(WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge):

* platform/ios/WebVideoFullscreenControllerAVKit.mm:
(WebVideoFullscreenControllerContext::setExternalPlayback):

* workers/WorkerGlobalScope.cpp:
(WebCore::WorkerGlobalScope::addConsoleMessage):
(WebCore::WorkerGlobalScope::addMessage):

* workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerMessagingProxy::postExceptionToWorkerObject):
(WebCore::WorkerMessagingProxy::postConsoleMessageToWorkerObject):

Source/WTF:

* wtf/text/WTFString.h:
(WTF::StringCapture::StringCapture): Deleted.
(WTF::StringCapture::string): Deleted.
(WTF::StringCapture::releaseString): Deleted.
(WTF::StringCapture::operator=): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (201593 => 201594)


--- trunk/Source/WTF/ChangeLog	2016-06-02 05:39:52 UTC (rev 201593)
+++ trunk/Source/WTF/ChangeLog	2016-06-02 05:47:12 UTC (rev 201594)
@@ -1,3 +1,16 @@
+2016-06-01  Brady Eidson  <beid...@apple.com>
+
+        Get rid of StringCapture.
+        https://bugs.webkit.org/show_bug.cgi?id=158285
+
+        Reviewed by Chris Dumez.
+
+        * wtf/text/WTFString.h:
+        (WTF::StringCapture::StringCapture): Deleted.
+        (WTF::StringCapture::string): Deleted.
+        (WTF::StringCapture::releaseString): Deleted.
+        (WTF::StringCapture::operator=): Deleted.
+
 2016-06-01  Benjamin Poulain  <bpoul...@apple.com>
 
         [JSC] Some setters for components of Date do not timeClip() their result

Modified: trunk/Source/WTF/wtf/text/WTFString.h (201593 => 201594)


--- trunk/Source/WTF/wtf/text/WTFString.h	2016-06-02 05:39:52 UTC (rev 201593)
+++ trunk/Source/WTF/wtf/text/WTFString.h	2016-06-02 05:47:12 UTC (rev 201594)
@@ -690,25 +690,6 @@
     const char* m_characters;
 };
 
-// For thread-safe lambda capture:
-// StringCapture stringCapture(string);
-// auto lambdaThatRunsInOtherThread = [stringCapture] { String string = stringCapture.string(); ... }
-// FIXME: Remove when we can use C++14 initialized lambda capture: [string = string.isolatedCopy()].
-class StringCapture {
-public:
-    StringCapture() { }
-    StringCapture(const String& string) : m_string(string) { }
-    explicit StringCapture(String&& string) : m_string(string) { }
-    StringCapture(const StringCapture& other) : m_string(other.m_string.isolatedCopy()) { }
-    const String& string() const { return m_string; }
-    String releaseString() { return WTFMove(m_string); }
-
-    void operator=(const StringCapture& other) { m_string = other.m_string.isolatedCopy(); }
-
-private:
-    String m_string;
-};
-
 // Shared global empty string.
 WTF_EXPORT_STRING_API const String& emptyString();
 
@@ -758,7 +739,6 @@
 using WTF::isSpaceOrNewline;
 using WTF::reverseFind;
 using WTF::ASCIILiteral;
-using WTF::StringCapture;
 
 #include <wtf/text/AtomicString.h>
 

Modified: trunk/Source/WebCore/ChangeLog (201593 => 201594)


--- trunk/Source/WebCore/ChangeLog	2016-06-02 05:39:52 UTC (rev 201593)
+++ trunk/Source/WebCore/ChangeLog	2016-06-02 05:47:12 UTC (rev 201594)
@@ -1,3 +1,36 @@
+2016-06-01  Brady Eidson  <beid...@apple.com>
+
+        Get rid of StringCapture.
+        https://bugs.webkit.org/show_bug.cgi?id=158285
+
+        Reviewed by Chris Dumez.
+
+        No new tests (Refactor, no behavior change).
+
+        * dom/Document.cpp:
+        (WebCore::Document::addConsoleMessage):
+        (WebCore::Document::addMessage):
+        
+        * dom/ScriptExecutionContext.h:
+        (WebCore::ScriptExecutionContext::AddConsoleMessageTask::AddConsoleMessageTask):
+        
+        * loader/DocumentLoader.cpp:
+        (WebCore::DocumentLoader::installContentFilterUnblockHandler):
+        
+        * loader/WorkerThreadableLoader.cpp:
+        (WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge):
+        
+        * platform/ios/WebVideoFullscreenControllerAVKit.mm:
+        (WebVideoFullscreenControllerContext::setExternalPlayback):
+        
+        * workers/WorkerGlobalScope.cpp:
+        (WebCore::WorkerGlobalScope::addConsoleMessage):
+        (WebCore::WorkerGlobalScope::addMessage):
+        
+        * workers/WorkerMessagingProxy.cpp:
+        (WebCore::WorkerMessagingProxy::postExceptionToWorkerObject):
+        (WebCore::WorkerMessagingProxy::postConsoleMessageToWorkerObject):
+
 2016-05-31  Darin Adler  <da...@apple.com>
 
         Audit RenderObject casts and fix problems and style issues found

Modified: trunk/Source/WebCore/dom/Document.cpp (201593 => 201594)


--- trunk/Source/WebCore/dom/Document.cpp	2016-06-02 05:39:52 UTC (rev 201593)
+++ trunk/Source/WebCore/dom/Document.cpp	2016-06-02 05:47:12 UTC (rev 201594)
@@ -5333,7 +5333,7 @@
 void Document::addConsoleMessage(MessageSource source, MessageLevel level, const String& message, unsigned long requestIdentifier)
 {
     if (!isContextThread()) {
-        postTask(AddConsoleMessageTask(source, level, StringCapture(message)));
+        postTask(AddConsoleMessageTask(source, level, message));
         return;
     }
 
@@ -5344,7 +5344,7 @@
 void Document::addMessage(MessageSource source, MessageLevel level, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, RefPtr<Inspector::ScriptCallStack>&& callStack, JSC::ExecState* state, unsigned long requestIdentifier)
 {
     if (!isContextThread()) {
-        postTask(AddConsoleMessageTask(source, level, StringCapture(message)));
+        postTask(AddConsoleMessageTask(source, level, message));
         return;
     }
 

Modified: trunk/Source/WebCore/dom/ScriptExecutionContext.h (201593 => 201594)


--- trunk/Source/WebCore/dom/ScriptExecutionContext.h	2016-06-02 05:39:52 UTC (rev 201593)
+++ trunk/Source/WebCore/dom/ScriptExecutionContext.h	2016-06-02 05:47:12 UTC (rev 201594)
@@ -210,9 +210,9 @@
 protected:
     class AddConsoleMessageTask : public Task {
     public:
-        AddConsoleMessageTask(MessageSource source, MessageLevel level, const StringCapture& message)
-            : Task([source, level, message](ScriptExecutionContext& context) {
-                context.addConsoleMessage(source, level, message.string());
+        AddConsoleMessageTask(MessageSource source, MessageLevel level, const String& message)
+            : Task([source, level, message = message.isolatedCopy()](ScriptExecutionContext& context) {
+                context.addConsoleMessage(source, level, message);
             })
         {
         }

Modified: trunk/Source/WebCore/loader/DocumentLoader.cpp (201593 => 201594)


--- trunk/Source/WebCore/loader/DocumentLoader.cpp	2016-06-02 05:39:52 UTC (rev 201593)
+++ trunk/Source/WebCore/loader/DocumentLoader.cpp	2016-06-02 05:47:12 UTC (rev 201594)
@@ -1703,10 +1703,9 @@
     String unblockRequestDeniedScript { contentFilter.unblockRequestDeniedScript() };
     if (!unblockRequestDeniedScript.isEmpty() && frame) {
         static_assert(std::is_base_of<ThreadSafeRefCounted<Frame>, Frame>::value, "Frame must be ThreadSafeRefCounted.");
-        StringCapture capturedScript { unblockRequestDeniedScript };
-        unblockHandler.wrapWithDecisionHandler([frame, capturedScript](bool unblocked) {
+        unblockHandler.wrapWithDecisionHandler([frame = WTFMove(frame), script = unblockRequestDeniedScript.isolatedCopy()](bool unblocked) {
             if (!unblocked)
-                frame->script().executeScript(capturedScript.string());
+                frame->script().executeScript(script);
         });
     }
     frameLoader()->client().contentFilterDidBlockLoad(WTFMove(unblockHandler));

Modified: trunk/Source/WebCore/loader/WorkerThreadableLoader.cpp (201593 => 201594)


--- trunk/Source/WebCore/loader/WorkerThreadableLoader.cpp	2016-06-02 05:39:52 UTC (rev 201593)
+++ trunk/Source/WebCore/loader/WorkerThreadableLoader.cpp	2016-06-02 05:47:12 UTC (rev 201594)
@@ -90,28 +90,23 @@
     , m_loaderProxy(loaderProxy)
     , m_taskMode(taskMode.isolatedCopy())
 {
-    auto* requestData = request.copyData().release();
-    auto* optionsCopy = options.isolatedCopy().release();
-
     ASSERT(securityOrigin);
     ASSERT(contentSecurityPolicy);
-    auto* contentSecurityPolicyCopy = std::make_unique<ContentSecurityPolicy>(*securityOrigin).release();
+
+    auto contentSecurityPolicyCopy = std::make_unique<ContentSecurityPolicy>(*securityOrigin);
     contentSecurityPolicyCopy->copyStateFrom(contentSecurityPolicy);
 
-    StringCapture capturedOutgoingReferrer(outgoingReferrer);
-    m_loaderProxy.postTaskToLoader([this, requestData, optionsCopy, contentSecurityPolicyCopy, capturedOutgoingReferrer](ScriptExecutionContext& context) {
+    m_loaderProxy.postTaskToLoader([this, requestData = request.copyData(), options = options.isolatedCopy(), contentSecurityPolicyCopy = WTFMove(contentSecurityPolicyCopy), outgoingReferrer = outgoingReferrer.isolatedCopy()](ScriptExecutionContext& context) mutable {
         ASSERT(isMainThread());
         Document& document = downcast<Document>(context);
 
-        auto request = ResourceRequest::adopt(std::unique_ptr<CrossThreadResourceRequestData>(requestData));
-        request->setHTTPReferrer(capturedOutgoingReferrer.string());
+        auto request = ResourceRequest::adopt(WTFMove(requestData));
+        request->setHTTPReferrer(outgoingReferrer);
 
-        auto options = std::unique_ptr<ThreadableLoaderOptions>(optionsCopy);
-
         // FIXME: If the a site requests a local resource, then this will return a non-zero value but the sync path
         // will return a 0 value. Either this should return 0 or the other code path should do a callback with
         // a failure.
-        m_mainThreadLoader = DocumentThreadableLoader::create(document, *this, *request, *options, std::unique_ptr<ContentSecurityPolicy>(contentSecurityPolicyCopy));
+        m_mainThreadLoader = DocumentThreadableLoader::create(document, *this, *request, *options, WTFMove(contentSecurityPolicyCopy));
         ASSERT(m_mainThreadLoader || m_loadingFinished);
     });
 }

Modified: trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm (201593 => 201594)


--- trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm	2016-06-02 05:39:52 UTC (rev 201593)
+++ trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm	2016-06-02 05:47:12 UTC (rev 201594)
@@ -434,11 +434,9 @@
 void WebVideoFullscreenControllerContext::setExternalPlayback(bool enabled, ExternalPlaybackTargetType type, String localizedDeviceName)
 {
     ASSERT(WebThreadIsCurrent());
-    RefPtr<WebVideoFullscreenControllerContext> protectedThis(this);
-    StringCapture capturedLocalizedDeviceName(localizedDeviceName);
-    dispatch_async(dispatch_get_main_queue(), [protectedThis, this, enabled, type, capturedLocalizedDeviceName] {
+    callOnMainThread([protectedThis = Ref<WebVideoFullscreenControllerContext>(*this), this, enabled, type, localizedDeviceName = localizedDeviceName.isolatedCopy()] {
         if (m_interface)
-            m_interface->setExternalPlayback(enabled, type, capturedLocalizedDeviceName.string());
+            m_interface->setExternalPlayback(enabled, type, localizedDeviceName);
     });
 }
 

Modified: trunk/Source/WebCore/workers/WorkerGlobalScope.cpp (201593 => 201594)


--- trunk/Source/WebCore/workers/WorkerGlobalScope.cpp	2016-06-02 05:39:52 UTC (rev 201593)
+++ trunk/Source/WebCore/workers/WorkerGlobalScope.cpp	2016-06-02 05:47:12 UTC (rev 201594)
@@ -253,7 +253,7 @@
 void WorkerGlobalScope::addConsoleMessage(std::unique_ptr<Inspector::ConsoleMessage> message)
 {
     if (!isContextThread()) {
-        postTask(AddConsoleMessageTask(message->source(), message->level(), StringCapture(message->message())));
+        postTask(AddConsoleMessageTask(message->source(), message->level(), message->message()));
         return;
     }
 
@@ -264,7 +264,7 @@
 void WorkerGlobalScope::addConsoleMessage(MessageSource source, MessageLevel level, const String& message, unsigned long requestIdentifier)
 {
     if (!isContextThread()) {
-        postTask(AddConsoleMessageTask(source, level, StringCapture(message)));
+        postTask(AddConsoleMessageTask(source, level, message));
         return;
     }
 
@@ -275,7 +275,7 @@
 void WorkerGlobalScope::addMessage(MessageSource source, MessageLevel level, const String& message, const String& sourceURL, unsigned lineNumber, unsigned columnNumber, RefPtr<ScriptCallStack>&& callStack, JSC::ExecState* state, unsigned long requestIdentifier)
 {
     if (!isContextThread()) {
-        postTask(AddConsoleMessageTask(source, level, StringCapture(message)));
+        postTask(AddConsoleMessageTask(source, level, message));
         return;
     }
 

Modified: trunk/Source/WebCore/workers/WorkerMessagingProxy.cpp (201593 => 201594)


--- trunk/Source/WebCore/workers/WorkerMessagingProxy.cpp	2016-06-02 05:39:52 UTC (rev 201593)
+++ trunk/Source/WebCore/workers/WorkerMessagingProxy.cpp	2016-06-02 05:47:12 UTC (rev 201594)
@@ -141,9 +141,7 @@
 
 void WorkerMessagingProxy::postExceptionToWorkerObject(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL)
 {
-    StringCapture capturedErrorMessage(errorMessage);
-    StringCapture capturedSourceURL(sourceURL);
-    m_scriptExecutionContext->postTask([this, capturedErrorMessage, capturedSourceURL, lineNumber, columnNumber] (ScriptExecutionContext& context) {
+    m_scriptExecutionContext->postTask([this, errorMessage = errorMessage.isolatedCopy(), sourceURL = sourceURL.isolatedCopy(), lineNumber, columnNumber] (ScriptExecutionContext& context) {
         Worker* workerObject = this->workerObject();
         if (!workerObject)
             return;
@@ -151,20 +149,18 @@
         // We don't bother checking the askedToTerminate() flag here, because exceptions should *always* be reported even if the thread is terminated.
         // This is intentionally different than the behavior in MessageWorkerTask, because terminated workers no longer deliver messages (section 4.6 of the WebWorker spec), but they do report exceptions.
 
-        bool errorHandled = !workerObject->dispatchEvent(ErrorEvent::create(capturedErrorMessage.string(), capturedSourceURL.string(), lineNumber, columnNumber));
+        bool errorHandled = !workerObject->dispatchEvent(ErrorEvent::create(errorMessage, sourceURL, lineNumber, columnNumber));
         if (!errorHandled)
-            context.reportException(capturedErrorMessage.string(), lineNumber, columnNumber, capturedSourceURL.string(), 0);
+            context.reportException(errorMessage, lineNumber, columnNumber, sourceURL, 0);
     });
 }
 
 void WorkerMessagingProxy::postConsoleMessageToWorkerObject(MessageSource source, MessageLevel level, const String& message, int lineNumber, int columnNumber, const String& sourceURL)
 {
-    StringCapture capturedMessage(message);
-    StringCapture capturedSourceURL(sourceURL);
-    m_scriptExecutionContext->postTask([this, source, level, capturedMessage, capturedSourceURL, lineNumber, columnNumber] (ScriptExecutionContext& context) {
+    m_scriptExecutionContext->postTask([this, source, level, message = message.isolatedCopy(), sourceURL = sourceURL.isolatedCopy(), lineNumber, columnNumber] (ScriptExecutionContext& context) {
         if (askedToTerminate())
             return;
-        context.addConsoleMessage(source, level, capturedMessage.string(), capturedSourceURL.string(), lineNumber, columnNumber);
+        context.addConsoleMessage(source, level, message, sourceURL, lineNumber, columnNumber);
     });
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to