Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(789)

Side by Side Diff: Source/web/WebEmbeddedWorkerImpl.cpp

Issue 1190493002: move processContentSecurityPolicy to WorkerScriptLoader (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: (rebase) Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/workers/WorkerScriptLoaderClient.cpp ('k') | Source/web/WebSharedWorkerImpl.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 85
86 void load(ExecutionContext* loadingContext, const KURL& scriptURL, PassOwnPt r<Closure> callback) 86 void load(ExecutionContext* loadingContext, const KURL& scriptURL, PassOwnPt r<Closure> callback)
87 { 87 {
88 ASSERT(loadingContext); 88 ASSERT(loadingContext);
89 m_callback = callback; 89 m_callback = callback;
90 m_scriptLoader->setRequestContext(WebURLRequest::RequestContextServiceWo rker); 90 m_scriptLoader->setRequestContext(WebURLRequest::RequestContextServiceWo rker);
91 m_scriptLoader->loadAsynchronously( 91 m_scriptLoader->loadAsynchronously(
92 *loadingContext, scriptURL, DenyCrossOriginRequests, this); 92 *loadingContext, scriptURL, DenyCrossOriginRequests, this);
93 } 93 }
94 94
95 void didReceiveResponse(unsigned long identifier, const ResourceResponse& re sponse) override
96 {
97 m_contentSecurityPolicy = ContentSecurityPolicy::create();
98 m_contentSecurityPolicy->setOverrideURLForSelf(response.url());
99 m_contentSecurityPolicy->didReceiveHeaders(ContentSecurityPolicyResponse Headers(response));
100 }
101
102 virtual void notifyFinished() override 95 virtual void notifyFinished() override
103 { 96 {
104 (*m_callback)(); 97 (*m_callback)();
105 } 98 }
106 99
107 void cancel() 100 void cancel()
108 { 101 {
109 m_scriptLoader->cancel(); 102 m_scriptLoader->cancel();
110 } 103 }
111 104
112 bool failed() const { return m_scriptLoader->failed(); } 105 bool failed() const { return m_scriptLoader->failed(); }
113 const KURL& url() const { return m_scriptLoader->responseURL(); } 106 const KURL& url() const { return m_scriptLoader->responseURL(); }
114 String script() const { return m_scriptLoader->script(); } 107 String script() const { return m_scriptLoader->script(); }
115 const Vector<char>* cachedMetadata() const { return m_scriptLoader->cachedMe tadata(); } 108 const Vector<char>* cachedMetadata() const { return m_scriptLoader->cachedMe tadata(); }
116 PassOwnPtr<Vector<char>> releaseCachedMetadata() const { return m_scriptLoad er->releaseCachedMetadata(); } 109 PassOwnPtr<Vector<char>> releaseCachedMetadata() const { return m_scriptLoad er->releaseCachedMetadata(); }
117 PassRefPtr<ContentSecurityPolicy> releaseContentSecurityPolicy() { return m_ contentSecurityPolicy.release(); } 110 PassRefPtr<ContentSecurityPolicy> releaseContentSecurityPolicy() { return m_ scriptLoader->releaseContentSecurityPolicy(); }
118 111
119 private: 112 private:
120 Loader() : m_scriptLoader(WorkerScriptLoader::create()) 113 Loader() : m_scriptLoader(WorkerScriptLoader::create())
121 { 114 {
122 } 115 }
123 116
124 RefPtr<WorkerScriptLoader> m_scriptLoader; 117 RefPtr<WorkerScriptLoader> m_scriptLoader;
125 OwnPtr<Closure> m_callback; 118 OwnPtr<Closure> m_callback;
126 RefPtr<ContentSecurityPolicy> m_contentSecurityPolicy;
127 }; 119 };
128 120
129 WebEmbeddedWorker* WebEmbeddedWorker::create(WebServiceWorkerContextClient* clie nt, WebWorkerContentSettingsClientProxy* contentSettingsClient) 121 WebEmbeddedWorker* WebEmbeddedWorker::create(WebServiceWorkerContextClient* clie nt, WebWorkerContentSettingsClientProxy* contentSettingsClient)
130 { 122 {
131 return new WebEmbeddedWorkerImpl(adoptPtr(client), adoptPtr(contentSettingsC lient)); 123 return new WebEmbeddedWorkerImpl(adoptPtr(client), adoptPtr(contentSettingsC lient));
132 } 124 }
133 125
134 static HashSet<WebEmbeddedWorkerImpl*>& runningWorkerInstances() 126 static HashSet<WebEmbeddedWorkerImpl*>& runningWorkerInstances()
135 { 127 {
136 DEFINE_STATIC_LOCAL(HashSet<WebEmbeddedWorkerImpl*>, set, ()); 128 DEFINE_STATIC_LOCAL(HashSet<WebEmbeddedWorkerImpl*>, set, ());
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
439 m_mainScriptLoader.clear(); 431 m_mainScriptLoader.clear();
440 432
441 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(*this, *doc ument, *m_workerContextClient); 433 m_workerGlobalScopeProxy = ServiceWorkerGlobalScopeProxy::create(*this, *doc ument, *m_workerContextClient);
442 m_loaderProxy = WorkerLoaderProxy::create(this); 434 m_loaderProxy = WorkerLoaderProxy::create(this);
443 m_workerThread = ServiceWorkerThread::create(m_loaderProxy, *m_workerGlobalS copeProxy); 435 m_workerThread = ServiceWorkerThread::create(m_loaderProxy, *m_workerGlobalS copeProxy);
444 m_workerThread->start(startupData.release()); 436 m_workerThread->start(startupData.release());
445 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(), scriptURL); 437 m_workerInspectorProxy->workerThreadCreated(document, m_workerThread.get(), scriptURL);
446 } 438 }
447 439
448 } // namespace blink 440 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/workers/WorkerScriptLoaderClient.cpp ('k') | Source/web/WebSharedWorkerImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698