OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_REGISTRATION_HANDLE_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_HANDLE_H_ |
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_HANDLE_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_HANDLE_H_ |
7 | 7 |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/weak_ptr.h" | 10 #include "base/memory/weak_ptr.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 : public ServiceWorkerRegistration::Listener { | 27 : public ServiceWorkerRegistration::Listener { |
28 public: | 28 public: |
29 CONTENT_EXPORT ServiceWorkerRegistrationHandle( | 29 CONTENT_EXPORT ServiceWorkerRegistrationHandle( |
30 base::WeakPtr<ServiceWorkerContextCore> context, | 30 base::WeakPtr<ServiceWorkerContextCore> context, |
31 ServiceWorkerDispatcherHost* dispatcher_host, | 31 ServiceWorkerDispatcherHost* dispatcher_host, |
32 int provider_id, | 32 int provider_id, |
33 ServiceWorkerRegistration* registration); | 33 ServiceWorkerRegistration* registration); |
34 virtual ~ServiceWorkerRegistrationHandle(); | 34 virtual ~ServiceWorkerRegistrationHandle(); |
35 | 35 |
36 ServiceWorkerRegistrationObjectInfo GetObjectInfo(); | 36 ServiceWorkerRegistrationObjectInfo GetObjectInfo(); |
| 37 ServiceWorkerObjectInfo CreateServiceWorkerHandleAndPass( |
| 38 ServiceWorkerVersion* version); |
37 | 39 |
38 bool HasNoRefCount() const { return ref_count_ <= 0; } | 40 bool HasNoRefCount() const { return ref_count_ <= 0; } |
39 void IncrementRefCount(); | 41 void IncrementRefCount(); |
40 void DecrementRefCount(); | 42 void DecrementRefCount(); |
41 | 43 |
42 int provider_id() const { return provider_id_; } | 44 int provider_id() const { return provider_id_; } |
43 int handle_id() const { return handle_id_; } | 45 int handle_id() const { return handle_id_; } |
44 | 46 |
45 ServiceWorkerRegistration* registration() { return registration_.get(); } | 47 ServiceWorkerRegistration* registration() { return registration_.get(); } |
46 | 48 |
47 private: | 49 private: |
48 // ServiceWorkerRegistration::Listener overrides. | 50 // ServiceWorkerRegistration::Listener overrides. |
49 virtual void OnVersionAttributesChanged( | 51 virtual void OnVersionAttributesChanged( |
50 ServiceWorkerRegistration* registration, | 52 ServiceWorkerRegistration* registration, |
51 ChangedVersionAttributesMask changed_mask, | 53 ChangedVersionAttributesMask changed_mask, |
52 const ServiceWorkerRegistrationInfo& info) OVERRIDE; | 54 const ServiceWorkerRegistrationInfo& info) OVERRIDE; |
53 virtual void OnRegistrationFailed( | 55 virtual void OnRegistrationFailed( |
54 ServiceWorkerRegistration* registration) OVERRIDE; | 56 ServiceWorkerRegistration* registration) OVERRIDE; |
| 57 virtual void OnUpdateFound( |
| 58 ServiceWorkerRegistration* registration) OVERRIDE; |
55 | 59 |
56 // Sets the corresponding version field to the given version or if the given | 60 // Sets the corresponding version field to the given version or if the given |
57 // version is NULL, clears the field. | 61 // version is NULL, clears the field. |
58 void SetVersionAttributes( | 62 void SetVersionAttributes( |
59 ServiceWorkerVersion* installing_version, | 63 ServiceWorkerVersion* installing_version, |
60 ServiceWorkerVersion* waiting_version, | 64 ServiceWorkerVersion* waiting_version, |
61 ServiceWorkerVersion* active_version); | 65 ServiceWorkerVersion* active_version); |
62 | 66 |
63 // Clears all version fields. | 67 // Clears all version fields. |
64 void ClearVersionAttributes(); | 68 void ClearVersionAttributes(); |
65 | 69 |
66 ServiceWorkerObjectInfo CreateServiceWorkerHandleAndPass( | |
67 ServiceWorkerVersion* version); | |
68 | |
69 base::WeakPtr<ServiceWorkerContextCore> context_; | 70 base::WeakPtr<ServiceWorkerContextCore> context_; |
70 ServiceWorkerDispatcherHost* dispatcher_host_; | 71 ServiceWorkerDispatcherHost* dispatcher_host_; |
71 const int provider_id_; | 72 const int provider_id_; |
72 const int handle_id_; | 73 const int handle_id_; |
73 int ref_count_; // Created with 1. | 74 int ref_count_; // Created with 1. |
74 | 75 |
75 scoped_refptr<ServiceWorkerRegistration> registration_; | 76 scoped_refptr<ServiceWorkerRegistration> registration_; |
76 scoped_refptr<ServiceWorkerVersion> installing_version_; | 77 scoped_refptr<ServiceWorkerVersion> installing_version_; |
77 scoped_refptr<ServiceWorkerVersion> waiting_version_; | 78 scoped_refptr<ServiceWorkerVersion> waiting_version_; |
78 scoped_refptr<ServiceWorkerVersion> active_version_; | 79 scoped_refptr<ServiceWorkerVersion> active_version_; |
79 | 80 |
80 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegistrationHandle); | 81 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegistrationHandle); |
81 }; | 82 }; |
82 | 83 |
83 } // namespace content | 84 } // namespace content |
84 | 85 |
85 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_HANDLE_H_ | 86 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_HANDLE_H_ |
OLD | NEW |