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_CHILD_SERVICE_WORKER_EMBEDDED_WORKER_CLIENT_H_ | 5 #ifndef CONTENT_CHILD_SERVICE_WORKER_EMBEDDED_WORKER_CLIENT_H_ |
6 #define CONTENT_CHILD_SERVICE_WORKER_EMBEDDED_WORKER_CLIENT_H_ | 6 #define CONTENT_CHILD_SERVICE_WORKER_EMBEDDED_WORKER_CLIENT_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
10 #include "ipc/ipc_listener.h" | 10 #include "ipc/ipc_listener.h" |
11 #include "third_party/WebKit/public/web/WebServiceWorkerContextClient.h" | 11 #include "third_party/WebKit/public/web/WebServiceWorkerContextClient.h" |
12 #include "url/gurl.h" | 12 #include "url/gurl.h" |
13 | 13 |
14 namespace base { | 14 namespace base { |
15 class MessageLoopProxy; | 15 class MessageLoopProxy; |
16 } | 16 } |
17 | 17 |
18 namespace content { | 18 namespace content { |
19 | 19 |
| 20 struct ServiceWorkerFetchRequest; |
20 class ThreadSafeSender; | 21 class ThreadSafeSender; |
21 | 22 |
22 // This class provides access to/from an embedded worker's WorkerGlobalScope. | 23 // This class provides access to/from an embedded worker's WorkerGlobalScope. |
23 // All methods other than the constructor (it's created on the main thread) | 24 // All methods other than the constructor (it's created on the main thread) |
24 // are called on the worker thread. | 25 // are called on the worker thread. |
25 class ServiceWorkerContextClient | 26 class EmbeddedWorkerContextClient |
26 : public blink::WebServiceWorkerContextClient { | 27 : public blink::WebServiceWorkerContextClient { |
27 public: | 28 public: |
28 // Returns a thread-specific client instance. This does NOT create a | 29 // Returns a thread-specific client instance. This does NOT create a |
29 // new instance. | 30 // new instance. |
30 static ServiceWorkerContextClient* ThreadSpecificInstance(); | 31 static EmbeddedWorkerContextClient* ThreadSpecificInstance(); |
31 | 32 |
32 ServiceWorkerContextClient(int embedded_worker_id, | 33 EmbeddedWorkerContextClient(int embedded_worker_id, |
33 int64 service_worker_version_id, | 34 int64 service_worker_version_id, |
34 const GURL& script_url); | 35 const GURL& script_url); |
35 | 36 |
36 virtual ~ServiceWorkerContextClient(); | 37 virtual ~EmbeddedWorkerContextClient(); |
37 | 38 |
38 bool OnMessageReceived(const IPC::Message& msg); | 39 bool OnMessageReceived(const IPC::Message& msg); |
39 | 40 |
40 // WebServiceWorkerContextClient overrides. | 41 // WebServiceWorkerContextClient overrides. |
41 virtual void workerContextFailedToStart(); | 42 virtual void workerContextFailedToStart(); |
42 virtual void workerContextStarted(blink::WebServiceWorkerContextProxy* proxy); | 43 virtual void workerContextStarted(blink::WebServiceWorkerContextProxy* proxy); |
43 virtual void workerContextDestroyed(); | 44 virtual void workerContextDestroyed(); |
44 | 45 |
45 // TODO: Implement DevTools related method overrides. | 46 // TODO: Implement DevTools related method overrides. |
46 | 47 |
47 int embedded_worker_id() const { return embedded_worker_id_; } | 48 int embedded_worker_id() const { return embedded_worker_id_; } |
48 | 49 |
49 private: | 50 private: |
| 51 void OnFetchEvent(int thread_id, |
| 52 int embedded_worker_id, |
| 53 const ServiceWorkerFetchRequest& request); |
| 54 |
50 const int embedded_worker_id_; | 55 const int embedded_worker_id_; |
51 const int64 service_worker_version_id_; | 56 const int64 service_worker_version_id_; |
52 const GURL script_url_; | 57 const GURL script_url_; |
53 scoped_refptr<ThreadSafeSender> sender_; | 58 scoped_refptr<ThreadSafeSender> sender_; |
54 scoped_refptr<base::MessageLoopProxy> main_thread_proxy_; | 59 scoped_refptr<base::MessageLoopProxy> main_thread_proxy_; |
55 | 60 |
56 blink::WebServiceWorkerContextProxy* proxy_; | 61 blink::WebServiceWorkerContextProxy* proxy_; |
57 | 62 |
58 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerContextClient); | 63 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerContextClient); |
59 }; | 64 }; |
60 | 65 |
61 } // namespace content | 66 } // namespace content |
62 | 67 |
63 #endif // CONTENT_CHILD_SERVICE_WORKER_EMBEDDED_WORKER_CLIENT_H_ | 68 #endif // CONTENT_CHILD_SERVICE_WORKER_EMBEDDED_WORKER_CLIENT_H_ |
OLD | NEW |