Add ICU message format support
[chromium-blink-merge.git] / content / browser / service_worker / service_worker_registration_handle.h
blob882c7ccb0c68a1c0f31515788ed34c4e45a495e3
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_HANDLE_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_HANDLE_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/memory/weak_ptr.h"
11 #include "content/browser/service_worker/service_worker_registration.h"
12 #include "content/browser/service_worker/service_worker_version.h"
13 #include "content/common/service_worker/service_worker_types.h"
15 namespace content {
17 class ServiceWorkerContextCore;
18 class ServiceWorkerDispatcherHost;
19 class ServiceWorkerVersion;
21 // Roughly Corresponds to one ServiceWorkerRegistration object in the renderer
22 // process (WebServiceWorkerRegistrationImpl).
23 // Has references to the corresponding ServiceWorkerRegistration and
24 // ServiceWorkerVersions (therefore they're guaranteed to be alive while this
25 // handle is around).
26 class ServiceWorkerRegistrationHandle
27 : public ServiceWorkerRegistration::Listener {
28 public:
29 CONTENT_EXPORT ServiceWorkerRegistrationHandle(
30 base::WeakPtr<ServiceWorkerContextCore> context,
31 base::WeakPtr<ServiceWorkerProviderHost> provider_host,
32 ServiceWorkerRegistration* registration);
33 virtual ~ServiceWorkerRegistrationHandle();
35 ServiceWorkerRegistrationObjectInfo GetObjectInfo();
37 bool HasNoRefCount() const { return ref_count_ <= 0; }
38 void IncrementRefCount();
39 void DecrementRefCount();
41 int provider_id() const { return provider_id_; }
42 int handle_id() const { return handle_id_; }
44 ServiceWorkerRegistration* registration() { return registration_.get(); }
46 private:
47 // ServiceWorkerRegistration::Listener overrides.
48 void OnVersionAttributesChanged(
49 ServiceWorkerRegistration* registration,
50 ChangedVersionAttributesMask changed_mask,
51 const ServiceWorkerRegistrationInfo& info) override;
52 void OnRegistrationFailed(ServiceWorkerRegistration* registration) override;
53 void OnUpdateFound(ServiceWorkerRegistration* registration) override;
55 // Sets the corresponding version field to the given version or if the given
56 // version is nullptr, clears the field.
57 void SetVersionAttributes(
58 ChangedVersionAttributesMask changed_mask,
59 ServiceWorkerVersion* installing_version,
60 ServiceWorkerVersion* waiting_version,
61 ServiceWorkerVersion* active_version);
63 base::WeakPtr<ServiceWorkerContextCore> context_;
64 base::WeakPtr<ServiceWorkerProviderHost> provider_host_;
65 const int provider_id_;
66 const int handle_id_;
67 int ref_count_; // Created with 1.
69 scoped_refptr<ServiceWorkerRegistration> registration_;
71 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegistrationHandle);
74 } // namespace content
76 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_HANDLE_H_