Title: [206122] trunk/Source/WebCore
Revision
206122
Author
dba...@webkit.org
Date
2016-09-19 15:33:56 -0700 (Mon, 19 Sep 2016)

Log Message

Cleanup: Remove an extraneous copy of SecurityOrigin
https://bugs.webkit.org/show_bug.cgi?id=162118

Reviewed by Youenn Fablet.

Share one isolated copy of the SecurityOrigin between the ContentSecurityPolicy and
LoaderTaskOptions objects instead of creating two isolated copies of the SecurityOrigin.
This is safe because both ContentSecurityPolicy and LoaderTaskOptions are instantiated
in WorkerThreadableLoader::MainThreadBridge for use on the main thread only.

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

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (206121 => 206122)


--- trunk/Source/WebCore/ChangeLog	2016-09-19 22:12:08 UTC (rev 206121)
+++ trunk/Source/WebCore/ChangeLog	2016-09-19 22:33:56 UTC (rev 206122)
@@ -1,3 +1,19 @@
+2016-09-19  Daniel Bates  <daba...@apple.com>
+
+        Cleanup: Remove an extraneous copy of SecurityOrigin
+        https://bugs.webkit.org/show_bug.cgi?id=162118
+
+        Reviewed by Youenn Fablet.
+
+        Share one isolated copy of the SecurityOrigin between the ContentSecurityPolicy and
+        LoaderTaskOptions objects instead of creating two isolated copies of the SecurityOrigin.
+        This is safe because both ContentSecurityPolicy and LoaderTaskOptions are instantiated
+        in WorkerThreadableLoader::MainThreadBridge for use on the main thread only.
+
+        * loader/WorkerThreadableLoader.cpp:
+        (WebCore::LoaderTaskOptions::LoaderTaskOptions):
+        (WebCore::WorkerThreadableLoader::MainThreadBridge::MainThreadBridge):
+
 2016-09-19  Antti Koivisto  <an...@apple.com>
 
         Add size assert for RenderElement

Modified: trunk/Source/WebCore/loader/WorkerThreadableLoader.cpp (206121 => 206122)


--- trunk/Source/WebCore/loader/WorkerThreadableLoader.cpp	2016-09-19 22:12:08 UTC (rev 206121)
+++ trunk/Source/WebCore/loader/WorkerThreadableLoader.cpp	2016-09-19 22:33:56 UTC (rev 206122)
@@ -85,16 +85,16 @@
 }
 
 struct LoaderTaskOptions {
-    LoaderTaskOptions(const ThreadableLoaderOptions&, const String&, const SecurityOrigin&);
+    LoaderTaskOptions(const ThreadableLoaderOptions&, const String&, Ref<SecurityOrigin>&&);
     ThreadableLoaderOptions options;
     String referrer;
-    RefPtr<SecurityOrigin> origin;
+    Ref<SecurityOrigin> origin;
 };
 
-LoaderTaskOptions::LoaderTaskOptions(const ThreadableLoaderOptions& options, const String& referrer, const SecurityOrigin& origin)
+LoaderTaskOptions::LoaderTaskOptions(const ThreadableLoaderOptions& options, const String& referrer, Ref<SecurityOrigin>&& origin)
     : options(options, options.preflightPolicy, options.contentSecurityPolicyEnforcement, options.initiator.isolatedCopy(), options.opaqueResponse)
     , referrer(referrer.isolatedCopy())
-    , origin(origin.isolatedCopy())
+    , origin(WTFMove(origin))
 {
 }
 
@@ -108,10 +108,11 @@
     ASSERT(securityOrigin);
     ASSERT(contentSecurityPolicy);
 
-    auto contentSecurityPolicyCopy = std::make_unique<ContentSecurityPolicy>(securityOrigin->isolatedCopy());
+    auto securityOriginCopy = securityOrigin->isolatedCopy();
+    auto contentSecurityPolicyCopy = std::make_unique<ContentSecurityPolicy>(securityOriginCopy);
     contentSecurityPolicyCopy->copyStateFrom(contentSecurityPolicy);
 
-    auto optionsCopy = std::make_unique<LoaderTaskOptions>(options, request.httpReferrer().isNull() ? outgoingReferrer : request.httpReferrer(), *securityOrigin);
+    auto optionsCopy = std::make_unique<LoaderTaskOptions>(options, request.httpReferrer().isNull() ? outgoingReferrer : request.httpReferrer(), WTFMove(securityOriginCopy));
 
     // Can we benefit from request being an r-value to create more efficiently its isolated copy?
     m_loaderProxy.postTaskToLoader([this, request = request.isolatedCopy(), options = WTFMove(optionsCopy), contentSecurityPolicyCopy = WTFMove(contentSecurityPolicyCopy)](ScriptExecutionContext& context) mutable {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to