| 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 28 matching lines...) Expand all Loading... |
| 39 #include "public/web/WebEmbeddedWorkerStartData.h" | 39 #include "public/web/WebEmbeddedWorkerStartData.h" |
| 40 #include "public/web/WebFrameClient.h" | 40 #include "public/web/WebFrameClient.h" |
| 41 | 41 |
| 42 namespace blink { | 42 namespace blink { |
| 43 | 43 |
| 44 class ServiceWorkerGlobalScopeProxy; | 44 class ServiceWorkerGlobalScopeProxy; |
| 45 class WebLocalFrameImpl; | 45 class WebLocalFrameImpl; |
| 46 class WebServiceWorkerNetworkProvider; | 46 class WebServiceWorkerNetworkProvider; |
| 47 class WebView; | 47 class WebView; |
| 48 class WorkerInspectorProxy; | 48 class WorkerInspectorProxy; |
| 49 class WorkerScriptLoader; |
| 49 class WorkerThread; | 50 class WorkerThread; |
| 50 | 51 |
| 51 class WebEmbeddedWorkerImpl final | 52 class WebEmbeddedWorkerImpl final |
| 52 : public WebEmbeddedWorker | 53 : public WebEmbeddedWorker |
| 53 , public WebFrameClient | 54 , public WebFrameClient |
| 54 , public WebDevToolsAgentClient | 55 , public WebDevToolsAgentClient |
| 55 , private WorkerLoaderProxyProvider { | 56 , private WorkerLoaderProxyProvider { |
| 56 WTF_MAKE_NONCOPYABLE(WebEmbeddedWorkerImpl); | 57 WTF_MAKE_NONCOPYABLE(WebEmbeddedWorkerImpl); |
| 57 public: | 58 public: |
| 58 WebEmbeddedWorkerImpl(PassOwnPtr<WebServiceWorkerContextClient>, PassOwnPtr<
WebWorkerContentSettingsClientProxy>); | 59 WebEmbeddedWorkerImpl(PassOwnPtr<WebServiceWorkerContextClient>, PassOwnPtr<
WebWorkerContentSettingsClientProxy>); |
| 59 virtual ~WebEmbeddedWorkerImpl(); | 60 ~WebEmbeddedWorkerImpl() override; |
| 60 | 61 |
| 61 // Terminate all WebEmbeddedWorkerImpl for testing purposes. | 62 // Terminate all WebEmbeddedWorkerImpl for testing purposes. |
| 62 // Note that this only schedules termination and | 63 // Note that this only schedules termination and |
| 63 // does not synchronously wait for it to complete. | 64 // does not synchronously wait for it to complete. |
| 64 static void terminateAll(); | 65 static void terminateAll(); |
| 65 | 66 |
| 66 // WebEmbeddedWorker overrides. | 67 // WebEmbeddedWorker overrides. |
| 67 virtual void startWorkerContext(const WebEmbeddedWorkerStartData&) override; | 68 void startWorkerContext(const WebEmbeddedWorkerStartData&) override; |
| 68 virtual void resumeAfterDownload() override; | 69 void resumeAfterDownload() override; |
| 69 virtual void terminateWorkerContext() override; | 70 void terminateWorkerContext() override; |
| 70 virtual void attachDevTools(const WebString& hostId) override; | 71 void attachDevTools(const WebString& hostId) override; |
| 71 virtual void reattachDevTools(const WebString& hostId, const WebString& save
dState) override; | 72 void reattachDevTools(const WebString& hostId, const WebString& savedState)
override; |
| 72 virtual void detachDevTools() override; | 73 void detachDevTools() override; |
| 73 virtual void dispatchDevToolsMessage(const WebString&) override; | 74 void dispatchDevToolsMessage(const WebString&) override; |
| 74 | 75 |
| 75 void postMessageToPageInspector(const WTF::String&); | 76 void postMessageToPageInspector(const WTF::String&); |
| 76 | 77 |
| 77 private: | 78 private: |
| 78 class Loader; | |
| 79 | |
| 80 void prepareShadowPageForLoader(); | 79 void prepareShadowPageForLoader(); |
| 81 void loadShadowPage(); | 80 void loadShadowPage(); |
| 82 | 81 |
| 83 // WebFrameClient overrides. | 82 // WebFrameClient overrides. |
| 84 virtual void willSendRequest( | 83 void willSendRequest( |
| 85 WebLocalFrame*, unsigned identifier, WebURLRequest&, | 84 WebLocalFrame*, unsigned identifier, WebURLRequest&, |
| 86 const WebURLResponse& redirectResponse) override; | 85 const WebURLResponse& redirectResponse) override; |
| 87 virtual void didFinishDocumentLoad(WebLocalFrame*) override; | 86 void didFinishDocumentLoad(WebLocalFrame*) override; |
| 88 | 87 |
| 89 // WebDevToolsAgentClient overrides. | 88 // WebDevToolsAgentClient overrides. |
| 90 virtual void sendProtocolMessage(int callId, const WebString&, const WebStri
ng&) override; | 89 void sendProtocolMessage(int callId, const WebString&, const WebString&) ove
rride; |
| 91 virtual void resumeStartup() override; | 90 void resumeStartup() override; |
| 92 | 91 |
| 93 void onScriptLoaderFinished(); | 92 void onScriptLoaderFinished(); |
| 94 void startWorkerThread(); | 93 void startWorkerThread(); |
| 95 | 94 |
| 96 // WorkerLoaderProxyProvider | 95 // WorkerLoaderProxyProvider |
| 97 virtual void postTaskToLoader(PassOwnPtr<ExecutionContextTask>) override; | 96 void postTaskToLoader(PassOwnPtr<ExecutionContextTask>) override; |
| 98 virtual bool postTaskToWorkerGlobalScope(PassOwnPtr<ExecutionContextTask>) o
verride; | 97 bool postTaskToWorkerGlobalScope(PassOwnPtr<ExecutionContextTask>) override; |
| 99 | 98 |
| 100 WebEmbeddedWorkerStartData m_workerStartData; | 99 WebEmbeddedWorkerStartData m_workerStartData; |
| 101 | 100 |
| 102 OwnPtr<WebServiceWorkerContextClient> m_workerContextClient; | 101 OwnPtr<WebServiceWorkerContextClient> m_workerContextClient; |
| 103 | 102 |
| 104 // This is kept until startWorkerContext is called, and then passed on | 103 // This is kept until startWorkerContext is called, and then passed on |
| 105 // to WorkerContext. | 104 // to WorkerContext. |
| 106 OwnPtr<WebWorkerContentSettingsClientProxy> m_contentSettingsClient; | 105 OwnPtr<WebWorkerContentSettingsClientProxy> m_contentSettingsClient; |
| 107 | 106 |
| 108 // We retain ownership of this one which is for use on the | 107 // We retain ownership of this one which is for use on the |
| 109 // main thread only. | 108 // main thread only. |
| 110 OwnPtr<WebServiceWorkerNetworkProvider> m_networkProvider; | 109 OwnPtr<WebServiceWorkerNetworkProvider> m_networkProvider; |
| 111 | 110 |
| 112 // Kept around only while main script loading is ongoing. | 111 // Kept around only while main script loading is ongoing. |
| 113 OwnPtr<Loader> m_mainScriptLoader; | 112 OwnPtr<WorkerScriptLoader> m_mainScriptLoader; |
| 114 | 113 |
| 115 RefPtr<WorkerThread> m_workerThread; | 114 RefPtr<WorkerThread> m_workerThread; |
| 116 RefPtr<WorkerLoaderProxy> m_loaderProxy; | 115 RefPtr<WorkerLoaderProxy> m_loaderProxy; |
| 117 OwnPtr<ServiceWorkerGlobalScopeProxy> m_workerGlobalScopeProxy; | 116 OwnPtr<ServiceWorkerGlobalScopeProxy> m_workerGlobalScopeProxy; |
| 118 OwnPtr<WorkerInspectorProxy> m_workerInspectorProxy; | 117 OwnPtr<WorkerInspectorProxy> m_workerInspectorProxy; |
| 119 | 118 |
| 120 // 'shadow page' - created to proxy loading requests from the worker. | 119 // 'shadow page' - created to proxy loading requests from the worker. |
| 121 // Both WebView and WebFrame objects are close()'ed (where they're | 120 // Both WebView and WebFrame objects are close()'ed (where they're |
| 122 // deref'ed) when this EmbeddedWorkerImpl is destructed, therefore they | 121 // deref'ed) when this EmbeddedWorkerImpl is destructed, therefore they |
| 123 // are guaranteed to exist while this object is around. | 122 // are guaranteed to exist while this object is around. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 138 DoPauseAfterDownload, | 137 DoPauseAfterDownload, |
| 139 IsPausedAfterDownload | 138 IsPausedAfterDownload |
| 140 } m_pauseAfterDownloadState; | 139 } m_pauseAfterDownloadState; |
| 141 | 140 |
| 142 WaitingForDebuggerState m_waitingForDebuggerState; | 141 WaitingForDebuggerState m_waitingForDebuggerState; |
| 143 }; | 142 }; |
| 144 | 143 |
| 145 } // namespace blink | 144 } // namespace blink |
| 146 | 145 |
| 147 #endif // WebEmbeddedWorkerImpl_h | 146 #endif // WebEmbeddedWorkerImpl_h |
| OLD | NEW |