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