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

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

Issue 309453002: ServiceWorker: Rename 'pending version' to 'installing' or 'waiting' (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 6 years, 6 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 13 matching lines...) Expand all
24 // - Mapping of caches to registrations / versions 24 // - Mapping of caches to registrations / versions
25 // 25 //
26 // This is the place where we manage simultaneous 26 // This is the place where we manage simultaneous
27 // requests for the same registrations and caches, making sure that 27 // requests for the same registrations and caches, making sure that
28 // two pages that are registering the same pattern at the same time 28 // two pages that are registering the same pattern at the same time
29 // have their registrations coalesced rather than overwriting each 29 // have their registrations coalesced rather than overwriting each
30 // other. 30 // other.
31 // 31 //
32 // This class also manages the state of the upgrade process, which 32 // This class also manages the state of the upgrade process, which
33 // includes managing which ServiceWorkerVersion is "active" vs "in 33 // includes managing which ServiceWorkerVersion is "active" vs "in
34 // waiting" (or "pending") 34 // waiting".
35 class CONTENT_EXPORT ServiceWorkerRegistration 35 class CONTENT_EXPORT ServiceWorkerRegistration
36 : NON_EXPORTED_BASE(public base::RefCounted<ServiceWorkerRegistration>) { 36 : NON_EXPORTED_BASE(public base::RefCounted<ServiceWorkerRegistration>) {
37 public: 37 public:
38 ServiceWorkerRegistration(const GURL& pattern, 38 ServiceWorkerRegistration(const GURL& pattern,
39 const GURL& script_url, 39 const GURL& script_url,
40 int64 registration_id, 40 int64 registration_id,
41 base::WeakPtr<ServiceWorkerContextCore> context); 41 base::WeakPtr<ServiceWorkerContextCore> context);
42 42
43 int64 id() const { return registration_id_; } 43 int64 id() const { return registration_id_; }
44 const GURL& script_url() const { return script_url_; } 44 const GURL& script_url() const { return script_url_; }
45 const GURL& pattern() const { return pattern_; } 45 const GURL& pattern() const { return pattern_; }
46 46
47 ServiceWorkerVersion* active_version() const { 47 ServiceWorkerVersion* active_version() const {
48 DCHECK(!is_shutdown_); 48 DCHECK(!is_shutdown_);
49 return active_version_.get(); 49 return active_version_.get();
50 } 50 }
51 51
52 ServiceWorkerVersion* pending_version() const { 52 ServiceWorkerVersion* waiting_version() const {
53 DCHECK(!is_shutdown_); 53 DCHECK(!is_shutdown_);
54 return pending_version_.get(); 54 return waiting_version_.get();
55 } 55 }
56 56
57 void set_active_version(ServiceWorkerVersion* version) { 57 void set_active_version(ServiceWorkerVersion* version) {
58 DCHECK(!is_shutdown_); 58 DCHECK(!is_shutdown_);
59 active_version_ = version; 59 active_version_ = version;
60 } 60 }
61 61
62 void set_pending_version(ServiceWorkerVersion* version) { 62 void set_waiting_version(ServiceWorkerVersion* version) {
63 DCHECK(!is_shutdown_); 63 DCHECK(!is_shutdown_);
64 pending_version_ = version; 64 waiting_version_ = version;
65 } 65 }
66 66
67 ServiceWorkerRegistrationInfo GetInfo(); 67 ServiceWorkerRegistrationInfo GetInfo();
68 68
69 // Returns the active version, if it is not null; otherwise, returns the 69 // Returns the active version, if it is not null; otherwise, returns the
70 // pending version. 70 // waiting version.
71 ServiceWorkerVersion* GetNewestVersion(); 71 ServiceWorkerVersion* GetNewestVersion();
72 72
73 // The final synchronous switchover after all events have been 73 // The final synchronous switchover after all events have been
74 // fired, and the old "active version" is being shut down. 74 // fired, and the old "active version" is being shut down.
75 void ActivatePendingVersion(); 75 void ActivateWaitingVersion();
76 76
77 private: 77 private:
78 ~ServiceWorkerRegistration(); 78 ~ServiceWorkerRegistration();
79 friend class base::RefCounted<ServiceWorkerRegistration>; 79 friend class base::RefCounted<ServiceWorkerRegistration>;
80 80
81 const GURL pattern_; 81 const GURL pattern_;
82 const GURL script_url_; 82 const GURL script_url_;
83 const int64 registration_id_; 83 const int64 registration_id_;
84 84
85 scoped_refptr<ServiceWorkerVersion> active_version_; 85 scoped_refptr<ServiceWorkerVersion> active_version_;
86 scoped_refptr<ServiceWorkerVersion> pending_version_; 86 scoped_refptr<ServiceWorkerVersion> waiting_version_;
87 87
88 bool is_shutdown_; 88 bool is_shutdown_;
89 base::WeakPtr<ServiceWorkerContextCore> context_; 89 base::WeakPtr<ServiceWorkerContextCore> context_;
90 90
91 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegistration); 91 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegistration);
92 }; 92 };
93 } // namespace content 93 } // namespace content
94 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_H_ 94 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698