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 <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "content/browser/service_worker/service_worker_registration.h" | 13 #include "content/browser/service_worker/service_worker_registration.h" |
14 #include "content/browser/service_worker/service_worker_version.h" | 14 #include "content/browser/service_worker/service_worker_version.h" |
| 15 #include "content/common/content_export.h" |
15 #include "content/common/service_worker/service_worker_types.h" | 16 #include "content/common/service_worker/service_worker_types.h" |
16 | 17 |
17 namespace content { | 18 namespace content { |
18 | 19 |
19 class ServiceWorkerContextCore; | 20 class ServiceWorkerContextCore; |
20 class ServiceWorkerVersion; | 21 class ServiceWorkerVersion; |
21 | 22 |
22 // Roughly corresponds to one WebServiceWorkerRegistration object in the | 23 // Roughly corresponds to one WebServiceWorkerRegistration object in the |
23 // renderer process. | 24 // renderer process. |
24 // | 25 // |
25 // The renderer process maintains the reference count by owning a | 26 // The renderer process maintains the reference count by owning a |
26 // ServiceWorkerRegistrationHandleReference for each reference it has to the | 27 // ServiceWorkerRegistrationHandleReference for each reference it has to the |
27 // registration object. ServiceWorkerRegistrationHandleReference creation and | 28 // registration object. ServiceWorkerRegistrationHandleReference creation and |
28 // destruction sends an IPC to the browser process, which adjusts the | 29 // destruction sends an IPC to the browser process, which adjusts the |
29 // ServiceWorkerRegistrationHandle refcount. | 30 // ServiceWorkerRegistrationHandle refcount. |
30 // | 31 // |
31 // Has a reference to the corresponding ServiceWorkerRegistration in order to | 32 // Has a reference to the corresponding ServiceWorkerRegistration in order to |
32 // ensure that the registration is alive while this handle is around. | 33 // ensure that the registration is alive while this handle is around. |
33 class ServiceWorkerRegistrationHandle | 34 class CONTENT_EXPORT ServiceWorkerRegistrationHandle |
34 : public ServiceWorkerRegistration::Listener { | 35 : public ServiceWorkerRegistration::Listener { |
35 public: | 36 public: |
36 CONTENT_EXPORT ServiceWorkerRegistrationHandle( | 37 ServiceWorkerRegistrationHandle( |
37 base::WeakPtr<ServiceWorkerContextCore> context, | 38 base::WeakPtr<ServiceWorkerContextCore> context, |
38 base::WeakPtr<ServiceWorkerProviderHost> provider_host, | 39 base::WeakPtr<ServiceWorkerProviderHost> provider_host, |
39 ServiceWorkerRegistration* registration); | 40 ServiceWorkerRegistration* registration); |
40 virtual ~ServiceWorkerRegistrationHandle(); | 41 virtual ~ServiceWorkerRegistrationHandle(); |
41 | 42 |
42 ServiceWorkerRegistrationObjectInfo GetObjectInfo(); | 43 ServiceWorkerRegistrationObjectInfo GetObjectInfo(); |
43 | 44 |
44 bool HasNoRefCount() const { return ref_count_ <= 0; } | 45 bool HasNoRefCount() const { return ref_count_ <= 0; } |
45 void IncrementRefCount(); | 46 void IncrementRefCount(); |
46 void DecrementRefCount(); | 47 void DecrementRefCount(); |
(...skipping 28 matching lines...) Expand all Loading... |
75 | 76 |
76 // This handle is the primary owner of this registration. | 77 // This handle is the primary owner of this registration. |
77 scoped_refptr<ServiceWorkerRegistration> registration_; | 78 scoped_refptr<ServiceWorkerRegistration> registration_; |
78 | 79 |
79 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegistrationHandle); | 80 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegistrationHandle); |
80 }; | 81 }; |
81 | 82 |
82 } // namespace content | 83 } // namespace content |
83 | 84 |
84 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_HANDLE_H_ | 85 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_HANDLE_H_ |
OLD | NEW |