| 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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 NEW, // The version is just created. | 63 NEW, // The version is just created. |
| 64 INSTALLING, // Install event is dispatched and being handled. | 64 INSTALLING, // Install event is dispatched and being handled. |
| 65 INSTALLED, // Install event is finished and is ready to be activated. | 65 INSTALLED, // Install event is finished and is ready to be activated. |
| 66 ACTIVATING, // Activate event is dispatched and being handled. | 66 ACTIVATING, // Activate event is dispatched and being handled. |
| 67 ACTIVE, // Activation is finished and can run as active. | 67 ACTIVE, // Activation is finished and can run as active. |
| 68 DEACTIVATED, // The version is no longer running as active, due to | 68 DEACTIVATED, // The version is no longer running as active, due to |
| 69 // unregistration or replace. (TODO(kinuko): we may need | 69 // unregistration or replace. (TODO(kinuko): we may need |
| 70 // different states for different termination sequences) | 70 // different states for different termination sequences) |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 class Listener { | 73 class CONTENT_EXPORT Listener { |
| 74 public: | 74 public: |
| 75 virtual void OnWorkerStarted(ServiceWorkerVersion* version) = 0; | 75 virtual void OnWorkerStarted(ServiceWorkerVersion* version) = 0; |
| 76 virtual void OnWorkerStopped(ServiceWorkerVersion* version) = 0; | 76 virtual void OnWorkerStopped(ServiceWorkerVersion* version) = 0; |
| 77 virtual void OnVersionStateChanged(ServiceWorkerVersion* version) = 0; | 77 virtual void OnVersionStateChanged(ServiceWorkerVersion* version) = 0; |
| 78 virtual void OnErrorReported(ServiceWorkerVersion* version, | 78 virtual void OnErrorReported(ServiceWorkerVersion* version, |
| 79 const base::string16& error_message, | 79 const base::string16& error_message, |
| 80 int line_number, | 80 int line_number, |
| 81 int column_number, | 81 int column_number, |
| 82 const GURL& source_url) = 0; | 82 const GURL& source_url) = 0; |
| 83 virtual void OnReportConsoleMessage(ServiceWorkerVersion* version, | 83 virtual void OnReportConsoleMessage(ServiceWorkerVersion* version, |
| 84 int source_identifier, | 84 int source_identifier, |
| 85 int message_level, | 85 int message_level, |
| 86 const base::string16& message, | 86 const base::string16& message, |
| 87 int line_number, | 87 int line_number, |
| 88 const GURL& source_url) = 0; | 88 const GURL& source_url) = 0; |
| 89 virtual void OnMainScriptCacheResult(ServiceWorkerVersion* version, |
| 90 bool success) {} |
| 89 }; | 91 }; |
| 90 | 92 |
| 91 ServiceWorkerVersion( | 93 ServiceWorkerVersion( |
| 92 ServiceWorkerRegistration* registration, | 94 ServiceWorkerRegistration* registration, |
| 93 int64 version_id, | 95 int64 version_id, |
| 94 base::WeakPtr<ServiceWorkerContextCore> context); | 96 base::WeakPtr<ServiceWorkerContextCore> context); |
| 95 | 97 |
| 96 int64 version_id() const { return version_id_; } | 98 int64 version_id() const { return version_id_; } |
| 97 int64 registration_id() const { return registration_id_; } | 99 int64 registration_id() const { return registration_id_; } |
| 98 | 100 |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 virtual void OnReportConsoleMessage(int source_identifier, | 210 virtual void OnReportConsoleMessage(int source_identifier, |
| 209 int message_level, | 211 int message_level, |
| 210 const base::string16& message, | 212 const base::string16& message, |
| 211 int line_number, | 213 int line_number, |
| 212 const GURL& source_url) OVERRIDE; | 214 const GURL& source_url) OVERRIDE; |
| 213 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 215 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 214 | 216 |
| 215 void AddToScriptCache(const GURL& url, int64 resource_id); | 217 void AddToScriptCache(const GURL& url, int64 resource_id); |
| 216 int64 LookupInScriptCache(const GURL& url); | 218 int64 LookupInScriptCache(const GURL& url); |
| 217 | 219 |
| 220 // Propagates to to Listeners. |
| 221 void NotifyMainScriptCacheResult(bool success); |
| 222 |
| 218 private: | 223 private: |
| 219 typedef ServiceWorkerVersion self; | 224 typedef ServiceWorkerVersion self; |
| 220 typedef std::map<ServiceWorkerProviderHost*, int> ControlleeMap; | 225 typedef std::map<ServiceWorkerProviderHost*, int> ControlleeMap; |
| 221 typedef IDMap<ServiceWorkerProviderHost> ControlleeByIDMap; | 226 typedef IDMap<ServiceWorkerProviderHost> ControlleeByIDMap; |
| 222 typedef std::map<GURL, int64> ResourceIDMap; | 227 typedef std::map<GURL, int64> ResourceIDMap; |
| 223 friend class base::RefCounted<ServiceWorkerVersion>; | 228 friend class base::RefCounted<ServiceWorkerVersion>; |
| 224 | 229 |
| 225 virtual ~ServiceWorkerVersion(); | 230 virtual ~ServiceWorkerVersion(); |
| 226 | 231 |
| 227 void RunStartWorkerCallbacksOnError(ServiceWorkerStatusCode status); | 232 void RunStartWorkerCallbacksOnError(ServiceWorkerStatusCode status); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 ResourceIDMap script_cache_map_; | 270 ResourceIDMap script_cache_map_; |
| 266 | 271 |
| 267 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; | 272 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; |
| 268 | 273 |
| 269 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); | 274 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); |
| 270 }; | 275 }; |
| 271 | 276 |
| 272 } // namespace content | 277 } // namespace content |
| 273 | 278 |
| 274 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 279 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
| OLD | NEW |