| 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 19 matching lines...) Expand all Loading... |
| 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/CoreExport.h" | 37 #include "core/CoreExport.h" |
| 38 #include "core/dom/ExecutionContext.h" | 38 #include "core/dom/ExecutionContext.h" |
| 39 #include "core/workers/SharedWorkerReportingProxy.h" | 39 #include "core/workers/SharedWorkerReportingProxy.h" |
| 40 #include "core/workers/WorkerClients.h" |
| 40 #include "core/workers/WorkerThread.h" | 41 #include "core/workers/WorkerThread.h" |
| 41 #include "platform/wtf/RefPtr.h" | 42 #include "platform/wtf/RefPtr.h" |
| 42 #include "public/platform/Platform.h" | 43 #include "public/platform/Platform.h" |
| 43 #include "public/platform/WebAddressSpace.h" | 44 #include "public/platform/WebAddressSpace.h" |
| 44 #include "public/platform/WebContentSecurityPolicy.h" | 45 #include "public/platform/WebContentSecurityPolicy.h" |
| 45 #include "public/web/WebDevToolsAgentClient.h" | 46 #include "public/web/WebDevToolsAgentClient.h" |
| 46 #include "public/web/WebFrameClient.h" | 47 #include "public/web/WebFrameClient.h" |
| 47 #include "public/web/WebSharedWorkerClient.h" | 48 #include "public/web/WebSharedWorkerClient.h" |
| 48 | 49 |
| 49 namespace blink { | 50 namespace blink { |
| 50 | 51 |
| 51 class WebApplicationCacheHost; | 52 class WebApplicationCacheHost; |
| 52 class WebApplicationCacheHostClient; | 53 class WebApplicationCacheHostClient; |
| 53 class WebLocalFrameBase; | 54 class WebLocalFrameBase; |
| 54 class WebServiceWorkerNetworkProvider; | 55 class WebServiceWorkerNetworkProvider; |
| 55 class WebSharedWorkerClient; | 56 class WebSharedWorkerClient; |
| 56 class WebString; | 57 class WebString; |
| 57 class WebURL; | 58 class WebURL; |
| 58 class WebView; | 59 class WebView; |
| 59 class WorkerClients; | |
| 60 class WorkerInspectorProxy; | 60 class WorkerInspectorProxy; |
| 61 class WorkerScriptLoader; | 61 class WorkerScriptLoader; |
| 62 | 62 |
| 63 // This class is used by the worker process code to talk to the SharedWorker | 63 // This class is used by the worker process code to talk to the SharedWorker |
| 64 // implementation. This is basically accessed on the main thread, but some | 64 // implementation. This is basically accessed on the main thread, but some |
| 65 // methods must be called from a worker thread. Such methods are suffixed with | 65 // methods must be called from a worker thread. Such methods are suffixed with |
| 66 // *OnWorkerThread or have header comments. | 66 // *OnWorkerThread or have header comments. |
| 67 class WebSharedWorkerImpl final : public WebFrameClient, | 67 class CORE_EXPORT WebSharedWorkerImpl final |
| 68 public WebSharedWorker, | 68 : public WebFrameClient, |
| 69 public WebDevToolsAgentClient { | 69 public WebSharedWorker, |
| 70 NON_EXPORTED_BASE(public WebDevToolsAgentClient) { |
| 70 public: | 71 public: |
| 71 explicit WebSharedWorkerImpl(WebSharedWorkerClient*); | 72 explicit WebSharedWorkerImpl(WebSharedWorkerClient*); |
| 72 | 73 |
| 73 // WebFrameClient methods to support resource loading thru the 'shadow page'. | 74 // WebFrameClient methods to support resource loading thru the 'shadow page'. |
| 74 std::unique_ptr<WebApplicationCacheHost> CreateApplicationCacheHost( | 75 std::unique_ptr<WebApplicationCacheHost> CreateApplicationCacheHost( |
| 75 WebApplicationCacheHostClient*) override; | 76 WebApplicationCacheHostClient*) override; |
| 76 void FrameDetached(WebLocalFrame*, DetachType) override; | 77 void FrameDetached(WebLocalFrame*, DetachType) override; |
| 77 void DidFinishDocumentLoad() override; | 78 void DidFinishDocumentLoad() override; |
| 78 | 79 |
| 79 // WebDevToolsAgentClient overrides. | 80 // WebDevToolsAgentClient overrides. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 110 // TODO(yhirano): Stop using Platform::CreateURLLoader() here. | 111 // TODO(yhirano): Stop using Platform::CreateURLLoader() here. |
| 111 return Platform::Current()->CreateURLLoader(); | 112 return Platform::Current()->CreateURLLoader(); |
| 112 } | 113 } |
| 113 | 114 |
| 114 // Callback methods for SharedWorkerReportingProxy. | 115 // Callback methods for SharedWorkerReportingProxy. |
| 115 void CountFeature(WebFeature); | 116 void CountFeature(WebFeature); |
| 116 void PostMessageToPageInspector(const String& message); | 117 void PostMessageToPageInspector(const String& message); |
| 117 void DidCloseWorkerGlobalScope(); | 118 void DidCloseWorkerGlobalScope(); |
| 118 void DidTerminateWorkerThread(); | 119 void DidTerminateWorkerThread(); |
| 119 | 120 |
| 120 using WorkerClientsCreatedCallback = void (*)(WorkerClients*); | |
| 121 // Allows for the registration of a callback that is invoked whenever a new | |
| 122 // OnScriptLoaderFinished is called. Callbacks are executed in the order that | |
| 123 // they were added using RegisterWorkerClientsCreatedCallback, and there are | |
| 124 // no checks for adding a callback multiple times. | |
| 125 CORE_EXPORT static void RegisterWorkerClientsCreatedCallback( | |
| 126 WorkerClientsCreatedCallback); | |
| 127 | |
| 128 private: | 121 private: |
| 129 ~WebSharedWorkerImpl() override; | 122 ~WebSharedWorkerImpl() override; |
| 130 | 123 |
| 131 WorkerThread* GetWorkerThread() { return worker_thread_.get(); } | 124 WorkerThread* GetWorkerThread() { return worker_thread_.get(); } |
| 132 | 125 |
| 133 // Shuts down the worker thread. | 126 // Shuts down the worker thread. |
| 134 void TerminateWorkerThread(); | 127 void TerminateWorkerThread(); |
| 135 | 128 |
| 136 // Creates the shadow loader used for worker network requests. | 129 // Creates the shadow loader used for worker network requests. |
| 137 void InitializeLoader(bool data_saver_enabled); | 130 void InitializeLoader(bool data_saver_enabled); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 163 bool is_paused_on_start_; | 156 bool is_paused_on_start_; |
| 164 | 157 |
| 165 // Kept around only while main script loading is ongoing. | 158 // Kept around only while main script loading is ongoing. |
| 166 RefPtr<WorkerScriptLoader> main_script_loader_; | 159 RefPtr<WorkerScriptLoader> main_script_loader_; |
| 167 | 160 |
| 168 WebURL url_; | 161 WebURL url_; |
| 169 WebString name_; | 162 WebString name_; |
| 170 WebAddressSpace creation_address_space_; | 163 WebAddressSpace creation_address_space_; |
| 171 }; | 164 }; |
| 172 | 165 |
| 166 extern template class CORE_EXTERN_TEMPLATE_EXPORT |
| 167 WorkerClientsInitializer<WebSharedWorkerImpl>; |
| 168 |
| 173 } // namespace blink | 169 } // namespace blink |
| 174 | 170 |
| 175 #endif // WebSharedWorkerImpl_h | 171 #endif // WebSharedWorkerImpl_h |
| OLD | NEW |