Changeset 202614 in webkit


Ignore:
Timestamp:
Jun 28, 2016 11:25:59 PM (8 years ago)
Author:
commit-queue@webkit.org
Message:

Remove ThreadableLoaderOptions origin
https://bugs.webkit.org/show_bug.cgi?id=159221

Patch by Youenn Fablet <youennf@gmail.com> on 2016-06-28
Reviewed by Sam Weinig.

No change of behavior.

  • loader/DocumentThreadableLoader.cpp:

(WebCore::DocumentThreadableLoader::loadResourceSynchronously): Adding origing parameter.
(WebCore::DocumentThreadableLoader::create): Ditto.
(WebCore::DocumentThreadableLoader::DocumentThreadableLoader): Ditto.
(WebCore::DocumentThreadableLoader::redirectReceived): Setting m_origin.
(WebCore::DocumentThreadableLoader::securityOrigin): Checking m_origin.

  • loader/DocumentThreadableLoader.h: Adding m_origin member.
  • loader/ThreadableLoader.cpp:

(WebCore::ThreadableLoaderOptions::ThreadableLoaderOptions): Removing origin.
(WebCore::ThreadableLoaderOption::isolatedCopy): Deleted.

  • loader/ThreadableLoader.h: Removing origin parameter and isolatedCopy function.
  • loader/WorkerThreadableLoader.cpp:

(WebCore::LoaderTaskOptions::LoaderTaskOptions): Structure to pass loader task options from one thread to another.
(WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge):

  • page/EventSource.cpp:

(WebCore::EventSource::connect): Removing setting of the origin.

  • workers/WorkerScriptLoader.cpp:

(WebCore::WorkerScriptLoader::loadSynchronously): Ditto.
(WebCore::WorkerScriptLoader::loadAsynchronously): Ditto.

  • xml/XMLHttpRequest.cpp:

(WebCore::XMLHttpRequest::createRequest): Ditto.

Location:
trunk/Source/WebCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r202611 r202614  
     12016-06-28  Youenn Fablet  <youennf@gmail.com>
     2
     3        Remove ThreadableLoaderOptions origin
     4        https://bugs.webkit.org/show_bug.cgi?id=159221
     5
     6        Reviewed by Sam Weinig.
     7
     8        No change of behavior.
     9
     10        * loader/DocumentThreadableLoader.cpp:
     11        (WebCore::DocumentThreadableLoader::loadResourceSynchronously): Adding origing parameter.
     12        (WebCore::DocumentThreadableLoader::create): Ditto.
     13        (WebCore::DocumentThreadableLoader::DocumentThreadableLoader): Ditto.
     14        (WebCore::DocumentThreadableLoader::redirectReceived): Setting m_origin.
     15        (WebCore::DocumentThreadableLoader::securityOrigin): Checking m_origin.
     16        * loader/DocumentThreadableLoader.h: Adding m_origin member.
     17        * loader/ThreadableLoader.cpp:
     18        (WebCore::ThreadableLoaderOptions::ThreadableLoaderOptions): Removing origin.
     19        (WebCore::ThreadableLoaderOption::isolatedCopy): Deleted.
     20        * loader/ThreadableLoader.h: Removing origin parameter and isolatedCopy function.
     21        * loader/WorkerThreadableLoader.cpp:
     22        (WebCore::LoaderTaskOptions::LoaderTaskOptions): Structure to pass loader task options from one thread to another.
     23        (WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge):
     24        * page/EventSource.cpp:
     25        (WebCore::EventSource::connect): Removing setting of the origin.
     26        * workers/WorkerScriptLoader.cpp:
     27        (WebCore::WorkerScriptLoader::loadSynchronously): Ditto.
     28        (WebCore::WorkerScriptLoader::loadAsynchronously): Ditto.
     29        * xml/XMLHttpRequest.cpp:
     30        (WebCore::XMLHttpRequest::createRequest): Ditto.
     31
    1322016-06-28  Commit Queue  <commit-queue@webkit.org>
    233
  • trunk/Source/WebCore/loader/DocumentThreadableLoader.cpp

    r202542 r202614  
    5757namespace WebCore {
    5858
    59 void DocumentThreadableLoader::loadResourceSynchronously(Document& document, const ResourceRequest& request, ThreadableLoaderClient& client, const ThreadableLoaderOptions& options, std::unique_ptr<ContentSecurityPolicy>&& contentSecurityPolicy)
     59void DocumentThreadableLoader::loadResourceSynchronously(Document& document, const ResourceRequest& request, ThreadableLoaderClient& client, const ThreadableLoaderOptions& options, RefPtr<SecurityOrigin>&& origin, std::unique_ptr<ContentSecurityPolicy>&& contentSecurityPolicy)
    6060{
    6161    // The loader will be deleted as soon as this function exits.
    62     RefPtr<DocumentThreadableLoader> loader = adoptRef(new DocumentThreadableLoader(document, client, LoadSynchronously, request, options, WTFMove(contentSecurityPolicy)));
     62    RefPtr<DocumentThreadableLoader> loader = adoptRef(new DocumentThreadableLoader(document, client, LoadSynchronously, request, options, WTFMove(origin), WTFMove(contentSecurityPolicy)));
    6363    ASSERT(loader->hasOneRef());
    6464}
     
    6666void DocumentThreadableLoader::loadResourceSynchronously(Document& document, const ResourceRequest& request, ThreadableLoaderClient& client, const ThreadableLoaderOptions& options)
    6767{
    68     loadResourceSynchronously(document, request, client, options, nullptr);
    69 }
    70 
    71 RefPtr<DocumentThreadableLoader> DocumentThreadableLoader::create(Document& document, ThreadableLoaderClient& client, const ResourceRequest& request, const ThreadableLoaderOptions& options, std::unique_ptr<ContentSecurityPolicy>&& contentSecurityPolicy)
    72 {
    73     RefPtr<DocumentThreadableLoader> loader = adoptRef(new DocumentThreadableLoader(document, client, LoadAsynchronously, request, options, WTFMove(contentSecurityPolicy)));
     68    loadResourceSynchronously(document, request, client, options, nullptr, nullptr);
     69}
     70
     71RefPtr<DocumentThreadableLoader> DocumentThreadableLoader::create(Document& document, ThreadableLoaderClient& client, const ResourceRequest& request, const ThreadableLoaderOptions& options, RefPtr<SecurityOrigin>&& origin, std::unique_ptr<ContentSecurityPolicy>&& contentSecurityPolicy)
     72{
     73    RefPtr<DocumentThreadableLoader> loader = adoptRef(new DocumentThreadableLoader(document, client, LoadAsynchronously, request, options, WTFMove(origin), WTFMove(contentSecurityPolicy)));
    7474    if (!loader->isLoading())
    7575        loader = nullptr;
     
    7979RefPtr<DocumentThreadableLoader> DocumentThreadableLoader::create(Document& document, ThreadableLoaderClient& client, const ResourceRequest& request, const ThreadableLoaderOptions& options)
    8080{
    81     return create(document, client, request, options, nullptr);
    82 }
    83 
    84 DocumentThreadableLoader::DocumentThreadableLoader(Document& document, ThreadableLoaderClient& client, BlockingBehavior blockingBehavior, const ResourceRequest& request, const ThreadableLoaderOptions& options, std::unique_ptr<ContentSecurityPolicy>&& contentSecurityPolicy)
     81    return create(document, client, request, options, nullptr, nullptr);
     82}
     83
     84DocumentThreadableLoader::DocumentThreadableLoader(Document& document, ThreadableLoaderClient& client, BlockingBehavior blockingBehavior, const ResourceRequest& request, const ThreadableLoaderOptions& options, RefPtr<SecurityOrigin>&& origin, std::unique_ptr<ContentSecurityPolicy>&& contentSecurityPolicy)
    8585    : m_client(&client)
    8686    , m_document(document)
    8787    , m_options(options)
     88    , m_origin(WTFMove(origin))
    8889    , m_sameOriginRequest(securityOrigin()->canRequest(request.url()))
    8990    , m_simpleRequest(true)
     
    240241            // should be the original URL origin.)
    241242            if (!m_sameOriginRequest && !originalOrigin->isSameSchemeHostPort(requestOrigin.get()))
    242                 m_options.securityOrigin = SecurityOrigin::createUnique();
     243                m_origin = SecurityOrigin::createUnique();
    243244            // Force any subsequent request to use these checks.
    244245            m_sameOriginRequest = false;
     
    445446SecurityOrigin* DocumentThreadableLoader::securityOrigin() const
    446447{
    447     return m_options.securityOrigin ? m_options.securityOrigin.get() : m_document.securityOrigin();
     448    return m_origin ? m_origin.get() : m_document.securityOrigin();
    448449}
    449450
  • trunk/Source/WebCore/loader/DocumentThreadableLoader.h

    r201924 r202614  
    3333
    3434#include "CrossOriginPreflightChecker.h"
     35#include "SecurityOrigin.h"
    3536#include "ThreadableLoader.h"
    3637
     
    3940    class ContentSecurityPolicy;
    4041    class Document;
    41     class SecurityOrigin;
    4242    class ThreadableLoaderClient;
    4343
     
    4545        WTF_MAKE_FAST_ALLOCATED;
    4646    public:
    47         static void loadResourceSynchronously(Document&, const ResourceRequest&, ThreadableLoaderClient&, const ThreadableLoaderOptions&, std::unique_ptr<ContentSecurityPolicy>&&);
     47        static void loadResourceSynchronously(Document&, const ResourceRequest&, ThreadableLoaderClient&, const ThreadableLoaderOptions&, RefPtr<SecurityOrigin>&&, std::unique_ptr<ContentSecurityPolicy>&&);
    4848        static void loadResourceSynchronously(Document&, const ResourceRequest&, ThreadableLoaderClient&, const ThreadableLoaderOptions&);
    4949
    50         static RefPtr<DocumentThreadableLoader> create(Document&, ThreadableLoaderClient&, const ResourceRequest&, const ThreadableLoaderOptions&, std::unique_ptr<ContentSecurityPolicy>&&);
     50        static RefPtr<DocumentThreadableLoader> create(Document&, ThreadableLoaderClient&, const ResourceRequest&, const ThreadableLoaderOptions&, RefPtr<SecurityOrigin>&&, std::unique_ptr<ContentSecurityPolicy>&&);
    5151        static RefPtr<DocumentThreadableLoader> create(Document&, ThreadableLoaderClient&, const ResourceRequest&, const ThreadableLoaderOptions&);
    5252
     
    7171        };
    7272
    73         DocumentThreadableLoader(Document&, ThreadableLoaderClient&, BlockingBehavior, const ResourceRequest&, const ThreadableLoaderOptions&, std::unique_ptr<ContentSecurityPolicy>&&);
     73        DocumentThreadableLoader(Document&, ThreadableLoaderClient&, BlockingBehavior, const ResourceRequest&, const ThreadableLoaderOptions&, RefPtr<SecurityOrigin>&&, std::unique_ptr<ContentSecurityPolicy>&&);
    7474
    7575        void clearResource();
     
    109109        Document& m_document;
    110110        ThreadableLoaderOptions m_options;
     111        RefPtr<SecurityOrigin> m_origin;
    111112        bool m_sameOriginRequest;
    112113        bool m_simpleRequest;
  • trunk/Source/WebCore/loader/ThreadableLoader.cpp

    r201324 r202614  
    5050}
    5151
    52 ThreadableLoaderOptions::ThreadableLoaderOptions(const ResourceLoaderOptions& baseOptions, PreflightPolicy preflightPolicy, CrossOriginRequestPolicy crossOriginRequestPolicy, ContentSecurityPolicyEnforcement contentSecurityPolicyEnforcement, RefPtr<SecurityOrigin>&& securityOrigin, String&& initiator)
     52ThreadableLoaderOptions::ThreadableLoaderOptions(const ResourceLoaderOptions& baseOptions, PreflightPolicy preflightPolicy, CrossOriginRequestPolicy crossOriginRequestPolicy, ContentSecurityPolicyEnforcement contentSecurityPolicyEnforcement, String&& initiator)
    5353    : ResourceLoaderOptions(baseOptions)
    5454    , preflightPolicy(preflightPolicy)
    5555    , crossOriginRequestPolicy(crossOriginRequestPolicy)
    5656    , contentSecurityPolicyEnforcement(contentSecurityPolicyEnforcement)
    57     , securityOrigin(WTFMove(securityOrigin))
    5857    , initiator(WTFMove(initiator))
    5958{
    60 }
    61 
    62 std::unique_ptr<ThreadableLoaderOptions> ThreadableLoaderOptions::isolatedCopy() const
    63 {
    64     RefPtr<SecurityOrigin> securityOriginCopy;
    65     if (securityOrigin)
    66         securityOriginCopy = securityOrigin->isolatedCopy();
    67     return std::make_unique<ThreadableLoaderOptions>(*this, preflightPolicy, crossOriginRequestPolicy, contentSecurityPolicyEnforcement, WTFMove(securityOriginCopy), initiator.isolatedCopy());
    6859}
    6960
  • trunk/Source/WebCore/loader/ThreadableLoader.h

    r201324 r202614  
    6868    struct ThreadableLoaderOptions : ResourceLoaderOptions {
    6969        ThreadableLoaderOptions();
    70         ThreadableLoaderOptions(const ResourceLoaderOptions&, PreflightPolicy, CrossOriginRequestPolicy, ContentSecurityPolicyEnforcement, RefPtr<SecurityOrigin>&&, String&& initiator);
     70        ThreadableLoaderOptions(const ResourceLoaderOptions&, PreflightPolicy, CrossOriginRequestPolicy, ContentSecurityPolicyEnforcement, String&& initiator);
    7171        ~ThreadableLoaderOptions();
    72 
    73         std::unique_ptr<ThreadableLoaderOptions> isolatedCopy() const;
    7472
    7573        PreflightPolicy preflightPolicy { ConsiderPreflight };
  • trunk/Source/WebCore/loader/WorkerThreadableLoader.cpp

    r202542 r202614  
    8484}
    8585
     86struct LoaderTaskOptions {
     87    LoaderTaskOptions(const ThreadableLoaderOptions&, const String&, const SecurityOrigin&);
     88    ThreadableLoaderOptions options;
     89    String referrer;
     90    RefPtr<SecurityOrigin> origin;
     91};
     92
     93LoaderTaskOptions::LoaderTaskOptions(const ThreadableLoaderOptions& options, const String& referrer, const SecurityOrigin& origin)
     94    : options(options, options.preflightPolicy, options.crossOriginRequestPolicy, options.contentSecurityPolicyEnforcement, options.initiator.isolatedCopy())
     95    , referrer(referrer.isolatedCopy())
     96    , origin(origin.isolatedCopy())
     97{
     98}
     99
    86100WorkerThreadableLoader::MainThreadBridge::MainThreadBridge(ThreadableLoaderClientWrapper& workerClientWrapper, WorkerLoaderProxy& loaderProxy, const String& taskMode,
    87101    const ResourceRequest& request, const ThreadableLoaderOptions& options, const String& outgoingReferrer,
     
    97111    contentSecurityPolicyCopy->copyStateFrom(contentSecurityPolicy);
    98112
    99     m_loaderProxy.postTaskToLoader([this, request = request.isolatedCopy(), options = options.isolatedCopy(), contentSecurityPolicyCopy = WTFMove(contentSecurityPolicyCopy), outgoingReferrer = outgoingReferrer.isolatedCopy()](ScriptExecutionContext& context) mutable {
     113    auto optionsCopy = std::make_unique<LoaderTaskOptions>(options, outgoingReferrer, *securityOrigin);
     114
     115    m_loaderProxy.postTaskToLoader([this, request = request.isolatedCopy(), options = WTFMove(optionsCopy), contentSecurityPolicyCopy = WTFMove(contentSecurityPolicyCopy)](ScriptExecutionContext& context) mutable {
    100116        ASSERT(isMainThread());
    101117        Document& document = downcast<Document>(context);
    102118
    103         request.setHTTPReferrer(outgoingReferrer);
    104 
    105         // FIXME: If the a site requests a local resource, then this will return a non-zero value but the sync path
    106         // will return a 0 value. Either this should return 0 or the other code path should do a callback with
    107         // a failure.
    108         m_mainThreadLoader = DocumentThreadableLoader::create(document, *this, request, *options, WTFMove(contentSecurityPolicyCopy));
     119        request.setHTTPReferrer(options->referrer);
     120
     121        // FIXME: If the site requests a local resource, then this will return a non-zero value but the sync path will return a 0 value.
     122        // Either this should return 0 or the other code path should call a failure callback.
     123        m_mainThreadLoader = DocumentThreadableLoader::create(document, *this, request, options->options, WTFMove(options->origin), WTFMove(contentSecurityPolicyCopy));
    109124        ASSERT(m_mainThreadLoader || m_loadingFinished);
    110125    });
  • trunk/Source/WebCore/page/EventSource.cpp

    r202542 r202614  
    114114    options.crossOriginRequestPolicy = UseAccessControl;
    115115    options.setDataBufferingPolicy(DoNotBufferData);
    116     options.securityOrigin = &origin;
    117116    options.contentSecurityPolicyEnforcement = scriptExecutionContext()->shouldBypassMainWorldContentSecurityPolicy() ? ContentSecurityPolicyEnforcement::DoNotEnforce : ContentSecurityPolicyEnforcement::EnforceConnectSrcDirective;
    118117
  • trunk/Source/WebCore/workers/WorkerScriptLoader.cpp

    r202480 r202614  
    6969    options.crossOriginRequestPolicy = crossOriginRequestPolicy;
    7070    options.setSendLoadCallbacks(SendCallbacks);
    71     options.securityOrigin = scriptExecutionContext->securityOrigin();
    7271    options.contentSecurityPolicyEnforcement = contentSecurityPolicyEnforcement;
    7372
    7473    WorkerThreadableLoader::loadResourceSynchronously(downcast<WorkerGlobalScope>(scriptExecutionContext), *request, *this, options);
    7574}
    76    
     75
    7776void WorkerScriptLoader::loadAsynchronously(ScriptExecutionContext* scriptExecutionContext, const URL& url, CrossOriginRequestPolicy crossOriginRequestPolicy, ContentSecurityPolicyEnforcement contentSecurityPolicyEnforcement, WorkerScriptLoaderClient* client)
    7877{
     
    8988    options.crossOriginRequestPolicy = crossOriginRequestPolicy;
    9089    options.setSendLoadCallbacks(SendCallbacks);
    91     options.securityOrigin = scriptExecutionContext->securityOrigin();
    9290    options.contentSecurityPolicyEnforcement = contentSecurityPolicyEnforcement;
    9391
  • trunk/Source/WebCore/xml/XMLHttpRequest.cpp

    r202480 r202614  
    716716    options.setCredentialRequest(m_includeCredentials ? ClientRequestedCredentials : ClientDidNotRequestCredentials);
    717717    options.crossOriginRequestPolicy = UseAccessControl;
    718     options.securityOrigin = securityOrigin();
    719718    options.contentSecurityPolicyEnforcement = scriptExecutionContext()->shouldBypassMainWorldContentSecurityPolicy() ? ContentSecurityPolicyEnforcement::DoNotEnforce : ContentSecurityPolicyEnforcement::EnforceConnectSrcDirective;
    720719    options.initiator = cachedResourceRequestInitiators().xmlhttprequest;
Note: See TracChangeset for help on using the changeset viewer.