⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 201594 in webkit


Ignore:
Timestamp:
Jun 1, 2016, 10:47:12 PM (10 years ago)
Author:
beidson@apple.com
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.

Location:
trunk/Source
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r201586 r201594  
     12016-06-01  Brady Eidson  <beidson@apple.com>
     2
     3        Get rid of StringCapture.
     4        https://bugs.webkit.org/show_bug.cgi?id=158285
     5
     6        Reviewed by Chris Dumez.
     7
     8        * wtf/text/WTFString.h:
     9        (WTF::StringCapture::StringCapture): Deleted.
     10        (WTF::StringCapture::string): Deleted.
     11        (WTF::StringCapture::releaseString): Deleted.
     12        (WTF::StringCapture::operator=): Deleted.
     13
    1142016-06-01  Benjamin Poulain  <bpoulain@apple.com>
    215
  • trunk/Source/WTF/wtf/text/WTFString.h

    r200626 r201594  
    689689private:
    690690    const char* m_characters;
    691 };
    692 
    693 // For thread-safe lambda capture:
    694 // StringCapture stringCapture(string);
    695 // auto lambdaThatRunsInOtherThread = [stringCapture] { String string = stringCapture.string(); ... }
    696 // FIXME: Remove when we can use C++14 initialized lambda capture: [string = string.isolatedCopy()].
    697 class StringCapture {
    698 public:
    699     StringCapture() { }
    700     StringCapture(const String& string) : m_string(string) { }
    701     explicit StringCapture(String&& string) : m_string(string) { }
    702     StringCapture(const StringCapture& other) : m_string(other.m_string.isolatedCopy()) { }
    703     const String& string() const { return m_string; }
    704     String releaseString() { return WTFMove(m_string); }
    705 
    706     void operator=(const StringCapture& other) { m_string = other.m_string.isolatedCopy(); }
    707 
    708 private:
    709     String m_string;
    710691};
    711692
     
    759740using WTF::reverseFind;
    760741using WTF::ASCIILiteral;
    761 using WTF::StringCapture;
    762742
    763743#include <wtf/text/AtomicString.h>
  • trunk/Source/WebCore/ChangeLog

    r201588 r201594  
     12016-06-01  Brady Eidson  <beidson@apple.com>
     2
     3        Get rid of StringCapture.
     4        https://bugs.webkit.org/show_bug.cgi?id=158285
     5
     6        Reviewed by Chris Dumez.
     7
     8        No new tests (Refactor, no behavior change).
     9
     10        * dom/Document.cpp:
     11        (WebCore::Document::addConsoleMessage):
     12        (WebCore::Document::addMessage):
     13       
     14        * dom/ScriptExecutionContext.h:
     15        (WebCore::ScriptExecutionContext::AddConsoleMessageTask::AddConsoleMessageTask):
     16       
     17        * loader/DocumentLoader.cpp:
     18        (WebCore::DocumentLoader::installContentFilterUnblockHandler):
     19       
     20        * loader/WorkerThreadableLoader.cpp:
     21        (WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge):
     22       
     23        * platform/ios/WebVideoFullscreenControllerAVKit.mm:
     24        (WebVideoFullscreenControllerContext::setExternalPlayback):
     25       
     26        * workers/WorkerGlobalScope.cpp:
     27        (WebCore::WorkerGlobalScope::addConsoleMessage):
     28        (WebCore::WorkerGlobalScope::addMessage):
     29       
     30        * workers/WorkerMessagingProxy.cpp:
     31        (WebCore::WorkerMessagingProxy::postExceptionToWorkerObject):
     32        (WebCore::WorkerMessagingProxy::postConsoleMessageToWorkerObject):
     33
    1342016-05-31  Darin Adler  <darin@apple.com>
    235
  • trunk/Source/WebCore/dom/Document.cpp

    r201534 r201594  
    53345334{
    53355335    if (!isContextThread()) {
    5336         postTask(AddConsoleMessageTask(source, level, StringCapture(message)));
     5336        postTask(AddConsoleMessageTask(source, level, message));
    53375337        return;
    53385338    }
     
    53455345{
    53465346    if (!isContextThread()) {
    5347         postTask(AddConsoleMessageTask(source, level, StringCapture(message)));
     5347        postTask(AddConsoleMessageTask(source, level, message));
    53485348        return;
    53495349    }
  • trunk/Source/WebCore/dom/ScriptExecutionContext.h

    r201518 r201594  
    211211    class AddConsoleMessageTask : public Task {
    212212    public:
    213         AddConsoleMessageTask(MessageSource source, MessageLevel level, const StringCapture& message)
    214             : Task([source, level, message](ScriptExecutionContext& context) {
    215                 context.addConsoleMessage(source, level, message.string());
     213        AddConsoleMessageTask(MessageSource source, MessageLevel level, const String& message)
     214            : Task([source, level, message = message.isolatedCopy()](ScriptExecutionContext& context) {
     215                context.addConsoleMessage(source, level, message);
    216216            })
    217217        {
  • trunk/Source/WebCore/loader/DocumentLoader.cpp

    r201354 r201594  
    17041704    if (!unblockRequestDeniedScript.isEmpty() && frame) {
    17051705        static_assert(std::is_base_of<ThreadSafeRefCounted<Frame>, Frame>::value, "Frame must be ThreadSafeRefCounted.");
    1706         StringCapture capturedScript { unblockRequestDeniedScript };
    1707         unblockHandler.wrapWithDecisionHandler([frame, capturedScript](bool unblocked) {
     1706        unblockHandler.wrapWithDecisionHandler([frame = WTFMove(frame), script = unblockRequestDeniedScript.isolatedCopy()](bool unblocked) {
    17081707            if (!unblocked)
    1709                 frame->script().executeScript(capturedScript.string());
     1708                frame->script().executeScript(script);
    17101709        });
    17111710    }
  • trunk/Source/WebCore/loader/WorkerThreadableLoader.cpp

    r201354 r201594  
    9191    , m_taskMode(taskMode.isolatedCopy())
    9292{
    93     auto* requestData = request.copyData().release();
    94     auto* optionsCopy = options.isolatedCopy().release();
    95 
    9693    ASSERT(securityOrigin);
    9794    ASSERT(contentSecurityPolicy);
    98     auto* contentSecurityPolicyCopy = std::make_unique<ContentSecurityPolicy>(*securityOrigin).release();
     95
     96    auto contentSecurityPolicyCopy = std::make_unique<ContentSecurityPolicy>(*securityOrigin);
    9997    contentSecurityPolicyCopy->copyStateFrom(contentSecurityPolicy);
    10098
    101     StringCapture capturedOutgoingReferrer(outgoingReferrer);
    102     m_loaderProxy.postTaskToLoader([this, requestData, optionsCopy, contentSecurityPolicyCopy, capturedOutgoingReferrer](ScriptExecutionContext& context) {
     99    m_loaderProxy.postTaskToLoader([this, requestData = request.copyData(), options = options.isolatedCopy(), contentSecurityPolicyCopy = WTFMove(contentSecurityPolicyCopy), outgoingReferrer = outgoingReferrer.isolatedCopy()](ScriptExecutionContext& context) mutable {
    103100        ASSERT(isMainThread());
    104101        Document& document = downcast<Document>(context);
    105102
    106         auto request = ResourceRequest::adopt(std::unique_ptr<CrossThreadResourceRequestData>(requestData));
    107         request->setHTTPReferrer(capturedOutgoingReferrer.string());
    108 
    109         auto options = std::unique_ptr<ThreadableLoaderOptions>(optionsCopy);
     103        auto request = ResourceRequest::adopt(WTFMove(requestData));
     104        request->setHTTPReferrer(outgoingReferrer);
    110105
    111106        // FIXME: If the a site requests a local resource, then this will return a non-zero value but the sync path
    112107        // will return a 0 value. Either this should return 0 or the other code path should do a callback with
    113108        // a failure.
    114         m_mainThreadLoader = DocumentThreadableLoader::create(document, *this, *request, *options, std::unique_ptr<ContentSecurityPolicy>(contentSecurityPolicyCopy));
     109        m_mainThreadLoader = DocumentThreadableLoader::create(document, *this, *request, *options, WTFMove(contentSecurityPolicyCopy));
    115110        ASSERT(m_mainThreadLoader || m_loadingFinished);
    116111    });
  • trunk/Source/WebCore/platform/ios/WebVideoFullscreenControllerAVKit.mm

    r201588 r201594  
    435435{
    436436    ASSERT(WebThreadIsCurrent());
    437     RefPtr<WebVideoFullscreenControllerContext> protectedThis(this);
    438     StringCapture capturedLocalizedDeviceName(localizedDeviceName);
    439     dispatch_async(dispatch_get_main_queue(), [protectedThis, this, enabled, type, capturedLocalizedDeviceName] {
    440         if (m_interface)
    441             m_interface->setExternalPlayback(enabled, type, capturedLocalizedDeviceName.string());
     437    callOnMainThread([protectedThis = Ref<WebVideoFullscreenControllerContext>(*this), this, enabled, type, localizedDeviceName = localizedDeviceName.isolatedCopy()] {
     438        if (m_interface)
     439            m_interface->setExternalPlayback(enabled, type, localizedDeviceName);
    442440    });
    443441}
  • trunk/Source/WebCore/workers/WorkerGlobalScope.cpp

    r201496 r201594  
    254254{
    255255    if (!isContextThread()) {
    256         postTask(AddConsoleMessageTask(message->source(), message->level(), StringCapture(message->message())));
     256        postTask(AddConsoleMessageTask(message->source(), message->level(), message->message()));
    257257        return;
    258258    }
     
    265265{
    266266    if (!isContextThread()) {
    267         postTask(AddConsoleMessageTask(source, level, StringCapture(message)));
     267        postTask(AddConsoleMessageTask(source, level, message));
    268268        return;
    269269    }
     
    276276{
    277277    if (!isContextThread()) {
    278         postTask(AddConsoleMessageTask(source, level, StringCapture(message)));
     278        postTask(AddConsoleMessageTask(source, level, message));
    279279        return;
    280280    }
  • trunk/Source/WebCore/workers/WorkerMessagingProxy.cpp

    r201354 r201594  
    142142void WorkerMessagingProxy::postExceptionToWorkerObject(const String& errorMessage, int lineNumber, int columnNumber, const String& sourceURL)
    143143{
    144     StringCapture capturedErrorMessage(errorMessage);
    145     StringCapture capturedSourceURL(sourceURL);
    146     m_scriptExecutionContext->postTask([this, capturedErrorMessage, capturedSourceURL, lineNumber, columnNumber] (ScriptExecutionContext& context) {
     144    m_scriptExecutionContext->postTask([this, errorMessage = errorMessage.isolatedCopy(), sourceURL = sourceURL.isolatedCopy(), lineNumber, columnNumber] (ScriptExecutionContext& context) {
    147145        Worker* workerObject = this->workerObject();
    148146        if (!workerObject)
     
    152150        // 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.
    153151
    154         bool errorHandled = !workerObject->dispatchEvent(ErrorEvent::create(capturedErrorMessage.string(), capturedSourceURL.string(), lineNumber, columnNumber));
     152        bool errorHandled = !workerObject->dispatchEvent(ErrorEvent::create(errorMessage, sourceURL, lineNumber, columnNumber));
    155153        if (!errorHandled)
    156             context.reportException(capturedErrorMessage.string(), lineNumber, columnNumber, capturedSourceURL.string(), 0);
     154            context.reportException(errorMessage, lineNumber, columnNumber, sourceURL, 0);
    157155    });
    158156}
     
    160158void WorkerMessagingProxy::postConsoleMessageToWorkerObject(MessageSource source, MessageLevel level, const String& message, int lineNumber, int columnNumber, const String& sourceURL)
    161159{
    162     StringCapture capturedMessage(message);
    163     StringCapture capturedSourceURL(sourceURL);
    164     m_scriptExecutionContext->postTask([this, source, level, capturedMessage, capturedSourceURL, lineNumber, columnNumber] (ScriptExecutionContext& context) {
     160    m_scriptExecutionContext->postTask([this, source, level, message = message.isolatedCopy(), sourceURL = sourceURL.isolatedCopy(), lineNumber, columnNumber] (ScriptExecutionContext& context) {
    165161        if (askedToTerminate())
    166162            return;
    167         context.addConsoleMessage(source, level, capturedMessage.string(), capturedSourceURL.string(), lineNumber, columnNumber);
     163        context.addConsoleMessage(source, level, message, sourceURL, lineNumber, columnNumber);
    168164    });
    169165}
Note: See TracChangeset for help on using the changeset viewer.