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