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_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_H_ |
6 #define CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 struct EmbeddedWorkerMsg_StartWorker_Params; | 30 struct EmbeddedWorkerMsg_StartWorker_Params; |
31 | 31 |
32 namespace IPC { | 32 namespace IPC { |
33 class Message; | 33 class Message; |
34 } | 34 } |
35 | 35 |
36 namespace content { | 36 namespace content { |
37 | 37 |
38 class EmbeddedWorkerRegistry; | 38 class EmbeddedWorkerRegistry; |
39 class MessagePortMessageFilter; | 39 class MessagePortMessageFilter; |
| 40 class ServiceRegistry; |
| 41 class ServiceRegistryImpl; |
40 class ServiceWorkerContextCore; | 42 class ServiceWorkerContextCore; |
41 struct ServiceWorkerFetchRequest; | 43 struct ServiceWorkerFetchRequest; |
42 | 44 |
43 // This gives an interface to control one EmbeddedWorker instance, which | 45 // This gives an interface to control one EmbeddedWorker instance, which |
44 // may be 'in-waiting' or running in one of the child processes added by | 46 // may be 'in-waiting' or running in one of the child processes added by |
45 // AddProcessReference(). | 47 // AddProcessReference(). |
46 class CONTENT_EXPORT EmbeddedWorkerInstance { | 48 class CONTENT_EXPORT EmbeddedWorkerInstance { |
47 public: | 49 public: |
48 typedef base::Callback<void(ServiceWorkerStatusCode)> StatusCallback; | 50 typedef base::Callback<void(ServiceWorkerStatusCode)> StatusCallback; |
49 enum Status { | 51 enum Status { |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 // Stops the worker if the worker is not being debugged (i.e. devtools is | 115 // Stops the worker if the worker is not being debugged (i.e. devtools is |
114 // not attached). This method is called by a stop-worker timer to kill | 116 // not attached). This method is called by a stop-worker timer to kill |
115 // idle workers. | 117 // idle workers. |
116 void StopIfIdle(); | 118 void StopIfIdle(); |
117 | 119 |
118 // Sends |message| to the embedded worker running in the child process. | 120 // Sends |message| to the embedded worker running in the child process. |
119 // It is invalid to call this while the worker is not in STARTING or RUNNING | 121 // It is invalid to call this while the worker is not in STARTING or RUNNING |
120 // status. | 122 // status. |
121 ServiceWorkerStatusCode SendMessage(const IPC::Message& message); | 123 ServiceWorkerStatusCode SendMessage(const IPC::Message& message); |
122 | 124 |
| 125 // Returns the ServiceRegistry for this worker. It is invalid to call this |
| 126 // when the worker is not in STARTING or RUNNING status. |
| 127 ServiceRegistry* GetServiceRegistry(); |
| 128 |
123 void ResumeAfterDownload(); | 129 void ResumeAfterDownload(); |
124 | 130 |
125 int embedded_worker_id() const { return embedded_worker_id_; } | 131 int embedded_worker_id() const { return embedded_worker_id_; } |
126 Status status() const { return status_; } | 132 Status status() const { return status_; } |
127 StartingPhase starting_phase() const { | 133 StartingPhase starting_phase() const { |
128 DCHECK_EQ(STARTING, status()); | 134 DCHECK_EQ(STARTING, status()); |
129 return starting_phase_; | 135 return starting_phase_; |
130 } | 136 } |
131 int process_id() const { return process_id_; } | 137 int process_id() const { return process_id_; } |
132 int thread_id() const { return thread_id_; } | 138 int thread_id() const { return thread_id_; } |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 | 240 |
235 base::WeakPtr<ServiceWorkerContextCore> context_; | 241 base::WeakPtr<ServiceWorkerContextCore> context_; |
236 scoped_refptr<EmbeddedWorkerRegistry> registry_; | 242 scoped_refptr<EmbeddedWorkerRegistry> registry_; |
237 const int embedded_worker_id_; | 243 const int embedded_worker_id_; |
238 Status status_; | 244 Status status_; |
239 StartingPhase starting_phase_; | 245 StartingPhase starting_phase_; |
240 | 246 |
241 // Current running information. -1 indicates the worker is not running. | 247 // Current running information. -1 indicates the worker is not running. |
242 int process_id_; | 248 int process_id_; |
243 int thread_id_; | 249 int thread_id_; |
| 250 scoped_ptr<ServiceRegistryImpl> service_registry_; |
244 | 251 |
245 // Whether devtools is attached or not. | 252 // Whether devtools is attached or not. |
246 bool devtools_attached_; | 253 bool devtools_attached_; |
247 | 254 |
248 // True if the script load request accessed the network. If the script was | 255 // True if the script load request accessed the network. If the script was |
249 // served from HTTPCache or ServiceWorkerDatabase this value is false. | 256 // served from HTTPCache or ServiceWorkerDatabase this value is false. |
250 bool network_accessed_for_script_; | 257 bool network_accessed_for_script_; |
251 | 258 |
252 StatusCallback start_callback_; | 259 StatusCallback start_callback_; |
253 ListenerList listener_list_; | 260 ListenerList listener_list_; |
254 scoped_ptr<DevToolsProxy> devtools_proxy_; | 261 scoped_ptr<DevToolsProxy> devtools_proxy_; |
255 | 262 |
256 base::TimeTicks start_timing_; | 263 base::TimeTicks start_timing_; |
257 | 264 |
258 base::WeakPtrFactory<EmbeddedWorkerInstance> weak_factory_; | 265 base::WeakPtrFactory<EmbeddedWorkerInstance> weak_factory_; |
259 | 266 |
260 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerInstance); | 267 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerInstance); |
261 }; | 268 }; |
262 | 269 |
263 } // namespace content | 270 } // namespace content |
264 | 271 |
265 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_H_ | 272 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_H_ |
OLD | NEW |