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

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

Issue 377153003: Service Worker: set active worker to REDUNDANT when unregistered (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make setting redundant clearly the responsibility of SWStorage 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_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 <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 STOPPING = EmbeddedWorkerInstance::STOPPING, 56 STOPPING = EmbeddedWorkerInstance::STOPPING,
57 }; 57 };
58 58
59 // Current version status; some of the status (e.g. INSTALLED and ACTIVATED) 59 // Current version status; some of the status (e.g. INSTALLED and ACTIVATED)
60 // should be persisted unlike running status. 60 // should be persisted unlike running status.
61 enum Status { 61 enum Status {
62 NEW, // The version is just created. 62 NEW, // The version is just created.
63 INSTALLING, // Install event is dispatched and being handled. 63 INSTALLING, // Install event is dispatched and being handled.
64 INSTALLED, // Install event is finished and is ready to be activated. 64 INSTALLED, // Install event is finished and is ready to be activated.
65 ACTIVATING, // Activate event is dispatched and being handled. 65 ACTIVATING, // Activate event is dispatched and being handled.
66 ACTIVATED, // Activation is finished and can run as activated. 66 ACTIVATED, // Activation is finished and can run as activated.
67 REDUNDANT, // The version is no longer running as activated, due to 67 REDUNDANT, // The version is no longer running as activated, due to
68 // unregistration or replace. 68 // unregistration or replace.
69 }; 69 };
70 70
71 class Listener { 71 class Listener {
72 public: 72 public:
73 virtual void OnWorkerStarted(ServiceWorkerVersion* version) {}; 73 virtual void OnWorkerStarted(ServiceWorkerVersion* version) {};
74 virtual void OnWorkerStopped(ServiceWorkerVersion* version) {}; 74 virtual void OnWorkerStopped(ServiceWorkerVersion* version) {};
75 virtual void OnVersionStateChanged(ServiceWorkerVersion* version) {}; 75 virtual void OnVersionStateChanged(ServiceWorkerVersion* version) {};
76 virtual void OnErrorReported(ServiceWorkerVersion* version, 76 virtual void OnErrorReported(ServiceWorkerVersion* version,
77 const base::string16& error_message, 77 const base::string16& error_message,
78 int line_number, 78 int line_number,
79 int column_number, 79 int column_number,
80 const GURL& source_url) {}; 80 const GURL& source_url) {};
81 virtual void OnReportConsoleMessage(ServiceWorkerVersion* version, 81 virtual void OnReportConsoleMessage(ServiceWorkerVersion* version,
82 int source_identifier, 82 int source_identifier,
83 int message_level, 83 int message_level,
84 const base::string16& message, 84 const base::string16& message,
85 int line_number, 85 int line_number,
86 const GURL& source_url) {}; 86 const GURL& source_url) {};
87 // Fired when a version that was the controller of a page no longer controls
88 // any pages.
87 virtual void OnNoControllees(ServiceWorkerVersion* version) {}; 89 virtual void OnNoControllees(ServiceWorkerVersion* version) {};
88 }; 90 };
89 91
90 ServiceWorkerVersion( 92 ServiceWorkerVersion(
91 ServiceWorkerRegistration* registration, 93 ServiceWorkerRegistration* registration,
92 int64 version_id, 94 int64 version_id,
93 base::WeakPtr<ServiceWorkerContextCore> context); 95 base::WeakPtr<ServiceWorkerContextCore> context);
94 96
95 int64 version_id() const { return version_id_; } 97 int64 version_id() const { return version_id_; }
96 int64 registration_id() const { return registration_id_; } 98 int64 registration_id() const { return registration_id_; }
(...skipping 20 matching lines...) Expand all
117 119
118 // Starts an embedded worker for this version. 120 // Starts an embedded worker for this version.
119 // |potential_process_ids| is a list of processes in which to start the 121 // |potential_process_ids| is a list of processes in which to start the
120 // worker. 122 // worker.
121 // This returns OK (success) if the worker is already running. 123 // This returns OK (success) if the worker is already running.
122 void StartWorkerWithCandidateProcesses( 124 void StartWorkerWithCandidateProcesses(
123 const std::vector<int>& potential_process_ids, 125 const std::vector<int>& potential_process_ids,
124 bool pause_after_download, 126 bool pause_after_download,
125 const StatusCallback& callback); 127 const StatusCallback& callback);
126 128
127 // Stops an embedded worker for this version. 129 // Stops the embedded worker for this version.
128 // This returns OK (success) if the worker is already stopped. 130 // This returns OK (success) if the worker is already stopped.
129 void StopWorker(const StatusCallback& callback); 131 void StopWorker(const StatusCallback& callback);
130 132
131 // Schedules an update to be run 'soon'. 133 // Schedules an update to be run 'soon'.
132 void ScheduleUpdate(); 134 void ScheduleUpdate();
133 135
134 // If an update is scheduled but not yet started, this resets the timer 136 // If an update is scheduled but not yet started, this resets the timer
135 // delaying the start time by a 'small' amount. 137 // delaying the start time by a 'small' amount.
136 void DeferScheduledUpdate(); 138 void DeferScheduledUpdate();
137 139
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 bool HasProcessToRun() const; 203 bool HasProcessToRun() const;
202 204
203 // Adds and removes |provider_host| as a controllee of this ServiceWorker. 205 // Adds and removes |provider_host| as a controllee of this ServiceWorker.
204 // A potential controllee is a host having the version as its .installing 206 // A potential controllee is a host having the version as its .installing
205 // or .waiting version. 207 // or .waiting version.
206 void AddControllee(ServiceWorkerProviderHost* provider_host); 208 void AddControllee(ServiceWorkerProviderHost* provider_host);
207 void RemoveControllee(ServiceWorkerProviderHost* provider_host); 209 void RemoveControllee(ServiceWorkerProviderHost* provider_host);
208 void AddPotentialControllee(ServiceWorkerProviderHost* provider_host); 210 void AddPotentialControllee(ServiceWorkerProviderHost* provider_host);
209 void RemovePotentialControllee(ServiceWorkerProviderHost* provider_host); 211 void RemovePotentialControllee(ServiceWorkerProviderHost* provider_host);
210 212
211 // Returns if it has controllee. 213 // Returns true if it has a controllee, excluding potential ones.
212 bool HasControllee() const { return !controllee_map_.empty(); } 214 bool HasControllee() const { return !controllee_map_.empty(); }
213 215
214 // Adds and removes Listeners. 216 // Adds and removes Listeners.
215 void AddListener(Listener* listener); 217 void AddListener(Listener* listener);
216 void RemoveListener(Listener* listener); 218 void RemoveListener(Listener* listener);
217 219
218 ServiceWorkerScriptCacheMap* script_cache_map() { return &script_cache_map_; } 220 ServiceWorkerScriptCacheMap* script_cache_map() { return &script_cache_map_; }
219 EmbeddedWorkerInstance* embedded_worker() { return embedded_worker_.get(); } 221 EmbeddedWorkerInstance* embedded_worker() { return embedded_worker_.get(); }
220 222
221 private: 223 private:
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 base::OneShotTimer<ServiceWorkerVersion> update_timer_; 291 base::OneShotTimer<ServiceWorkerVersion> update_timer_;
290 292
291 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; 293 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_;
292 294
293 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); 295 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion);
294 }; 296 };
295 297
296 } // namespace content 298 } // namespace content
297 299
298 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ 300 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698