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

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

Issue 380093002: Update installed ServiceWorkers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/gtest_prod_util.h" 9 #include "base/gtest_prod_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 18 matching lines...) Expand all
29 // two pages that are registering the same pattern at the same time 29 // two pages that are registering the same pattern at the same time
30 // have their registrations coalesced rather than overwriting each 30 // have their registrations coalesced rather than overwriting each
31 // other. 31 // other.
32 // 32 //
33 // This class also manages the state of the upgrade process, which 33 // This class also manages the state of the upgrade process, which
34 // includes managing which ServiceWorkerVersion is "active" vs "in 34 // includes managing which ServiceWorkerVersion is "active" vs "in
35 // waiting". 35 // waiting".
36 class CONTENT_EXPORT ServiceWorkerRegistration 36 class CONTENT_EXPORT ServiceWorkerRegistration
37 : NON_EXPORTED_BASE(public base::RefCounted<ServiceWorkerRegistration>) { 37 : NON_EXPORTED_BASE(public base::RefCounted<ServiceWorkerRegistration>) {
38 public: 38 public:
39 typedef base::Callback<void(ServiceWorkerStatusCode status)> StatusCallback;
39 40
40 class Listener { 41 class Listener {
41 public: 42 public:
42 virtual void OnVersionAttributesChanged( 43 virtual void OnVersionAttributesChanged(
43 ServiceWorkerRegistration* registration, 44 ServiceWorkerRegistration* registration,
44 ChangedVersionAttributesMask changed_mask, 45 ChangedVersionAttributesMask changed_mask,
45 const ServiceWorkerRegistrationInfo& info) = 0; 46 const ServiceWorkerRegistrationInfo& info) = 0;
46 }; 47 };
47 48
48 ServiceWorkerRegistration(const GURL& pattern, 49 ServiceWorkerRegistration(const GURL& pattern,
(...skipping 27 matching lines...) Expand all
76 // Also notifies listeners via OnVersionAttributesChanged. 77 // Also notifies listeners via OnVersionAttributesChanged.
77 void SetActiveVersion(ServiceWorkerVersion* version); 78 void SetActiveVersion(ServiceWorkerVersion* version);
78 void SetWaitingVersion(ServiceWorkerVersion* version); 79 void SetWaitingVersion(ServiceWorkerVersion* version);
79 void SetInstallingVersion(ServiceWorkerVersion* version); 80 void SetInstallingVersion(ServiceWorkerVersion* version);
80 81
81 // If version is the installing, waiting, active version of this 82 // If version is the installing, waiting, active version of this
82 // registation, the method will reset that field to NULL, and notify 83 // registation, the method will reset that field to NULL, and notify
83 // listeners via OnVersionAttributesChanged. 84 // listeners via OnVersionAttributesChanged.
84 void UnsetVersion(ServiceWorkerVersion* version); 85 void UnsetVersion(ServiceWorkerVersion* version);
85 86
87 void ActivateWaitingVersion(const StatusCallback& completion_callback);
88
86 private: 89 private:
87 ~ServiceWorkerRegistration(); 90 ~ServiceWorkerRegistration();
88 friend class base::RefCounted<ServiceWorkerRegistration>; 91 friend class base::RefCounted<ServiceWorkerRegistration>;
89 92
90 void SetVersionInternal( 93 void SetVersionInternal(
91 ServiceWorkerVersion* version, 94 ServiceWorkerVersion* version,
92 scoped_refptr<ServiceWorkerVersion>* data_member, 95 scoped_refptr<ServiceWorkerVersion>* data_member,
93 int change_flag); 96 int change_flag);
94 void UnsetVersionInternal( 97 void UnsetVersionInternal(
95 ServiceWorkerVersion* version, 98 ServiceWorkerVersion* version,
96 ChangedVersionAttributesMask* mask); 99 ChangedVersionAttributesMask* mask);
97 100
101 void OnActivateEventFinished(
102 ServiceWorkerVersion* activating_version,
103 const StatusCallback& completion_callback,
104 ServiceWorkerStatusCode status);
105
98 const GURL pattern_; 106 const GURL pattern_;
99 const GURL script_url_; 107 const GURL script_url_;
100 const int64 registration_id_; 108 const int64 registration_id_;
101 scoped_refptr<ServiceWorkerVersion> active_version_; 109 scoped_refptr<ServiceWorkerVersion> active_version_;
102 scoped_refptr<ServiceWorkerVersion> waiting_version_; 110 scoped_refptr<ServiceWorkerVersion> waiting_version_;
103 scoped_refptr<ServiceWorkerVersion> installing_version_; 111 scoped_refptr<ServiceWorkerVersion> installing_version_;
104 ObserverList<Listener> listeners_; 112 ObserverList<Listener> listeners_;
105 base::WeakPtr<ServiceWorkerContextCore> context_; 113 base::WeakPtr<ServiceWorkerContextCore> context_;
106 114
107 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegistration); 115 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegistration);
108 }; 116 };
109 } // namespace content 117 } // namespace content
110 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_H_ 118 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698