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

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

Issue 224733014: Introduce ServiceWorkerHandle for tracking WebServiceWorkerImpl reference (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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_VERSION_H_ 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 NEW, // The version is just created. 61 NEW, // The version is just created.
62 INSTALLING, // Install event is dispatched and being handled. 62 INSTALLING, // Install event is dispatched and being handled.
63 INSTALLED, // Install event is finished and is ready to be activated. 63 INSTALLED, // Install event is finished and is ready to be activated.
64 ACTIVATING, // Activate event is dispatched and being handled. 64 ACTIVATING, // Activate event is dispatched and being handled.
65 ACTIVE, // Activation is finished and can run as active. 65 ACTIVE, // Activation is finished and can run as active.
66 DEACTIVATED, // The version is no longer running as active, due to 66 DEACTIVATED, // The version is no longer running as active, due to
67 // unregistration or replace. (TODO(kinuko): we may need 67 // unregistration or replace. (TODO(kinuko): we may need
68 // different states for different termination sequences) 68 // different states for different termination sequences)
69 }; 69 };
70 70
71 class Listener {
72 public:
73 virtual void OnVersionStateChanged() = 0;
74 };
75
71 ServiceWorkerVersion( 76 ServiceWorkerVersion(
72 ServiceWorkerRegistration* registration, 77 ServiceWorkerRegistration* registration,
73 int64 version_id, 78 int64 version_id,
74 base::WeakPtr<ServiceWorkerContextCore> context); 79 base::WeakPtr<ServiceWorkerContextCore> context);
75 80
76 int64 version_id() const { return version_id_; } 81 int64 version_id() const { return version_id_; }
77 ServiceWorkerRegistration* registration() { return registration_.get(); } 82 int64 registration_id() const { return registration_id_; }
78
79 void Shutdown();
80 bool is_shutdown() const { return is_shutdown_; }
81 83
82 RunningStatus running_status() const { 84 RunningStatus running_status() const {
83 return static_cast<RunningStatus>(embedded_worker_->status()); 85 return static_cast<RunningStatus>(embedded_worker_->status());
84 } 86 }
85 87
86 ServiceWorkerVersionInfo GetInfo(); 88 ServiceWorkerVersionInfo GetInfo();
87 89
88 Status status() const { return status_; } 90 Status status() const { return status_; }
89 91
90 // This sets the new status and also run status change callbacks 92 // This sets the new status and also run status change callbacks
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 const IPC::Message& message) OVERRIDE; 181 const IPC::Message& message) OVERRIDE;
180 182
181 private: 183 private:
182 typedef ServiceWorkerVersion self; 184 typedef ServiceWorkerVersion self;
183 typedef std::set<ServiceWorkerProviderHost*> ProviderHostSet; 185 typedef std::set<ServiceWorkerProviderHost*> ProviderHostSet;
184 friend class base::RefCounted<ServiceWorkerVersion>; 186 friend class base::RefCounted<ServiceWorkerVersion>;
185 187
186 virtual ~ServiceWorkerVersion(); 188 virtual ~ServiceWorkerVersion();
187 189
188 const int64 version_id_; 190 const int64 version_id_;
191 int64 registration_id_;
192 GURL script_url_;
189 Status status_; 193 Status status_;
190 bool is_shutdown_;
191 scoped_refptr<ServiceWorkerRegistration> registration_;
192 scoped_ptr<EmbeddedWorkerInstance> embedded_worker_; 194 scoped_ptr<EmbeddedWorkerInstance> embedded_worker_;
193 std::vector<StatusCallback> start_callbacks_; 195 std::vector<StatusCallback> start_callbacks_;
194 std::vector<StatusCallback> stop_callbacks_; 196 std::vector<StatusCallback> stop_callbacks_;
195 std::vector<base::Closure> status_change_callbacks_; 197 std::vector<base::Closure> status_change_callbacks_;
196 IDMap<MessageCallback, IDMapOwnPointer> message_callbacks_; 198 IDMap<MessageCallback, IDMapOwnPointer> message_callbacks_;
197 199
198 ProviderHostSet controllee_providers_; 200 ProviderHostSet controllee_providers_;
199 201
200 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; 202 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_;
201 base::WeakPtr<ServiceWorkerContextCore> context_; 203 base::WeakPtr<ServiceWorkerContextCore> context_;
202 204
203 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); 205 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion);
204 }; 206 };
205 207
206 } // namespace content 208 } // namespace content
207 209
208 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ 210 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698