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

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: version purges the resources 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 virtual void OnNoControllees(ServiceWorkerVersion* version) {}; 87 virtual void OnNoControllees(ServiceWorkerVersion* version) {};
nhiroki 2014/07/11 07:59:13 According to grep, this looks no longer necessary.
falken 2014/07/11 12:08:12 Done.
88 }; 88 };
89 89
90 ServiceWorkerVersion( 90 ServiceWorkerVersion(
91 ServiceWorkerRegistration* registration, 91 ServiceWorkerRegistration* registration,
92 int64 version_id, 92 int64 version_id,
93 base::WeakPtr<ServiceWorkerContextCore> context); 93 base::WeakPtr<ServiceWorkerContextCore> context);
94 94
95 int64 version_id() const { return version_id_; } 95 int64 version_id() const { return version_id_; }
96 int64 registration_id() const { return registration_id_; } 96 int64 registration_id() const { return registration_id_; }
97 const GURL& script_url() const { return script_url_; } 97 const GURL& script_url() const { return script_url_; }
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 // Returns if it has controllee. 211 // Returns if it has controllee.
212 bool HasControllee() const { return !controllee_map_.empty(); } 212 bool HasControllee() const { return !controllee_map_.empty(); }
213 213
214 // Adds and removes Listeners. 214 // Adds and removes Listeners.
215 void AddListener(Listener* listener); 215 void AddListener(Listener* listener);
216 void RemoveListener(Listener* listener); 216 void RemoveListener(Listener* listener);
217 217
218 ServiceWorkerScriptCacheMap* script_cache_map() { return &script_cache_map_; } 218 ServiceWorkerScriptCacheMap* script_cache_map() { return &script_cache_map_; }
219 EmbeddedWorkerInstance* embedded_worker() { return embedded_worker_.get(); } 219 EmbeddedWorkerInstance* embedded_worker() { return embedded_worker_.get(); }
220 220
221 // Dooms this version to have REDUNDANT status and its resources deleted. If
222 // the version is controlling a page, these changes will happen when the
223 // version no longer controls any pages. Since this function can trigger
224 // resource deletion, it should only be called after the
225 // registration storing this version has been deleted from
226 // ServiceWorkerDatabase (or is queued to be).
michaeln 2014/07/11 01:16:05 I don't think the part about 'should only be calle
falken 2014/07/11 12:08:12 I meant more that the resource ids should already
227 void Doom();
228
221 private: 229 private:
222 typedef ServiceWorkerVersion self; 230 typedef ServiceWorkerVersion self;
223 typedef std::map<ServiceWorkerProviderHost*, int> ControlleeMap; 231 typedef std::map<ServiceWorkerProviderHost*, int> ControlleeMap;
224 typedef IDMap<ServiceWorkerProviderHost> ControlleeByIDMap; 232 typedef IDMap<ServiceWorkerProviderHost> ControlleeByIDMap;
225 friend class base::RefCounted<ServiceWorkerVersion>; 233 friend class base::RefCounted<ServiceWorkerVersion>;
226 234
227 virtual ~ServiceWorkerVersion(); 235 virtual ~ServiceWorkerVersion();
228 236
229 // EmbeddedWorkerInstance::Listener overrides: 237 // EmbeddedWorkerInstance::Listener overrides:
230 virtual void OnStarted() OVERRIDE; 238 virtual void OnStarted() OVERRIDE;
(...skipping 24 matching lines...) Expand all
255 void OnFetchEventFinished(int request_id, 263 void OnFetchEventFinished(int request_id,
256 ServiceWorkerFetchEventResult result, 264 ServiceWorkerFetchEventResult result,
257 const ServiceWorkerResponse& response); 265 const ServiceWorkerResponse& response);
258 void OnSyncEventFinished(int request_id); 266 void OnSyncEventFinished(int request_id);
259 void OnPushEventFinished(int request_id); 267 void OnPushEventFinished(int request_id);
260 void OnPostMessageToDocument(int client_id, 268 void OnPostMessageToDocument(int client_id,
261 const base::string16& message, 269 const base::string16& message,
262 const std::vector<int>& sent_message_port_ids); 270 const std::vector<int>& sent_message_port_ids);
263 271
264 void ScheduleStopWorker(); 272 void ScheduleStopWorker();
273 void DoomInternal();
265 274
266 const int64 version_id_; 275 const int64 version_id_;
267 int64 registration_id_; 276 int64 registration_id_;
268 GURL script_url_; 277 GURL script_url_;
269 GURL scope_; 278 GURL scope_;
270 Status status_; 279 Status status_;
271 scoped_ptr<EmbeddedWorkerInstance> embedded_worker_; 280 scoped_ptr<EmbeddedWorkerInstance> embedded_worker_;
272 std::vector<StatusCallback> start_callbacks_; 281 std::vector<StatusCallback> start_callbacks_;
273 std::vector<StatusCallback> stop_callbacks_; 282 std::vector<StatusCallback> stop_callbacks_;
274 std::vector<base::Closure> status_change_callbacks_; 283 std::vector<base::Closure> status_change_callbacks_;
275 284
276 // Message callbacks. 285 // Message callbacks.
277 IDMap<StatusCallback, IDMapOwnPointer> activate_callbacks_; 286 IDMap<StatusCallback, IDMapOwnPointer> activate_callbacks_;
278 IDMap<StatusCallback, IDMapOwnPointer> install_callbacks_; 287 IDMap<StatusCallback, IDMapOwnPointer> install_callbacks_;
279 IDMap<FetchCallback, IDMapOwnPointer> fetch_callbacks_; 288 IDMap<FetchCallback, IDMapOwnPointer> fetch_callbacks_;
280 IDMap<StatusCallback, IDMapOwnPointer> sync_callbacks_; 289 IDMap<StatusCallback, IDMapOwnPointer> sync_callbacks_;
281 IDMap<StatusCallback, IDMapOwnPointer> push_callbacks_; 290 IDMap<StatusCallback, IDMapOwnPointer> push_callbacks_;
282 291
283 ControlleeMap controllee_map_; 292 ControlleeMap controllee_map_;
284 ControlleeByIDMap controllee_by_id_; 293 ControlleeByIDMap controllee_by_id_;
285 base::WeakPtr<ServiceWorkerContextCore> context_; 294 base::WeakPtr<ServiceWorkerContextCore> context_;
286 ObserverList<Listener> listeners_; 295 ObserverList<Listener> listeners_;
287 ServiceWorkerScriptCacheMap script_cache_map_; 296 ServiceWorkerScriptCacheMap script_cache_map_;
288 base::OneShotTimer<ServiceWorkerVersion> stop_worker_timer_; 297 base::OneShotTimer<ServiceWorkerVersion> stop_worker_timer_;
289 base::OneShotTimer<ServiceWorkerVersion> update_timer_; 298 base::OneShotTimer<ServiceWorkerVersion> update_timer_;
299 bool is_doomed_;
290 300
291 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; 301 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_;
292 302
293 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); 303 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion);
294 }; 304 };
295 305
296 } // namespace content 306 } // namespace content
297 307
298 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ 308 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698