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

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

Issue 70683002: Stub out ServiceWorkerRegistration and Version classes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Switch all parameters to raw pointers Created 7 years, 1 month 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 (c) 2013 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_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_H_
7
8 #include "base/basictypes.h"
9 #include "base/gtest_prod_util.h"
10 #include "base/logging.h"
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "content/browser/service_worker/service_worker_version.h"
14 #include "content/common/content_export.h"
15 #include "url/gurl.h"
16
17 namespace content {
18
19 class ServiceWorkerVersion;
20
21 // This class manages all persistence of service workers:
22 // - Registrations
23 // - Mapping of caches to registrations / versions
24 //
25 // This is the place where we manage simultaneous
26 // requests for the same registrations and caches, making sure that
27 // two pages that are registering the same pattern at the same time
28 // have their registrations coalesced rather than overwriting each
29 // other.
30 //
31 // This class also manages the state of the upgrade process, which
32 // includes managing which ServiceWorkerVersion is "active" vs "in
33 // waiting" (or "pending")
34 class CONTENT_EXPORT ServiceWorkerRegistration
35 : NON_EXPORTED_BASE(public base::RefCounted<ServiceWorkerRegistration>) {
36 public:
37 ServiceWorkerRegistration(const GURL& pattern,
38 const GURL& script_url,
39 int64 registration_id);
40
41 void Shutdown();
42 bool is_shutdown() const { return is_shutdown_; }
43
44 int64 id() const { return registration_id_; }
45 const GURL& script_url() const { return script_url_; }
46 const GURL& pattern() const { return pattern_; }
47
48 ServiceWorkerVersion* active_version() const {
49 DCHECK(!is_shutdown_);
50 return active_version_.get();
51 }
52
53 ServiceWorkerVersion* pending_version() const {
54 DCHECK(!is_shutdown_);
55 return pending_version_.get();
56 }
57
58 void set_active_version(ServiceWorkerVersion* version) {
59 DCHECK(!is_shutdown_);
60 active_version_ = version;
61 }
62
63 void set_pending_version(ServiceWorkerVersion* version) {
64 DCHECK(!is_shutdown_);
65 pending_version_ = version;
66 }
67
68 // The final synchronous switchover after all events have been
69 // fired, and the old "active version" is being shut down.
70 void ActivatePendingVersion();
71
72 private:
73 virtual ~ServiceWorkerRegistration();
74 friend class base::RefCounted<ServiceWorkerRegistration>;
75
76 const GURL pattern_;
77 const GURL script_url_;
78 const int64 registration_id_;
79
80 scoped_refptr<ServiceWorkerVersion> active_version_;
81 scoped_refptr<ServiceWorkerVersion> pending_version_;
82
83 bool is_shutdown_;
84
85 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerRegistration);
86 };
87 } // namespace content
88 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_REGISTRATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698