| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |