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_SERVICE_WORKER_VERSION_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
115 // Registers status change callback. (This is for one-off observation, | 115 // Registers status change callback. (This is for one-off observation, |
116 // the consumer needs to re-register if it wants to continue observing | 116 // the consumer needs to re-register if it wants to continue observing |
117 // status changes) | 117 // status changes) |
118 void RegisterStatusChangeCallback(const base::Closure& callback); | 118 void RegisterStatusChangeCallback(const base::Closure& callback); |
119 | 119 |
120 // Starts an embedded worker for this version. | 120 // Starts an embedded worker for this version. |
121 // This returns OK (success) if the worker is already running. | 121 // This returns OK (success) if the worker is already running. |
122 void StartWorker(const StatusCallback& callback); | 122 void StartWorker(const StatusCallback& callback); |
123 | 123 |
124 // Starts an embedded worker for this version. | 124 // Starts an embedded worker for this version. |
125 // |potential_process_ids| is a list of processes in which to start the | 125 // |pause_after_download| is a flag to tell worker to pause after download. |
Jeffrey Yasskin
2014/08/19 23:42:24
This isn't a particularly useful comment. What wou
xiang
2014/08/29 07:49:40
Done.
| |
126 // worker. | |
127 // This returns OK (success) if the worker is already running. | 126 // This returns OK (success) if the worker is already running. |
128 void StartWorkerWithCandidateProcesses( | 127 void StartWorker(bool pause_after_download, |
129 const std::vector<int>& potential_process_ids, | 128 const StatusCallback& callback); |
130 bool pause_after_download, | |
131 const StatusCallback& callback); | |
132 | 129 |
133 // Stops an embedded worker for this version. | 130 // Stops an embedded worker for this version. |
134 // This returns OK (success) if the worker is already stopped. | 131 // This returns OK (success) if the worker is already stopped. |
135 void StopWorker(const StatusCallback& callback); | 132 void StopWorker(const StatusCallback& callback); |
136 | 133 |
137 // Schedules an update to be run 'soon'. | 134 // Schedules an update to be run 'soon'. |
138 void ScheduleUpdate(); | 135 void ScheduleUpdate(); |
139 | 136 |
140 // If an update is scheduled but not yet started, this resets the timer | 137 // If an update is scheduled but not yet started, this resets the timer |
141 // delaying the start time by a 'small' amount. | 138 // delaying the start time by a 'small' amount. |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
196 // This must be called when the status() is ACTIVATED. | 193 // This must be called when the status() is ACTIVATED. |
197 void DispatchPushEvent(const StatusCallback& callback, | 194 void DispatchPushEvent(const StatusCallback& callback, |
198 const std::string& data); | 195 const std::string& data); |
199 | 196 |
200 // These are expected to be called when a renderer process host for the | 197 // These are expected to be called when a renderer process host for the |
201 // same-origin as for this ServiceWorkerVersion is created. The added | 198 // same-origin as for this ServiceWorkerVersion is created. The added |
202 // processes are used to run an in-renderer embedded worker. | 199 // processes are used to run an in-renderer embedded worker. |
203 void AddProcessToWorker(int process_id); | 200 void AddProcessToWorker(int process_id); |
204 void RemoveProcessFromWorker(int process_id); | 201 void RemoveProcessFromWorker(int process_id); |
205 | 202 |
206 // Returns true if this has at least one process to run. | |
207 bool HasProcessToRun() const; | |
208 | |
209 // Adds and removes |provider_host| as a controllee of this ServiceWorker. | 203 // Adds and removes |provider_host| as a controllee of this ServiceWorker. |
210 // A potential controllee is a host having the version as its .installing | 204 // A potential controllee is a host having the version as its .installing |
211 // or .waiting version. | 205 // or .waiting version. |
212 void AddControllee(ServiceWorkerProviderHost* provider_host); | 206 void AddControllee(ServiceWorkerProviderHost* provider_host); |
213 void RemoveControllee(ServiceWorkerProviderHost* provider_host); | 207 void RemoveControllee(ServiceWorkerProviderHost* provider_host); |
214 void AddPotentialControllee(ServiceWorkerProviderHost* provider_host); | 208 void AddPotentialControllee(ServiceWorkerProviderHost* provider_host); |
215 void RemovePotentialControllee(ServiceWorkerProviderHost* provider_host); | 209 void RemovePotentialControllee(ServiceWorkerProviderHost* provider_host); |
216 | 210 |
211 // Notifies process manager about the callback pending renderer processes. | |
212 void AddPendingProcesses(const std::vector<int>& pending_processes); | |
213 | |
217 // Returns if it has controllee. | 214 // Returns if it has controllee. |
218 bool HasControllee() const { return !controllee_map_.empty(); } | 215 bool HasControllee() const { return !controllee_map_.empty(); } |
219 | 216 |
220 // Adds and removes Listeners. | 217 // Adds and removes Listeners. |
221 void AddListener(Listener* listener); | 218 void AddListener(Listener* listener); |
222 void RemoveListener(Listener* listener); | 219 void RemoveListener(Listener* listener); |
223 | 220 |
224 ServiceWorkerScriptCacheMap* script_cache_map() { return &script_cache_map_; } | 221 ServiceWorkerScriptCacheMap* script_cache_map() { return &script_cache_map_; } |
225 EmbeddedWorkerInstance* embedded_worker() { return embedded_worker_.get(); } | 222 EmbeddedWorkerInstance* embedded_worker() { return embedded_worker_.get(); } |
226 | 223 |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
307 bool is_doomed_; | 304 bool is_doomed_; |
308 | 305 |
309 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; | 306 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; |
310 | 307 |
311 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); | 308 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); |
312 }; | 309 }; |
313 | 310 |
314 } // namespace content | 311 } // namespace content |
315 | 312 |
316 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 313 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
OLD | NEW |