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

Side by Side Diff: third_party/WebKit/Source/web/WebSharedWorkerImpl.h

Issue 2721543002: SharedWorker: Factor out WorkerReportingProxy impl from WebSharedWorkerImpl (Closed)
Patch Set: tweak header comment Created 3 years, 9 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
OLDNEW
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 18 matching lines...) Expand all
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" 38 #include "core/workers/WorkerLoaderProxy.h"
39 #include "core/workers/WorkerReportingProxy.h"
40 #include "core/workers/WorkerThread.h" 39 #include "core/workers/WorkerThread.h"
41 #include "public/platform/WebAddressSpace.h" 40 #include "public/platform/WebAddressSpace.h"
42 #include "public/platform/WebContentSecurityPolicy.h" 41 #include "public/platform/WebContentSecurityPolicy.h"
43 #include "public/web/WebDevToolsAgentClient.h" 42 #include "public/web/WebDevToolsAgentClient.h"
44 #include "public/web/WebFrameClient.h" 43 #include "public/web/WebFrameClient.h"
45 #include "public/web/WebSharedWorkerClient.h" 44 #include "public/web/WebSharedWorkerClient.h"
45 #include "web/WebSharedWorkerReportingProxyImpl.h"
46 #include "wtf/RefPtr.h" 46 #include "wtf/RefPtr.h"
47 47
48 namespace blink { 48 namespace blink {
49 49
50 class ParentFrameTaskRunners; 50 class ParentFrameTaskRunners;
51 class WebApplicationCacheHost; 51 class WebApplicationCacheHost;
52 class WebApplicationCacheHostClient; 52 class WebApplicationCacheHostClient;
53 class WebLocalFrameImpl; 53 class WebLocalFrameImpl;
54 class WebServiceWorkerNetworkProvider; 54 class WebServiceWorkerNetworkProvider;
55 class WebSharedWorkerClient; 55 class WebSharedWorkerClient;
56 class WebString; 56 class WebString;
57 class WebURL; 57 class WebURL;
58 class WebView; 58 class WebView;
59 class WorkerInspectorProxy; 59 class WorkerInspectorProxy;
60 class WorkerScriptLoader; 60 class WorkerScriptLoader;
61 61
62 // This class is used by the worker process code to talk to the SharedWorker 62 // This class is used by the worker process code to talk to the SharedWorker
63 // implementation. 63 // implementation. This is basically accessed on the main thread, but some
64 // It can't use it directly since it uses WebKit types, so this class converts 64 // methods must be called from a worker thread. Such methods are suffixed with
65 // the data types. When the SharedWorker object wants to call 65 // *OnWorkerThread or have header comments.
66 // WorkerReportingProxy, this class will convert to Chrome data types first and 66 class WebSharedWorkerImpl final : public WebFrameClient,
67 // then call the supplied WebCommonWorkerClient.
68 class WebSharedWorkerImpl final : public WorkerReportingProxy,
69 public WebFrameClient,
70 public WebSharedWorker, 67 public WebSharedWorker,
71 public WebDevToolsAgentClient, 68 public WebDevToolsAgentClient,
72 private WorkerLoaderProxyProvider { 69 private WorkerLoaderProxyProvider {
73 public: 70 public:
74 explicit WebSharedWorkerImpl(WebSharedWorkerClient*); 71 explicit WebSharedWorkerImpl(WebSharedWorkerClient*);
75 72
76 // WorkerReportingProxy methods:
77 void countFeature(UseCounter::Feature) override;
78 void countDeprecation(UseCounter::Feature) override;
79 void reportException(const WTF::String&,
80 std::unique_ptr<SourceLocation>,
81 int exceptionId) override;
82 void reportConsoleMessage(MessageSource,
83 MessageLevel,
84 const String& message,
85 SourceLocation*) override;
86 void postMessageToPageInspector(const WTF::String&) override;
87 void didEvaluateWorkerScript(bool success) override {}
88 void didCloseWorkerGlobalScope() override;
89 void willDestroyWorkerGlobalScope() override {}
90 void didTerminateWorkerThread() override;
91
92 // WebFrameClient methods to support resource loading thru the 'shadow page'. 73 // WebFrameClient methods to support resource loading thru the 'shadow page'.
93 WebApplicationCacheHost* createApplicationCacheHost( 74 WebApplicationCacheHost* createApplicationCacheHost(
94 WebApplicationCacheHostClient*) override; 75 WebApplicationCacheHostClient*) override;
95 void willSendRequest(WebLocalFrame*, WebURLRequest&) override; 76 void willSendRequest(WebLocalFrame*, WebURLRequest&) override;
96 void didFinishDocumentLoad(WebLocalFrame*) override; 77 void didFinishDocumentLoad(WebLocalFrame*) override;
97 bool isControlledByServiceWorker(WebDataSource&) override; 78 bool isControlledByServiceWorker(WebDataSource&) override;
98 int64_t serviceWorkerID(WebDataSource&) override; 79 int64_t serviceWorkerID(WebDataSource&) override;
99 80
100 // WebDevToolsAgentClient overrides. 81 // WebDevToolsAgentClient overrides.
101 void sendProtocolMessage(int sessionId, 82 void sendProtocolMessage(int sessionId,
(...skipping 17 matching lines...) Expand all
119 void attachDevTools(const WebString& hostId, int sessionId) override; 100 void attachDevTools(const WebString& hostId, int sessionId) override;
120 void reattachDevTools(const WebString& hostId, 101 void reattachDevTools(const WebString& hostId,
121 int sesionId, 102 int sesionId,
122 const WebString& savedState) override; 103 const WebString& savedState) override;
123 void detachDevTools() override; 104 void detachDevTools() override;
124 void dispatchDevToolsMessage(int sessionId, 105 void dispatchDevToolsMessage(int sessionId,
125 int callId, 106 int callId,
126 const WebString& method, 107 const WebString& method,
127 const WebString& message) override; 108 const WebString& message) override;
128 109
110 // Callback methods for WebSharedWorkerReportingProxyImpl.
111 void countFeature(UseCounter::Feature);
112 void postMessageToPageInspector(const String& message);
113 void didCloseWorkerGlobalScope();
114 void didTerminateWorkerThread();
115
129 private: 116 private:
130 ~WebSharedWorkerImpl() override; 117 ~WebSharedWorkerImpl() override;
131 118
132 WorkerThread* workerThread() { return m_workerThread.get(); } 119 WorkerThread* workerThread() { return m_workerThread.get(); }
133 120
134 // Shuts down the worker thread. 121 // Shuts down the worker thread.
135 void terminateWorkerThread(); 122 void terminateWorkerThread();
136 123
137 // Creates the shadow loader used for worker network requests. 124 // Creates the shadow loader used for worker network requests.
138 void initializeLoader(); 125 void initializeLoader();
139 126
140 void loadShadowPage(); 127 void loadShadowPage();
141 void didReceiveScriptLoaderResponse(); 128 void didReceiveScriptLoaderResponse();
142 void onScriptLoaderFinished(); 129 void onScriptLoaderFinished();
143 130
144 void connectTask(WebMessagePortChannelUniquePtr); 131 void connectTaskOnWorkerThread(WebMessagePortChannelUniquePtr);
145
146 // Tasks that are run on the main thread.
147 void didCloseWorkerGlobalScopeOnMainThread();
148 void didTerminateWorkerThreadOnMainThread();
149
150 void postMessageToPageInspectorOnMainThread(const String& message);
151 132
152 // WorkerLoaderProxyProvider 133 // WorkerLoaderProxyProvider
134 // postTaskToLoader() must be called from a worker thread.
153 void postTaskToLoader(const WebTraceLocation&, 135 void postTaskToLoader(const WebTraceLocation&,
154 std::unique_ptr<WTF::CrossThreadClosure>) override; 136 std::unique_ptr<WTF::CrossThreadClosure>) override;
155 void postTaskToWorkerGlobalScope( 137 void postTaskToWorkerGlobalScope(
156 const WebTraceLocation&, 138 const WebTraceLocation&,
157 std::unique_ptr<WTF::CrossThreadClosure>) override; 139 std::unique_ptr<WTF::CrossThreadClosure>) override;
158 ExecutionContext* getLoaderExecutionContext() override; 140 ExecutionContext* getLoaderExecutionContext() override;
159 141
160 // 'shadow page' - created to proxy loading requests from the worker. 142 // 'shadow page' - created to proxy loading requests from the worker.
161 // Will be accessed by worker thread when posting tasks. 143 // Will be accessed by worker thread when posting tasks.
162 Persistent<ExecutionContext> m_loadingDocument; 144 Persistent<ExecutionContext> m_loadingDocument;
163 WebView* m_webView; 145 WebView* m_webView;
164 Persistent<WebLocalFrameImpl> m_mainFrame; 146 Persistent<WebLocalFrameImpl> m_mainFrame;
165 bool m_askedToTerminate; 147 bool m_askedToTerminate;
166 148
167 // This one is bound to and used only on the main thread.
168 std::unique_ptr<WebServiceWorkerNetworkProvider> m_networkProvider; 149 std::unique_ptr<WebServiceWorkerNetworkProvider> m_networkProvider;
169 150
170 Persistent<WorkerInspectorProxy> m_workerInspectorProxy; 151 Persistent<WorkerInspectorProxy> m_workerInspectorProxy;
171 152
172 // Owned by the main thread, but will be accessed by the worker. 153 // Owned by the main thread, but will be accessed by the worker.
173 CrossThreadPersistent<ParentFrameTaskRunners> m_parentFrameTaskRunners; 154 CrossThreadPersistent<ParentFrameTaskRunners> m_parentFrameTaskRunners;
174 155
156 Persistent<WebSharedWorkerReportingProxyImpl> m_reportingProxy;
175 std::unique_ptr<WorkerThread> m_workerThread; 157 std::unique_ptr<WorkerThread> m_workerThread;
176 158
177 WebSharedWorkerClient* m_client; 159 WebSharedWorkerClient* m_client;
178 160
179 bool m_pauseWorkerContextOnStart; 161 bool m_pauseWorkerContextOnStart;
180 bool m_isPausedOnStart; 162 bool m_isPausedOnStart;
181 163
182 // Kept around only while main script loading is ongoing. 164 // Kept around only while main script loading is ongoing.
183 RefPtr<WorkerScriptLoader> m_mainScriptLoader; 165 RefPtr<WorkerScriptLoader> m_mainScriptLoader;
184 166
185 RefPtr<WorkerLoaderProxy> m_loaderProxy; 167 RefPtr<WorkerLoaderProxy> m_loaderProxy;
186 168
187 WebURL m_url; 169 WebURL m_url;
188 WebString m_name; 170 WebString m_name;
189 WebAddressSpace m_creationAddressSpace; 171 WebAddressSpace m_creationAddressSpace;
190 }; 172 };
191 173
192 } // namespace blink 174 } // namespace blink
193 175
194 #endif // WebSharedWorkerImpl_h 176 #endif // WebSharedWorkerImpl_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/BUILD.gn ('k') | third_party/WebKit/Source/web/WebSharedWorkerImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698