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/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 "ipc/ipc_listener.h" | 11 #include "ipc/ipc_listener.h" |
12 #include "third_party/WebKit/public/web/WebServiceWorkerContextClient.h" | 12 #include "third_party/WebKit/public/web/WebServiceWorkerContextClient.h" |
13 #include "url/gurl.h" | 13 #include "url/gurl.h" |
14 | 14 |
15 namespace base { | 15 namespace base { |
16 class MessageLoopProxy; | 16 class MessageLoopProxy; |
17 class TaskRunner; | 17 class TaskRunner; |
18 } | 18 } |
19 | 19 |
| 20 namespace blink { |
| 21 class WebDataSource; |
| 22 } |
| 23 |
20 namespace content { | 24 namespace content { |
21 | 25 |
22 class ServiceWorkerScriptContext; | 26 class ServiceWorkerScriptContext; |
23 class ThreadSafeSender; | 27 class ThreadSafeSender; |
24 | 28 |
25 // This class provides access to/from an embedded worker's WorkerGlobalScope. | 29 // This class provides access to/from an embedded worker's WorkerGlobalScope. |
26 // All methods other than the constructor (it's created on the main thread) | 30 // All methods other than the constructor (it's created on the main thread) |
| 31 // and didCreateDataSource (which is also created on the main thread) |
27 // are called on the worker thread. | 32 // are called on the worker thread. |
28 // | 33 // |
29 // TODO(kinuko): Currently EW/SW separation is made a little hazily. | 34 // TODO(kinuko): Currently EW/SW separation is made a little hazily. |
30 // This should implement WebEmbeddedWorkerContextClient | 35 // This should implement WebEmbeddedWorkerContextClient |
31 // or sort of it (which doesn't exist yet) rather than | 36 // or sort of it (which doesn't exist yet) rather than |
32 // WebServiceWorkerContextClient if we want to separate them more cleanly, | 37 // WebServiceWorkerContextClient if we want to separate them more cleanly, |
33 // or ServiceWorkerScriptContext should be merged into this class | 38 // or ServiceWorkerScriptContext should be merged into this class |
34 // if we consider EW == SW script context. | 39 // if we consider EW == SW script context. |
35 class EmbeddedWorkerContextClient | 40 class EmbeddedWorkerContextClient |
36 : public blink::WebServiceWorkerContextClient { | 41 : public blink::WebServiceWorkerContextClient { |
37 public: | 42 public: |
38 // Returns a thread-specific client instance. This does NOT create a | 43 // Returns a thread-specific client instance. This does NOT create a |
39 // new instance. | 44 // new instance. |
40 static EmbeddedWorkerContextClient* ThreadSpecificInstance(); | 45 static EmbeddedWorkerContextClient* ThreadSpecificInstance(); |
41 | 46 |
42 EmbeddedWorkerContextClient(int embedded_worker_id, | 47 EmbeddedWorkerContextClient(int embedded_worker_id, |
43 int64 service_worker_version_id, | 48 int64 service_worker_version_id, |
44 const GURL& script_url); | 49 const GURL& script_url); |
45 | 50 |
46 virtual ~EmbeddedWorkerContextClient(); | 51 virtual ~EmbeddedWorkerContextClient(); |
47 | 52 |
| 53 // Called on the main thread prior to main script resource load time. |
| 54 // fyi: ShadowDoc's WebFrameClient calls this from within it's |
| 55 // didCreateDataSource method. |
| 56 virtual void didCreateDataSource(blink::WebDataSource*); |
| 57 |
48 bool OnMessageReceived(const IPC::Message& msg); | 58 bool OnMessageReceived(const IPC::Message& msg); |
49 | 59 |
50 void SendMessageToBrowser(int request_id, const IPC::Message& message); | 60 void SendMessageToBrowser(int request_id, const IPC::Message& message); |
51 | 61 |
52 // WebServiceWorkerContextClient overrides, some of them are just dispatched | 62 // WebServiceWorkerContextClient overrides, some of them are just dispatched |
53 // on to script_context_. | 63 // on to script_context_. |
54 virtual void workerContextFailedToStart(); | 64 virtual void workerContextFailedToStart(); |
55 virtual void workerContextStarted(blink::WebServiceWorkerContextProxy* proxy); | 65 virtual void workerContextStarted(blink::WebServiceWorkerContextProxy* proxy); |
56 virtual void workerContextDestroyed(); | 66 virtual void workerContextDestroyed(); |
57 virtual void didHandleInstallEvent(int request_id); | 67 virtual void didHandleInstallEvent(int request_id); |
(...skipping 20 matching lines...) Expand all Loading... |
78 scoped_ptr<ServiceWorkerScriptContext> script_context_; | 88 scoped_ptr<ServiceWorkerScriptContext> script_context_; |
79 | 89 |
80 base::WeakPtrFactory<EmbeddedWorkerContextClient> weak_factory_; | 90 base::WeakPtrFactory<EmbeddedWorkerContextClient> weak_factory_; |
81 | 91 |
82 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerContextClient); | 92 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerContextClient); |
83 }; | 93 }; |
84 | 94 |
85 } // namespace content | 95 } // namespace content |
86 | 96 |
87 #endif // CONTENT_CHILD_SERVICE_WORKER_EMBEDDED_WORKER_CLIENT_H_ | 97 #endif // CONTENT_CHILD_SERVICE_WORKER_EMBEDDED_WORKER_CLIENT_H_ |
OLD | NEW |