| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_RENDERER_SERVICE_WORKER_EMBEDDED_WORKER_CONTEXT_CLIENT_H_ | 5 #ifndef CONTENT_RENDERER_SERVICE_WORKER_EMBEDDED_WORKER_CONTEXT_CLIENT_H_ |
| 6 #define CONTENT_RENDERER_SERVICE_WORKER_EMBEDDED_WORKER_CONTEXT_CLIENT_H_ | 6 #define CONTENT_RENDERER_SERVICE_WORKER_EMBEDDED_WORKER_CONTEXT_CLIENT_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| 11 #include "content/common/service_worker/service_worker_types.h" | 11 #include "content/common/service_worker/service_worker_types.h" |
| 12 #include "ipc/ipc_listener.h" | 12 #include "ipc/ipc_listener.h" |
| 13 #include "third_party/WebKit/public/web/WebServiceWorkerContextClient.h" | 13 #include "third_party/WebKit/public/web/WebServiceWorkerContextClient.h" |
| 14 #include "url/gurl.h" | 14 #include "url/gurl.h" |
| 15 | 15 |
| 16 namespace base { | 16 namespace base { |
| 17 class SingleThreadTaskRunner; | 17 class SingleThreadTaskRunner; |
| 18 class TaskRunner; | 18 class TaskRunner; |
| 19 } | 19 } |
| 20 | 20 |
| 21 namespace blink { | 21 namespace blink { |
| 22 class WebDataSource; | 22 class WebDataSource; |
| 23 class WebServiceWorkerProvider; | 23 class WebServiceWorkerProvider; |
| 24 class WebServiceWorkerCacheStorage; | |
| 25 } | 24 } |
| 26 | 25 |
| 27 namespace content { | 26 namespace content { |
| 28 | 27 |
| 29 class ServiceWorkerProviderContext; | 28 class ServiceWorkerProviderContext; |
| 30 class ServiceWorkerScriptContext; | 29 class ServiceWorkerScriptContext; |
| 31 class ThreadSafeSender; | 30 class ThreadSafeSender; |
| 32 | 31 |
| 33 // This class provides access to/from an embedded worker's WorkerGlobalScope. | 32 // This class provides access to/from an embedded worker's WorkerGlobalScope. |
| 34 // Unless otherwise noted, all methods are called on the worker thread. | 33 // Unless otherwise noted, all methods are called on the worker thread. |
| (...skipping 20 matching lines...) Expand all Loading... |
| 55 | 54 |
| 56 virtual ~EmbeddedWorkerContextClient(); | 55 virtual ~EmbeddedWorkerContextClient(); |
| 57 | 56 |
| 58 bool OnMessageReceived(const IPC::Message& msg); | 57 bool OnMessageReceived(const IPC::Message& msg); |
| 59 | 58 |
| 60 void Send(IPC::Message* message); | 59 void Send(IPC::Message* message); |
| 61 | 60 |
| 62 // WebServiceWorkerContextClient overrides, some of them are just dispatched | 61 // WebServiceWorkerContextClient overrides, some of them are just dispatched |
| 63 // on to script_context_. | 62 // on to script_context_. |
| 64 virtual blink::WebURL scope() const; | 63 virtual blink::WebURL scope() const; |
| 65 // TODO(jsbell): Remove this once Blink is updated. http://crbug.com/439389 | |
| 66 virtual blink::WebServiceWorkerCacheStorage* cacheStorage(); | |
| 67 virtual void didPauseAfterDownload(); | 64 virtual void didPauseAfterDownload(); |
| 68 virtual void getClients(const blink::WebServiceWorkerClientQueryOptions&, | 65 virtual void getClients(const blink::WebServiceWorkerClientQueryOptions&, |
| 69 blink::WebServiceWorkerClientsCallbacks*); | 66 blink::WebServiceWorkerClientsCallbacks*); |
| 70 virtual void openWindow(const blink::WebURL&, | 67 virtual void openWindow(const blink::WebURL&, |
| 71 blink::WebServiceWorkerClientCallbacks*); | 68 blink::WebServiceWorkerClientCallbacks*); |
| 72 virtual void setCachedMetadata(const blink::WebURL&, | 69 virtual void setCachedMetadata(const blink::WebURL&, |
| 73 const char* data, | 70 const char* data, |
| 74 size_t size); | 71 size_t size); |
| 75 virtual void clearCachedMetadata(const blink::WebURL&); | 72 virtual void clearCachedMetadata(const blink::WebURL&); |
| 76 virtual void workerReadyForInspection(); | 73 virtual void workerReadyForInspection(); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 virtual void claim(blink::WebServiceWorkerClientsClaimCallbacks* callbacks); | 128 virtual void claim(blink::WebServiceWorkerClientsClaimCallbacks* callbacks); |
| 132 | 129 |
| 133 // TODO: Implement DevTools related method overrides. | 130 // TODO: Implement DevTools related method overrides. |
| 134 | 131 |
| 135 int embedded_worker_id() const { return embedded_worker_id_; } | 132 int embedded_worker_id() const { return embedded_worker_id_; } |
| 136 base::SingleThreadTaskRunner* main_thread_task_runner() const { | 133 base::SingleThreadTaskRunner* main_thread_task_runner() const { |
| 137 return main_thread_task_runner_.get(); | 134 return main_thread_task_runner_.get(); |
| 138 } | 135 } |
| 139 ThreadSafeSender* thread_safe_sender() { return sender_.get(); } | 136 ThreadSafeSender* thread_safe_sender() { return sender_.get(); } |
| 140 | 137 |
| 141 // Only needed by ServiceWorkerScriptContext when creating a | |
| 142 // WebServiceWorkerCacheStorageImpl | |
| 143 // TODO(jsbell): Remove when no longer needed. crbug.com/439389 | |
| 144 const GURL origin() const { return service_worker_scope_.GetOrigin(); } | |
| 145 | |
| 146 private: | 138 private: |
| 147 void OnMessageToWorker(int thread_id, | 139 void OnMessageToWorker(int thread_id, |
| 148 int embedded_worker_id, | 140 int embedded_worker_id, |
| 149 const IPC::Message& message); | 141 const IPC::Message& message); |
| 150 void SendWorkerStarted(); | 142 void SendWorkerStarted(); |
| 151 void SetRegistrationInServiceWorkerGlobalScope(); | 143 void SetRegistrationInServiceWorkerGlobalScope(); |
| 152 | 144 |
| 153 const int embedded_worker_id_; | 145 const int embedded_worker_id_; |
| 154 const int64 service_worker_version_id_; | 146 const int64 service_worker_version_id_; |
| 155 const GURL service_worker_scope_; | 147 const GURL service_worker_scope_; |
| 156 const GURL script_url_; | 148 const GURL script_url_; |
| 157 const int worker_devtools_agent_route_id_; | 149 const int worker_devtools_agent_route_id_; |
| 158 scoped_refptr<ThreadSafeSender> sender_; | 150 scoped_refptr<ThreadSafeSender> sender_; |
| 159 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; | 151 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; |
| 160 scoped_refptr<base::TaskRunner> worker_task_runner_; | 152 scoped_refptr<base::TaskRunner> worker_task_runner_; |
| 161 | 153 |
| 162 scoped_ptr<ServiceWorkerScriptContext> script_context_; | 154 scoped_ptr<ServiceWorkerScriptContext> script_context_; |
| 163 scoped_refptr<ServiceWorkerProviderContext> provider_context_; | 155 scoped_refptr<ServiceWorkerProviderContext> provider_context_; |
| 164 | 156 |
| 165 base::WeakPtrFactory<EmbeddedWorkerContextClient> weak_factory_; | 157 base::WeakPtrFactory<EmbeddedWorkerContextClient> weak_factory_; |
| 166 | 158 |
| 167 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerContextClient); | 159 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerContextClient); |
| 168 }; | 160 }; |
| 169 | 161 |
| 170 } // namespace content | 162 } // namespace content |
| 171 | 163 |
| 172 #endif // CONTENT_RENDERER_SERVICE_WORKER_EMBEDDED_WORKER_CONTEXT_CLIENT_H_ | 164 #endif // CONTENT_RENDERER_SERVICE_WORKER_EMBEDDED_WORKER_CONTEXT_CLIENT_H_ |
| OLD | NEW |