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

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

Issue 534293003: DevTools: Switch shared workers inspection on to the main thread. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 3 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 | « no previous file | Source/web/WebSharedWorkerImpl.cpp » ('j') | Source/web/WebSharedWorkerImpl.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 21 matching lines...) Expand all
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 "core/dom/ExecutionContext.h" 36 #include "core/dom/ExecutionContext.h"
37 #include "core/workers/WorkerLoaderProxy.h" 37 #include "core/workers/WorkerLoaderProxy.h"
38 #include "core/workers/WorkerReportingProxy.h" 38 #include "core/workers/WorkerReportingProxy.h"
39 #include "core/workers/WorkerScriptLoaderClient.h" 39 #include "core/workers/WorkerScriptLoaderClient.h"
40 #include "core/workers/WorkerThread.h" 40 #include "core/workers/WorkerThread.h"
41 #include "public/web/WebContentSecurityPolicy.h" 41 #include "public/web/WebContentSecurityPolicy.h"
42 #include "public/web/WebDevToolsAgentClient.h"
42 #include "public/web/WebFrameClient.h" 43 #include "public/web/WebFrameClient.h"
43 #include "public/web/WebSharedWorkerClient.h" 44 #include "public/web/WebSharedWorkerClient.h"
44 #include "wtf/PassOwnPtr.h" 45 #include "wtf/PassOwnPtr.h"
45 #include "wtf/RefPtr.h" 46 #include "wtf/RefPtr.h"
46 #include "wtf/WeakPtr.h" 47 #include "wtf/WeakPtr.h"
47 48
48 namespace blink { 49 namespace blink {
49 50
50 class ConsoleMessage; 51 class ConsoleMessage;
51 class ResourceResponse; 52 class ResourceResponse;
52 class WebApplicationCacheHost; 53 class WebApplicationCacheHost;
53 class WebApplicationCacheHostClient; 54 class WebApplicationCacheHostClient;
54 class WebWorkerClient; 55 class WebWorkerClient;
55 class WebSecurityOrigin; 56 class WebSecurityOrigin;
56 class WebString; 57 class WebString;
57 class WebURL; 58 class WebURL;
58 class WebView; 59 class WebView;
59 class WebWorker; 60 class WebWorker;
60 class WebSharedWorkerClient; 61 class WebSharedWorkerClient;
61 class WorkerInspectorProxy; 62 class WorkerInspectorProxy;
62 63
63 // This class is used by the worker process code to talk to the SharedWorker imp lementation. 64 // This class is used by the worker process code to talk to the SharedWorker imp lementation.
64 // It can't use it directly since it uses WebKit types, so this class converts t he data types. 65 // It can't use it directly since it uses WebKit types, so this class converts t he data types.
65 // When the SharedWorker object wants to call WorkerReportingProxy, this class w ill 66 // When the SharedWorker object wants to call WorkerReportingProxy, this class w ill
66 // convert to Chrome data types first and then call the supplied WebCommonWorker Client. 67 // convert to Chrome data types first and then call the supplied WebCommonWorker Client.
67 class WebSharedWorkerImpl FINAL 68 class WebSharedWorkerImpl FINAL
68 : public WorkerReportingProxy 69 : public WorkerReportingProxy
69 , public WorkerLoaderProxy 70 , public WorkerLoaderProxy
70 , public WebFrameClient 71 , public WebFrameClient
71 , public WebSharedWorker { 72 , public WebSharedWorker
73 , public WebDevToolsAgentClient {
72 public: 74 public:
73 explicit WebSharedWorkerImpl(WebSharedWorkerClient*); 75 explicit WebSharedWorkerImpl(WebSharedWorkerClient*);
74 76
75 // WorkerReportingProxy methods: 77 // WorkerReportingProxy methods:
76 virtual void reportException( 78 virtual void reportException(
77 const WTF::String&, int, int, const WTF::String&) OVERRIDE; 79 const WTF::String&, int, int, const WTF::String&) OVERRIDE;
78 virtual void reportConsoleMessage(PassRefPtrWillBeRawPtr<ConsoleMessage>) OV ERRIDE; 80 virtual void reportConsoleMessage(PassRefPtrWillBeRawPtr<ConsoleMessage>) OV ERRIDE;
79 virtual void postMessageToPageInspector(const WTF::String&) OVERRIDE; 81 virtual void postMessageToPageInspector(const WTF::String&) OVERRIDE;
80 virtual void updateInspectorStateCookie(const WTF::String&) OVERRIDE; 82 virtual void updateInspectorStateCookie(const WTF::String&) OVERRIDE;
81 virtual void workerGlobalScopeStarted(WorkerGlobalScope*) OVERRIDE; 83 virtual void workerGlobalScopeStarted(WorkerGlobalScope*) OVERRIDE;
82 virtual void workerGlobalScopeClosed() OVERRIDE; 84 virtual void workerGlobalScopeClosed() OVERRIDE;
83 virtual void workerThreadTerminated() OVERRIDE; 85 virtual void workerThreadTerminated() OVERRIDE;
84 virtual void willDestroyWorkerGlobalScope() OVERRIDE { } 86 virtual void willDestroyWorkerGlobalScope() OVERRIDE { }
85 87
86 // WorkerLoaderProxy methods: 88 // WorkerLoaderProxy methods:
87 virtual void postTaskToLoader(PassOwnPtr<ExecutionContextTask>) OVERRIDE; 89 virtual void postTaskToLoader(PassOwnPtr<ExecutionContextTask>) OVERRIDE;
88 virtual bool postTaskToWorkerGlobalScope(PassOwnPtr<ExecutionContextTask>) O VERRIDE; 90 virtual bool postTaskToWorkerGlobalScope(PassOwnPtr<ExecutionContextTask>) O VERRIDE;
89 91
90 // WebFrameClient methods to support resource loading thru the 'shadow page' . 92 // WebFrameClient methods to support resource loading thru the 'shadow page' .
91 virtual WebApplicationCacheHost* createApplicationCacheHost(WebLocalFrame*, WebApplicationCacheHostClient*) OVERRIDE; 93 virtual WebApplicationCacheHost* createApplicationCacheHost(WebLocalFrame*, WebApplicationCacheHostClient*) OVERRIDE;
92 virtual void didFinishDocumentLoad(WebLocalFrame*) OVERRIDE; 94 virtual void didFinishDocumentLoad(WebLocalFrame*) OVERRIDE;
93 95
96 // WebDevToolsAgentClient overrides.
97 virtual void sendMessageToInspectorFrontend(const WebString&) OVERRIDE;
98 virtual void saveAgentRuntimeState(const WebString&) OVERRIDE;
99 virtual void resumeStartup() OVERRIDE;
100
94 // WebSharedWorker methods: 101 // WebSharedWorker methods:
95 virtual void startWorkerContext(const WebURL&, const WebString& name, const WebString& contentSecurityPolicy, WebContentSecurityPolicyType) OVERRIDE; 102 virtual void startWorkerContext(const WebURL&, const WebString& name, const WebString& contentSecurityPolicy, WebContentSecurityPolicyType) OVERRIDE;
96 virtual void connect(WebMessagePortChannel*) OVERRIDE; 103 virtual void connect(WebMessagePortChannel*) OVERRIDE;
97 virtual void terminateWorkerContext() OVERRIDE; 104 virtual void terminateWorkerContext() OVERRIDE;
98 virtual void clientDestroyed() OVERRIDE; 105 virtual void clientDestroyed() OVERRIDE;
99 106
100 virtual void pauseWorkerContextOnStart() OVERRIDE; 107 virtual void pauseWorkerContextOnStart() OVERRIDE;
101 virtual void resumeWorkerContext() OVERRIDE; 108 virtual void resumeWorkerContext() OVERRIDE;
102 // FIXME: Remove this once chromium uses the one that receives hostId as a p arameter.
103 virtual void attachDevTools() OVERRIDE;
104 virtual void attachDevTools(const WebString& hostId) OVERRIDE; 109 virtual void attachDevTools(const WebString& hostId) OVERRIDE;
105 // FIXME: Remove this once chromium uses the one that receives hostId as a p arameter.
106 virtual void reattachDevTools(const WebString& savedState) OVERRIDE;
107 virtual void reattachDevTools(const WebString& hostId, const WebString& save dState) OVERRIDE; 110 virtual void reattachDevTools(const WebString& hostId, const WebString& save dState) OVERRIDE;
108 virtual void detachDevTools() OVERRIDE; 111 virtual void detachDevTools() OVERRIDE;
109 virtual void dispatchDevToolsMessage(const WebString&) OVERRIDE; 112 virtual void dispatchDevToolsMessage(const WebString&) OVERRIDE;
110 113
111 private: 114 private:
112 class Loader; 115 class Loader;
113 116
114 virtual ~WebSharedWorkerImpl(); 117 virtual ~WebSharedWorkerImpl();
115 118
116 WebSharedWorkerClient* client() { return m_client->get(); } 119 WebSharedWorkerClient* client() { return m_client->get(); }
117 120
118 void setWorkerThread(PassRefPtr<WorkerThread> thread) { m_workerThread = thr ead; } 121 void setWorkerThread(PassRefPtr<WorkerThread> thread) { m_workerThread = thr ead; }
119 WorkerThread* workerThread() { return m_workerThread.get(); } 122 WorkerThread* workerThread() { return m_workerThread.get(); }
120 123
121 // Shuts down the worker thread. 124 // Shuts down the worker thread.
122 void stopWorkerThread(); 125 void stopWorkerThread();
123 126
124 // Creates the shadow loader used for worker network requests. 127 // Creates the shadow loader used for worker network requests.
125 void initializeLoader(const WebURL&); 128 void initializeLoader(const WebURL&);
126 129
130 void startScriptLoader(WebLocalFrame*);
127 void didReceiveScriptLoaderResponse(); 131 void didReceiveScriptLoaderResponse();
128 void onScriptLoaderFinished(); 132 void onScriptLoaderFinished();
129 133
130 static void connectTask(ExecutionContext*, PassOwnPtr<WebMessagePortChannel> ); 134 static void connectTask(ExecutionContext*, PassOwnPtr<WebMessagePortChannel> );
131 // Tasks that are run on the main thread. 135 // Tasks that are run on the main thread.
132 void workerGlobalScopeClosedOnMainThread(); 136 void workerGlobalScopeClosedOnMainThread();
133 void workerThreadTerminatedOnMainThread(); 137 void workerThreadTerminatedOnMainThread();
134 138
135 void postMessageToPageInspectorOnMainThread(const String& message); 139 void postMessageToPageInspectorOnMainThread(const String& message);
136 140
137 // 'shadow page' - created to proxy loading requests from the worker. 141 // 'shadow page' - created to proxy loading requests from the worker.
138 RefPtrWillBePersistent<ExecutionContext> m_loadingDocument; 142 RefPtrWillBePersistent<ExecutionContext> m_loadingDocument;
139 WebView* m_webView; 143 WebView* m_webView;
140 WebFrame* m_mainFrame; 144 WebFrame* m_mainFrame;
141 bool m_askedToTerminate; 145 bool m_askedToTerminate;
142 146
143 OwnPtr<WorkerInspectorProxy> m_workerInspectorProxy; 147 OwnPtr<WorkerInspectorProxy> m_workerInspectorProxy;
144 148
145 RefPtr<WorkerThread> m_workerThread; 149 RefPtr<WorkerThread> m_workerThread;
146 150
147 // This one's initialized and bound to the main thread. 151 // This one's initialized and bound to the main thread.
148 RefPtr<WeakReference<WebSharedWorkerClient> > m_client; 152 RefPtr<WeakReference<WebSharedWorkerClient> > m_client;
149 153
150 // Usually WeakPtr is created by WeakPtrFactory exposed by Client 154 // Usually WeakPtr is created by WeakPtrFactory exposed by Client
151 // class itself, but here it's implemented by Chrome so we create 155 // class itself, but here it's implemented by Chrome so we create
152 // our own WeakPtr. 156 // our own WeakPtr.
153 WeakPtr<WebSharedWorkerClient> m_clientWeakPtr; 157 WeakPtr<WebSharedWorkerClient> m_clientWeakPtr;
154 158
155 bool m_pauseWorkerContextOnStart; 159 bool m_pauseWorkerContextOnStart;
156 bool m_attachDevToolsOnStart; 160 bool m_isPausedOnStart;
157 161
158 // Kept around only while main script loading is ongoing. 162 // Kept around only while main script loading is ongoing.
159 OwnPtr<Loader> m_mainScriptLoader; 163 OwnPtr<Loader> m_mainScriptLoader;
160 WebURL m_url; 164 WebURL m_url;
161 WebString m_name; 165 WebString m_name;
162 WebString m_contentSecurityPolicy; 166 WebString m_contentSecurityPolicy;
163 WebContentSecurityPolicyType m_policyType; 167 WebContentSecurityPolicyType m_policyType;
164 }; 168 };
165 169
166 } // namespace blink 170 } // namespace blink
167 171
168 #endif 172 #endif
OLDNEW
« no previous file with comments | « no previous file | Source/web/WebSharedWorkerImpl.cpp » ('j') | Source/web/WebSharedWorkerImpl.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698