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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 // Stops the worker if the worker is not being debugged (i.e. devtools is | 113 // Stops the worker if the worker is not being debugged (i.e. devtools is |
112 // not attached). This method is called by a stop-worker timer to kill | 114 // not attached). This method is called by a stop-worker timer to kill |
113 // idle workers. | 115 // idle workers. |
114 void StopIfIdle(); | 116 void StopIfIdle(); |
115 | 117 |
116 // Sends |message| to the embedded worker running in the child process. | 118 // Sends |message| to the embedded worker running in the child process. |
117 // It is invalid to call this while the worker is not in STARTING or RUNNING | 119 // It is invalid to call this while the worker is not in STARTING or RUNNING |
118 // status. | 120 // status. |
119 ServiceWorkerStatusCode SendMessage(const IPC::Message& message); | 121 ServiceWorkerStatusCode SendMessage(const IPC::Message& message); |
120 | 122 |
| 123 // Returns the ServiceRegistry for this worker. It is invalid to call this |
| 124 // when the worker is not in STARTING or RUNNING status. |
| 125 ServiceRegistry* GetServiceRegistry(); |
| 126 |
121 int embedded_worker_id() const { return embedded_worker_id_; } | 127 int embedded_worker_id() const { return embedded_worker_id_; } |
122 Status status() const { return status_; } | 128 Status status() const { return status_; } |
123 StartingPhase starting_phase() const { | 129 StartingPhase starting_phase() const { |
124 DCHECK_EQ(STARTING, status()); | 130 DCHECK_EQ(STARTING, status()); |
125 return starting_phase_; | 131 return starting_phase_; |
126 } | 132 } |
127 int process_id() const { return process_id_; } | 133 int process_id() const { return process_id_; } |
128 int thread_id() const { return thread_id_; } | 134 int thread_id() const { return thread_id_; } |
129 int worker_devtools_agent_route_id() const; | 135 int worker_devtools_agent_route_id() const; |
130 MessagePortMessageFilter* message_port_message_filter() const; | 136 MessagePortMessageFilter* message_port_message_filter() const; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 | 234 |
229 base::WeakPtr<ServiceWorkerContextCore> context_; | 235 base::WeakPtr<ServiceWorkerContextCore> context_; |
230 scoped_refptr<EmbeddedWorkerRegistry> registry_; | 236 scoped_refptr<EmbeddedWorkerRegistry> registry_; |
231 const int embedded_worker_id_; | 237 const int embedded_worker_id_; |
232 Status status_; | 238 Status status_; |
233 StartingPhase starting_phase_; | 239 StartingPhase starting_phase_; |
234 | 240 |
235 // Current running information. -1 indicates the worker is not running. | 241 // Current running information. -1 indicates the worker is not running. |
236 int process_id_; | 242 int process_id_; |
237 int thread_id_; | 243 int thread_id_; |
| 244 scoped_ptr<ServiceRegistryImpl> service_registry_; |
238 | 245 |
239 // Whether devtools is attached or not. | 246 // Whether devtools is attached or not. |
240 bool devtools_attached_; | 247 bool devtools_attached_; |
241 | 248 |
242 // True if the script load request accessed the network. If the script was | 249 // True if the script load request accessed the network. If the script was |
243 // served from HTTPCache or ServiceWorkerDatabase this value is false. | 250 // served from HTTPCache or ServiceWorkerDatabase this value is false. |
244 bool network_accessed_for_script_; | 251 bool network_accessed_for_script_; |
245 | 252 |
246 StatusCallback start_callback_; | 253 StatusCallback start_callback_; |
247 ListenerList listener_list_; | 254 ListenerList listener_list_; |
248 scoped_ptr<DevToolsProxy> devtools_proxy_; | 255 scoped_ptr<DevToolsProxy> devtools_proxy_; |
249 | 256 |
250 base::TimeTicks start_timing_; | 257 base::TimeTicks start_timing_; |
251 | 258 |
252 base::WeakPtrFactory<EmbeddedWorkerInstance> weak_factory_; | 259 base::WeakPtrFactory<EmbeddedWorkerInstance> weak_factory_; |
253 | 260 |
254 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerInstance); | 261 DISALLOW_COPY_AND_ASSIGN(EmbeddedWorkerInstance); |
255 }; | 262 }; |
256 | 263 |
257 } // namespace content | 264 } // namespace content |
258 | 265 |
259 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_H_ | 266 #endif // CONTENT_BROWSER_SERVICE_WORKER_EMBEDDED_WORKER_INSTANCE_H_ |
OLD | NEW |