Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: content/browser/service_worker/service_worker_registration_handle.h

Issue 463013002: ServiceWorker: Implement updatefound event and version attributes (Chromium) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address for comments Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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.
4
5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_HANDLE_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_HANDLE_H_
7
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"
14
15 namespace content {
16
17 class ServiceWorkerContextCore;
18 class ServiceWorkerDispatcherHost;
19 class ServiceWorkerVersion;
20
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 ServiceWorkerRegistrationHandle(
30 base::WeakPtr<ServiceWorkerContextCore> context,
31 ServiceWorkerDispatcherHost* dispatcher_host,
32 int provider_id,
33 ServiceWorkerRegistration* registration);
34 virtual ~ServiceWorkerRegistrationHandle();
35
36 bool HasNoRefCount() const { return ref_count_ <= 0; }
37 void IncrementRefCount();
38 void DecrementRefCount();
39
40 int provider_id() const { return provider_id_; }
41 int handle_id() const { return handle_id_; }
42
43 ServiceWorkerRegistration* registration() { return registration_.get(); }
44
45 private:
46 // ServiceWorkerRegistration::Listener overrides.
47 virtual void OnVersionAttributesChanged(
48 ServiceWorkerRegistration* registration,
49 ChangedVersionAttributesMask changed_mask,
50 const ServiceWorkerRegistrationInfo& info) OVERRIDE;
51 virtual void OnRegistrationFailed(
52 ServiceWorkerRegistration* registration) OVERRIDE;
53
54 // Sets the corresponding version field to the given version or if the given
55 // version is NULL, clears the field.
56 void SetVersionAttributes(
57 ServiceWorkerVersion* installing_version,
58 ServiceWorkerVersion* waiting_version,
59 ServiceWorkerVersion* active_version);
60
61 // Clears all version fields.
62 void ClearVersionAttributes();
63
64 ServiceWorkerObjectInfo CreateServiceWorkerHandleAndPass(
65 ServiceWorkerVersion* version);
66
67 base::WeakPtr<ServiceWorkerContextCore> context_;
68 ServiceWorkerDispatcherHost* dispatcher_host_;
69 const int provider_id_;
70 const int handle_id_;
71 int ref_count_; // Created with 1.
72
73 scoped_refptr<ServiceWorkerRegistration> registration_;
74 scoped_refptr<ServiceWorkerVersion> installing_version_;
75 scoped_refptr<ServiceWorkerVersion> waiting_version_;
76 scoped_refptr<ServiceWorkerVersion> active_version_;
77
78 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegistrationHandle);
79 };
80
81 } // namespace content
82
83 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_HANDLE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698