| 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 "base/basictypes.h" | 8 #include "base/basictypes.h" | 
| 9 #include "base/gtest_prod_util.h" | 9 #include "base/gtest_prod_util.h" | 
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" | 
|  | 11 #include "base/memory/scoped_ptr.h" | 
| 11 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" | 
| 12 | 13 | 
| 13 class GURL; | 14 class GURL; | 
| 14 | 15 | 
| 15 namespace content { | 16 namespace content { | 
| 16 | 17 | 
|  | 18 class EmbeddedWorkerInstance; | 
|  | 19 class EmbeddedWorkerRegistry; | 
|  | 20 class ServiceWorkerProviderHost; | 
| 17 class ServiceWorkerRegistration; | 21 class ServiceWorkerRegistration; | 
| 18 | 22 | 
| 19 // This class corresponds to a specific version of a ServiceWorker | 23 // This class corresponds to a specific version of a ServiceWorker | 
| 20 // script for a given pattern. When a script is upgraded, there may be | 24 // script for a given pattern. When a script is upgraded, there may be | 
| 21 // more than one ServiceWorkerVersion "running" at a time, but only | 25 // more than one ServiceWorkerVersion "running" at a time, but only | 
| 22 // one of them is active. This class connects the actual script with a | 26 // one of them is active. This class connects the actual script with a | 
| 23 // running worker. | 27 // running worker. | 
| 24 // Instances of this class are in one of two install states: | 28 // Instances of this class are in one of two install states: | 
| 25 // - Pending: The script is in the process of being installed. There | 29 // - Pending: The script is in the process of being installed. There | 
| 26 //            may be another active script running. | 30 //            may be another active script running. | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
| 44 // events. During the Active state, it can receive other events such | 48 // events. During the Active state, it can receive other events such | 
| 45 // as 'fetch'. | 49 // as 'fetch'. | 
| 46 // | 50 // | 
| 47 // And finally, is_shutdown_ is detects the live-ness of the object | 51 // And finally, is_shutdown_ is detects the live-ness of the object | 
| 48 // itself. If the object is shut down, then it is in the process of | 52 // itself. If the object is shut down, then it is in the process of | 
| 49 // being deleted from memory. This happens when a version is replaced | 53 // being deleted from memory. This happens when a version is replaced | 
| 50 // as well as at browser shutdown. | 54 // as well as at browser shutdown. | 
| 51 class CONTENT_EXPORT ServiceWorkerVersion | 55 class CONTENT_EXPORT ServiceWorkerVersion | 
| 52     : NON_EXPORTED_BASE(public base::RefCounted<ServiceWorkerVersion>) { | 56     : NON_EXPORTED_BASE(public base::RefCounted<ServiceWorkerVersion>) { | 
| 53  public: | 57  public: | 
| 54   explicit ServiceWorkerVersion(ServiceWorkerRegistration* registration); | 58   ServiceWorkerVersion( | 
|  | 59       ServiceWorkerRegistration* registration, | 
|  | 60       EmbeddedWorkerRegistry* worker_registry, | 
|  | 61       int64 version_id); | 
|  | 62 | 
|  | 63   int64 version_id() const { return version_id_; } | 
| 55 | 64 | 
| 56   void Shutdown(); | 65   void Shutdown(); | 
| 57   bool is_shutdown() const { return is_shutdown_; } | 66   bool is_shutdown() const { return is_shutdown_; } | 
| 58 | 67 | 
|  | 68   // Starts and stops an embedded worker for this version. | 
|  | 69   void StartWorker(); | 
|  | 70   void StopWorker(); | 
|  | 71 | 
|  | 72   // Called when this version is associated to a provider host. | 
|  | 73   // Non-null |provider_host| must be given. | 
|  | 74   void OnAssociateProvider(ServiceWorkerProviderHost* provider_host); | 
|  | 75   void OnUnassociateProvider(ServiceWorkerProviderHost* provider_host); | 
|  | 76 | 
| 59  private: | 77  private: | 
|  | 78   friend class base::RefCounted<ServiceWorkerVersion>; | 
|  | 79 | 
| 60   ~ServiceWorkerVersion(); | 80   ~ServiceWorkerVersion(); | 
| 61   friend class base::RefCounted<ServiceWorkerVersion>; | 81 | 
|  | 82   const int64 version_id_; | 
| 62 | 83 | 
| 63   bool is_shutdown_; | 84   bool is_shutdown_; | 
| 64   scoped_refptr<ServiceWorkerRegistration> registration_; | 85   scoped_refptr<ServiceWorkerRegistration> registration_; | 
| 65 | 86 | 
|  | 87   scoped_ptr<EmbeddedWorkerInstance> embedded_worker_; | 
|  | 88 | 
| 66   DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); | 89   DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); | 
| 67 }; | 90 }; | 
|  | 91 | 
| 68 }  // namespace content | 92 }  // namespace content | 
|  | 93 | 
| 69 #endif  // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 94 #endif  // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 
| OLD | NEW | 
|---|