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 <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 20 matching lines...) Expand all Loading... |
31 class ServiceWorkerContextCore; | 31 class ServiceWorkerContextCore; |
32 class ServiceWorkerProviderHost; | 32 class ServiceWorkerProviderHost; |
33 class ServiceWorkerRegistration; | 33 class ServiceWorkerRegistration; |
34 class ServiceWorkerVersionInfo; | 34 class ServiceWorkerVersionInfo; |
35 | 35 |
36 // This class corresponds to a specific version of a ServiceWorker | 36 // This class corresponds to a specific version of a ServiceWorker |
37 // script for a given pattern. When a script is upgraded, there may be | 37 // script for a given pattern. When a script is upgraded, there may be |
38 // more than one ServiceWorkerVersion "running" at a time, but only | 38 // more than one ServiceWorkerVersion "running" at a time, but only |
39 // one of them is active. This class connects the actual script with a | 39 // one of them is active. This class connects the actual script with a |
40 // running worker. | 40 // running worker. |
41 // | |
42 // is_shutdown_ detects the live-ness of the object itself. If the object is | |
43 // shut down, then it is in the process of being deleted from memory. | |
44 // This happens when a version is replaced as well as at browser shutdown. | |
45 class CONTENT_EXPORT ServiceWorkerVersion | 41 class CONTENT_EXPORT ServiceWorkerVersion |
46 : NON_EXPORTED_BASE(public base::RefCounted<ServiceWorkerVersion>), | 42 : NON_EXPORTED_BASE(public base::RefCounted<ServiceWorkerVersion>), |
47 public EmbeddedWorkerInstance::Listener { | 43 public EmbeddedWorkerInstance::Listener { |
48 public: | 44 public: |
49 typedef base::Callback<void(ServiceWorkerStatusCode)> StatusCallback; | 45 typedef base::Callback<void(ServiceWorkerStatusCode)> StatusCallback; |
50 typedef base::Callback<void(ServiceWorkerStatusCode, | 46 typedef base::Callback<void(ServiceWorkerStatusCode, |
51 const IPC::Message& message)> MessageCallback; | 47 const IPC::Message& message)> MessageCallback; |
52 typedef base::Callback<void(ServiceWorkerStatusCode, | 48 typedef base::Callback<void(ServiceWorkerStatusCode, |
53 ServiceWorkerFetchEventResult, | 49 ServiceWorkerFetchEventResult, |
54 const ServiceWorkerResponse&)> FetchCallback; | 50 const ServiceWorkerResponse&)> FetchCallback; |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 // These are expected to be called when a renderer process host for the | 194 // These are expected to be called when a renderer process host for the |
199 // same-origin as for this ServiceWorkerVersion is created. The added | 195 // same-origin as for this ServiceWorkerVersion is created. The added |
200 // processes are used to run an in-renderer embedded worker. | 196 // processes are used to run an in-renderer embedded worker. |
201 void AddProcessToWorker(int process_id); | 197 void AddProcessToWorker(int process_id); |
202 void RemoveProcessFromWorker(int process_id); | 198 void RemoveProcessFromWorker(int process_id); |
203 | 199 |
204 // Returns true if this has at least one process to run. | 200 // Returns true if this has at least one process to run. |
205 bool HasProcessToRun() const; | 201 bool HasProcessToRun() const; |
206 | 202 |
207 // Adds and removes |provider_host| as a controllee of this ServiceWorker. | 203 // Adds and removes |provider_host| as a controllee of this ServiceWorker. |
| 204 // A potential controllee is a host having the version as its .installing |
| 205 // or .waiting version. |
208 void AddControllee(ServiceWorkerProviderHost* provider_host); | 206 void AddControllee(ServiceWorkerProviderHost* provider_host); |
209 void RemoveControllee(ServiceWorkerProviderHost* provider_host); | 207 void RemoveControllee(ServiceWorkerProviderHost* provider_host); |
210 void AddWaitingControllee(ServiceWorkerProviderHost* provider_host); | 208 void AddPotentialControllee(ServiceWorkerProviderHost* provider_host); |
211 void RemoveWaitingControllee(ServiceWorkerProviderHost* provider_host); | 209 void RemovePotentialControllee(ServiceWorkerProviderHost* provider_host); |
212 | 210 |
213 // Returns if it has controllee. | 211 // Returns if it has controllee. |
214 bool HasControllee() const { return !controllee_map_.empty(); } | 212 bool HasControllee() const { return !controllee_map_.empty(); } |
215 | 213 |
216 // Adds and removes Listeners. | 214 // Adds and removes Listeners. |
217 void AddListener(Listener* listener); | 215 void AddListener(Listener* listener); |
218 void RemoveListener(Listener* listener); | 216 void RemoveListener(Listener* listener); |
219 | 217 |
220 ServiceWorkerScriptCacheMap* script_cache_map() { return &script_cache_map_; } | 218 ServiceWorkerScriptCacheMap* script_cache_map() { return &script_cache_map_; } |
221 EmbeddedWorkerInstance* embedded_worker() { return embedded_worker_.get(); } | 219 EmbeddedWorkerInstance* embedded_worker() { return embedded_worker_.get(); } |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 base::OneShotTimer<ServiceWorkerVersion> update_timer_; | 289 base::OneShotTimer<ServiceWorkerVersion> update_timer_; |
292 | 290 |
293 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; | 291 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; |
294 | 292 |
295 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); | 293 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); |
296 }; | 294 }; |
297 | 295 |
298 } // namespace content | 296 } // namespace content |
299 | 297 |
300 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 298 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
OLD | NEW |