| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 17 matching lines...) Expand all Loading... |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef WebSharedWorkerImpl_h | 31 #ifndef WebSharedWorkerImpl_h |
| 32 #define WebSharedWorkerImpl_h | 32 #define WebSharedWorkerImpl_h |
| 33 | 33 |
| 34 #include "public/web/WebSharedWorker.h" | 34 #include "public/web/WebSharedWorker.h" |
| 35 | 35 |
| 36 #include <memory> | 36 #include <memory> |
| 37 #include "core/dom/ExecutionContext.h" | 37 #include "core/dom/ExecutionContext.h" |
| 38 #include "core/workers/WorkerLoaderProxy.h" | |
| 39 #include "core/workers/WorkerThread.h" | 38 #include "core/workers/WorkerThread.h" |
| 40 #include "platform/wtf/RefPtr.h" | 39 #include "platform/wtf/RefPtr.h" |
| 41 #include "public/platform/Platform.h" | 40 #include "public/platform/Platform.h" |
| 42 #include "public/platform/WebAddressSpace.h" | 41 #include "public/platform/WebAddressSpace.h" |
| 43 #include "public/platform/WebContentSecurityPolicy.h" | 42 #include "public/platform/WebContentSecurityPolicy.h" |
| 44 #include "public/web/WebDevToolsAgentClient.h" | 43 #include "public/web/WebDevToolsAgentClient.h" |
| 45 #include "public/web/WebFrameClient.h" | 44 #include "public/web/WebFrameClient.h" |
| 46 #include "public/web/WebSharedWorkerClient.h" | 45 #include "public/web/WebSharedWorkerClient.h" |
| 47 #include "web/WebSharedWorkerReportingProxyImpl.h" | 46 #include "web/WebSharedWorkerReportingProxyImpl.h" |
| 48 | 47 |
| 49 namespace blink { | 48 namespace blink { |
| 50 | 49 |
| 51 class WebApplicationCacheHost; | 50 class WebApplicationCacheHost; |
| 52 class WebApplicationCacheHostClient; | 51 class WebApplicationCacheHostClient; |
| 53 class WebLocalFrameBase; | 52 class WebLocalFrameBase; |
| 54 class WebServiceWorkerNetworkProvider; | 53 class WebServiceWorkerNetworkProvider; |
| 55 class WebSharedWorkerClient; | 54 class WebSharedWorkerClient; |
| 56 class WebString; | 55 class WebString; |
| 57 class WebURL; | 56 class WebURL; |
| 58 class WebView; | 57 class WebView; |
| 59 class WorkerInspectorProxy; | 58 class WorkerInspectorProxy; |
| 60 class WorkerScriptLoader; | 59 class WorkerScriptLoader; |
| 61 | 60 |
| 62 // This class is used by the worker process code to talk to the SharedWorker | 61 // This class is used by the worker process code to talk to the SharedWorker |
| 63 // implementation. This is basically accessed on the main thread, but some | 62 // implementation. This is basically accessed on the main thread, but some |
| 64 // methods must be called from a worker thread. Such methods are suffixed with | 63 // methods must be called from a worker thread. Such methods are suffixed with |
| 65 // *OnWorkerThread or have header comments. | 64 // *OnWorkerThread or have header comments. |
| 66 class WebSharedWorkerImpl final : public WebFrameClient, | 65 class WebSharedWorkerImpl final : public WebFrameClient, |
| 67 public WebSharedWorker, | 66 public WebSharedWorker, |
| 68 public WebDevToolsAgentClient, | 67 public WebDevToolsAgentClient { |
| 69 private WorkerLoaderProxyProvider { | |
| 70 public: | 68 public: |
| 71 explicit WebSharedWorkerImpl(WebSharedWorkerClient*); | 69 explicit WebSharedWorkerImpl(WebSharedWorkerClient*); |
| 72 | 70 |
| 73 // WebFrameClient methods to support resource loading thru the 'shadow page'. | 71 // WebFrameClient methods to support resource loading thru the 'shadow page'. |
| 74 std::unique_ptr<WebApplicationCacheHost> CreateApplicationCacheHost( | 72 std::unique_ptr<WebApplicationCacheHost> CreateApplicationCacheHost( |
| 75 WebApplicationCacheHostClient*) override; | 73 WebApplicationCacheHostClient*) override; |
| 76 void FrameDetached(WebLocalFrame*, DetachType) override; | 74 void FrameDetached(WebLocalFrame*, DetachType) override; |
| 77 void DidFinishDocumentLoad() override; | 75 void DidFinishDocumentLoad() override; |
| 78 | 76 |
| 79 // WebDevToolsAgentClient overrides. | 77 // WebDevToolsAgentClient overrides. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 125 |
| 128 // Creates the shadow loader used for worker network requests. | 126 // Creates the shadow loader used for worker network requests. |
| 129 void InitializeLoader(bool data_saver_enabled); | 127 void InitializeLoader(bool data_saver_enabled); |
| 130 | 128 |
| 131 void LoadShadowPage(); | 129 void LoadShadowPage(); |
| 132 void DidReceiveScriptLoaderResponse(); | 130 void DidReceiveScriptLoaderResponse(); |
| 133 void OnScriptLoaderFinished(); | 131 void OnScriptLoaderFinished(); |
| 134 | 132 |
| 135 void ConnectTaskOnWorkerThread(std::unique_ptr<WebMessagePortChannel>); | 133 void ConnectTaskOnWorkerThread(std::unique_ptr<WebMessagePortChannel>); |
| 136 | 134 |
| 137 // WorkerLoaderProxyProvider | |
| 138 ThreadableLoadingContext* GetThreadableLoadingContext() override; | |
| 139 | |
| 140 // 'shadow page' - created to proxy loading requests from the worker. | 135 // 'shadow page' - created to proxy loading requests from the worker. |
| 141 // Will be accessed by worker thread when posting tasks. | 136 // Will be accessed by worker thread when posting tasks. |
| 142 Persistent<ExecutionContext> loading_document_; | 137 Persistent<ExecutionContext> loading_document_; |
| 143 Persistent<ThreadableLoadingContext> loading_context_; | 138 Persistent<ThreadableLoadingContext> loading_context_; |
| 144 WebView* web_view_; | 139 WebView* web_view_; |
| 145 Persistent<WebLocalFrameBase> main_frame_; | 140 Persistent<WebLocalFrameBase> main_frame_; |
| 146 bool asked_to_terminate_; | 141 bool asked_to_terminate_; |
| 147 | 142 |
| 148 std::unique_ptr<WebServiceWorkerNetworkProvider> network_provider_; | 143 std::unique_ptr<WebServiceWorkerNetworkProvider> network_provider_; |
| 149 | 144 |
| 150 Persistent<WorkerInspectorProxy> worker_inspector_proxy_; | 145 Persistent<WorkerInspectorProxy> worker_inspector_proxy_; |
| 151 | 146 |
| 152 Persistent<WebSharedWorkerReportingProxyImpl> reporting_proxy_; | 147 Persistent<WebSharedWorkerReportingProxyImpl> reporting_proxy_; |
| 153 std::unique_ptr<WorkerThread> worker_thread_; | 148 std::unique_ptr<WorkerThread> worker_thread_; |
| 154 | 149 |
| 155 WebSharedWorkerClient* client_; | 150 WebSharedWorkerClient* client_; |
| 156 | 151 |
| 157 bool pause_worker_context_on_start_; | 152 bool pause_worker_context_on_start_; |
| 158 bool is_paused_on_start_; | 153 bool is_paused_on_start_; |
| 159 | 154 |
| 160 // Kept around only while main script loading is ongoing. | 155 // Kept around only while main script loading is ongoing. |
| 161 RefPtr<WorkerScriptLoader> main_script_loader_; | 156 RefPtr<WorkerScriptLoader> main_script_loader_; |
| 162 | 157 |
| 163 RefPtr<WorkerLoaderProxy> loader_proxy_; | |
| 164 | |
| 165 WebURL url_; | 158 WebURL url_; |
| 166 WebString name_; | 159 WebString name_; |
| 167 WebAddressSpace creation_address_space_; | 160 WebAddressSpace creation_address_space_; |
| 168 }; | 161 }; |
| 169 | 162 |
| 170 } // namespace blink | 163 } // namespace blink |
| 171 | 164 |
| 172 #endif // WebSharedWorkerImpl_h | 165 #endif // WebSharedWorkerImpl_h |
| OLD | NEW |