| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 const base::string16& error_message, | 77 const base::string16& error_message, |
| 78 int line_number, | 78 int line_number, |
| 79 int column_number, | 79 int column_number, |
| 80 const GURL& source_url) {}; | 80 const GURL& source_url) {}; |
| 81 virtual void OnReportConsoleMessage(ServiceWorkerVersion* version, | 81 virtual void OnReportConsoleMessage(ServiceWorkerVersion* version, |
| 82 int source_identifier, | 82 int source_identifier, |
| 83 int message_level, | 83 int message_level, |
| 84 const base::string16& message, | 84 const base::string16& message, |
| 85 int line_number, | 85 int line_number, |
| 86 const GURL& source_url) {}; | 86 const GURL& source_url) {}; |
| 87 virtual void OnNoControllees(ServiceWorkerVersion* version) {}; | |
| 88 }; | 87 }; |
| 89 | 88 |
| 90 ServiceWorkerVersion( | 89 ServiceWorkerVersion( |
| 91 ServiceWorkerRegistration* registration, | 90 ServiceWorkerRegistration* registration, |
| 92 int64 version_id, | 91 int64 version_id, |
| 93 base::WeakPtr<ServiceWorkerContextCore> context); | 92 base::WeakPtr<ServiceWorkerContextCore> context); |
| 94 | 93 |
| 95 int64 version_id() const { return version_id_; } | 94 int64 version_id() const { return version_id_; } |
| 96 int64 registration_id() const { return registration_id_; } | 95 int64 registration_id() const { return registration_id_; } |
| 97 const GURL& script_url() const { return script_url_; } | 96 const GURL& script_url() const { return script_url_; } |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 // Returns if it has controllee. | 210 // Returns if it has controllee. |
| 212 bool HasControllee() const { return !controllee_map_.empty(); } | 211 bool HasControllee() const { return !controllee_map_.empty(); } |
| 213 | 212 |
| 214 // Adds and removes Listeners. | 213 // Adds and removes Listeners. |
| 215 void AddListener(Listener* listener); | 214 void AddListener(Listener* listener); |
| 216 void RemoveListener(Listener* listener); | 215 void RemoveListener(Listener* listener); |
| 217 | 216 |
| 218 ServiceWorkerScriptCacheMap* script_cache_map() { return &script_cache_map_; } | 217 ServiceWorkerScriptCacheMap* script_cache_map() { return &script_cache_map_; } |
| 219 EmbeddedWorkerInstance* embedded_worker() { return embedded_worker_.get(); } | 218 EmbeddedWorkerInstance* embedded_worker() { return embedded_worker_.get(); } |
| 220 | 219 |
| 220 // Dooms this version to have REDUNDANT status and its resources deleted. If |
| 221 // the version is controlling a page, these changes will happen when the |
| 222 // version no longer controls any pages. |
| 223 void Doom(); |
| 224 |
| 221 private: | 225 private: |
| 222 typedef ServiceWorkerVersion self; | 226 typedef ServiceWorkerVersion self; |
| 223 typedef std::map<ServiceWorkerProviderHost*, int> ControlleeMap; | 227 typedef std::map<ServiceWorkerProviderHost*, int> ControlleeMap; |
| 224 typedef IDMap<ServiceWorkerProviderHost> ControlleeByIDMap; | 228 typedef IDMap<ServiceWorkerProviderHost> ControlleeByIDMap; |
| 225 friend class base::RefCounted<ServiceWorkerVersion>; | 229 friend class base::RefCounted<ServiceWorkerVersion>; |
| 226 | 230 |
| 227 virtual ~ServiceWorkerVersion(); | 231 virtual ~ServiceWorkerVersion(); |
| 228 | 232 |
| 229 // EmbeddedWorkerInstance::Listener overrides: | 233 // EmbeddedWorkerInstance::Listener overrides: |
| 230 virtual void OnStarted() OVERRIDE; | 234 virtual void OnStarted() OVERRIDE; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 255 void OnFetchEventFinished(int request_id, | 259 void OnFetchEventFinished(int request_id, |
| 256 ServiceWorkerFetchEventResult result, | 260 ServiceWorkerFetchEventResult result, |
| 257 const ServiceWorkerResponse& response); | 261 const ServiceWorkerResponse& response); |
| 258 void OnSyncEventFinished(int request_id); | 262 void OnSyncEventFinished(int request_id); |
| 259 void OnPushEventFinished(int request_id); | 263 void OnPushEventFinished(int request_id); |
| 260 void OnPostMessageToDocument(int client_id, | 264 void OnPostMessageToDocument(int client_id, |
| 261 const base::string16& message, | 265 const base::string16& message, |
| 262 const std::vector<int>& sent_message_port_ids); | 266 const std::vector<int>& sent_message_port_ids); |
| 263 | 267 |
| 264 void ScheduleStopWorker(); | 268 void ScheduleStopWorker(); |
| 269 void DoomInternal(); |
| 265 | 270 |
| 266 const int64 version_id_; | 271 const int64 version_id_; |
| 267 int64 registration_id_; | 272 int64 registration_id_; |
| 268 GURL script_url_; | 273 GURL script_url_; |
| 269 GURL scope_; | 274 GURL scope_; |
| 270 Status status_; | 275 Status status_; |
| 271 scoped_ptr<EmbeddedWorkerInstance> embedded_worker_; | 276 scoped_ptr<EmbeddedWorkerInstance> embedded_worker_; |
| 272 std::vector<StatusCallback> start_callbacks_; | 277 std::vector<StatusCallback> start_callbacks_; |
| 273 std::vector<StatusCallback> stop_callbacks_; | 278 std::vector<StatusCallback> stop_callbacks_; |
| 274 std::vector<base::Closure> status_change_callbacks_; | 279 std::vector<base::Closure> status_change_callbacks_; |
| 275 | 280 |
| 276 // Message callbacks. | 281 // Message callbacks. |
| 277 IDMap<StatusCallback, IDMapOwnPointer> activate_callbacks_; | 282 IDMap<StatusCallback, IDMapOwnPointer> activate_callbacks_; |
| 278 IDMap<StatusCallback, IDMapOwnPointer> install_callbacks_; | 283 IDMap<StatusCallback, IDMapOwnPointer> install_callbacks_; |
| 279 IDMap<FetchCallback, IDMapOwnPointer> fetch_callbacks_; | 284 IDMap<FetchCallback, IDMapOwnPointer> fetch_callbacks_; |
| 280 IDMap<StatusCallback, IDMapOwnPointer> sync_callbacks_; | 285 IDMap<StatusCallback, IDMapOwnPointer> sync_callbacks_; |
| 281 IDMap<StatusCallback, IDMapOwnPointer> push_callbacks_; | 286 IDMap<StatusCallback, IDMapOwnPointer> push_callbacks_; |
| 282 | 287 |
| 283 ControlleeMap controllee_map_; | 288 ControlleeMap controllee_map_; |
| 284 ControlleeByIDMap controllee_by_id_; | 289 ControlleeByIDMap controllee_by_id_; |
| 285 base::WeakPtr<ServiceWorkerContextCore> context_; | 290 base::WeakPtr<ServiceWorkerContextCore> context_; |
| 286 ObserverList<Listener> listeners_; | 291 ObserverList<Listener> listeners_; |
| 287 ServiceWorkerScriptCacheMap script_cache_map_; | 292 ServiceWorkerScriptCacheMap script_cache_map_; |
| 288 base::OneShotTimer<ServiceWorkerVersion> stop_worker_timer_; | 293 base::OneShotTimer<ServiceWorkerVersion> stop_worker_timer_; |
| 289 base::OneShotTimer<ServiceWorkerVersion> update_timer_; | 294 base::OneShotTimer<ServiceWorkerVersion> update_timer_; |
| 295 bool is_doomed_; |
| 290 | 296 |
| 291 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; | 297 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; |
| 292 | 298 |
| 293 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); | 299 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); |
| 294 }; | 300 }; |
| 295 | 301 |
| 296 } // namespace content | 302 } // namespace content |
| 297 | 303 |
| 298 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 304 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
| OLD | NEW |