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