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

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

Issue 761923004: Keep alive ServiceWorkers when devtools is attached (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updated comments Created 6 years 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
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 <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 241
242 ServiceWorkerScriptCacheMap* script_cache_map() { return &script_cache_map_; } 242 ServiceWorkerScriptCacheMap* script_cache_map() { return &script_cache_map_; }
243 EmbeddedWorkerInstance* embedded_worker() { return embedded_worker_.get(); } 243 EmbeddedWorkerInstance* embedded_worker() { return embedded_worker_.get(); }
244 244
245 // Dooms this version to have REDUNDANT status and its resources deleted. If 245 // Dooms this version to have REDUNDANT status and its resources deleted. If
246 // the version is controlling a page, these changes will happen when the 246 // the version is controlling a page, these changes will happen when the
247 // version no longer controls any pages. 247 // version no longer controls any pages.
248 void Doom(); 248 void Doom();
249 bool is_doomed() const { return is_doomed_; } 249 bool is_doomed() const { return is_doomed_; }
250 250
251 // If |keep_alive_mode| is set to true we don't run stop-worker-timer.
252 void SetKeepAliveMode(bool keep_alive);
253
251 private: 254 private:
252 friend class base::RefCounted<ServiceWorkerVersion>; 255 friend class base::RefCounted<ServiceWorkerVersion>;
253 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerControlleeRequestHandlerTest, 256 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerControlleeRequestHandlerTest,
254 ActivateWaitingVersion); 257 ActivateWaitingVersion);
255 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, ScheduleStopWorker); 258 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, ScheduleStopWorker);
259 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, KeepAlive);
256 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, ListenerAvailability); 260 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, ListenerAvailability);
257 typedef ServiceWorkerVersion self; 261 typedef ServiceWorkerVersion self;
258 typedef std::map<ServiceWorkerProviderHost*, int> ControlleeMap; 262 typedef std::map<ServiceWorkerProviderHost*, int> ControlleeMap;
259 typedef IDMap<ServiceWorkerProviderHost> ControlleeByIDMap; 263 typedef IDMap<ServiceWorkerProviderHost> ControlleeByIDMap;
260 264
261 ~ServiceWorkerVersion() override; 265 ~ServiceWorkerVersion() override;
262 266
263 // EmbeddedWorkerInstance::Listener overrides: 267 // EmbeddedWorkerInstance::Listener overrides:
264 void OnStarted() override; 268 void OnStarted() override;
265 void OnStopped(EmbeddedWorkerInstance::Status old_status) override; 269 void OnStopped(EmbeddedWorkerInstance::Status old_status) override;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 void OnSyncEventFinished(int request_id); 301 void OnSyncEventFinished(int request_id);
298 void OnNotificationClickEventFinished(int request_id); 302 void OnNotificationClickEventFinished(int request_id);
299 void OnPushEventFinished(int request_id, 303 void OnPushEventFinished(int request_id,
300 blink::WebServiceWorkerEventResult result); 304 blink::WebServiceWorkerEventResult result);
301 void OnGeofencingEventFinished(int request_id); 305 void OnGeofencingEventFinished(int request_id);
302 void OnPostMessageToDocument(int client_id, 306 void OnPostMessageToDocument(int client_id,
303 const base::string16& message, 307 const base::string16& message,
304 const std::vector<int>& sent_message_port_ids); 308 const std::vector<int>& sent_message_port_ids);
305 309
306 void ScheduleStopWorker(); 310 void ScheduleStopWorker();
311 void CancelStopWorker();
312 void MaybeStopWorker();
313 bool HasInflightRequests() const;
314
307 void DoomInternal(); 315 void DoomInternal();
308 316
309 const int64 version_id_; 317 const int64 version_id_;
310 int64 registration_id_; 318 int64 registration_id_;
311 GURL script_url_; 319 GURL script_url_;
312 GURL scope_; 320 GURL scope_;
313 Status status_; 321 Status status_;
314 scoped_ptr<EmbeddedWorkerInstance> embedded_worker_; 322 scoped_ptr<EmbeddedWorkerInstance> embedded_worker_;
315 scoped_ptr<ServiceWorkerCacheListener> cache_listener_; 323 scoped_ptr<ServiceWorkerCacheListener> cache_listener_;
316 std::vector<StatusCallback> start_callbacks_; 324 std::vector<StatusCallback> start_callbacks_;
317 std::vector<StatusCallback> stop_callbacks_; 325 std::vector<StatusCallback> stop_callbacks_;
318 std::vector<base::Closure> status_change_callbacks_; 326 std::vector<base::Closure> status_change_callbacks_;
319 327
320 // Message callbacks. 328 // Message callbacks. (Update HasInflightRequests() too when you update this
329 // list.)
321 IDMap<StatusCallback, IDMapOwnPointer> activate_callbacks_; 330 IDMap<StatusCallback, IDMapOwnPointer> activate_callbacks_;
322 IDMap<StatusCallback, IDMapOwnPointer> install_callbacks_; 331 IDMap<StatusCallback, IDMapOwnPointer> install_callbacks_;
323 IDMap<FetchCallback, IDMapOwnPointer> fetch_callbacks_; 332 IDMap<FetchCallback, IDMapOwnPointer> fetch_callbacks_;
324 IDMap<StatusCallback, IDMapOwnPointer> sync_callbacks_; 333 IDMap<StatusCallback, IDMapOwnPointer> sync_callbacks_;
325 IDMap<StatusCallback, IDMapOwnPointer> notification_click_callbacks_; 334 IDMap<StatusCallback, IDMapOwnPointer> notification_click_callbacks_;
326 IDMap<StatusCallback, IDMapOwnPointer> push_callbacks_; 335 IDMap<StatusCallback, IDMapOwnPointer> push_callbacks_;
327 IDMap<StatusCallback, IDMapOwnPointer> geofencing_callbacks_; 336 IDMap<StatusCallback, IDMapOwnPointer> geofencing_callbacks_;
328 337
329 ControlleeMap controllee_map_; 338 ControlleeMap controllee_map_;
330 ControlleeByIDMap controllee_by_id_; 339 ControlleeByIDMap controllee_by_id_;
331 base::WeakPtr<ServiceWorkerContextCore> context_; 340 base::WeakPtr<ServiceWorkerContextCore> context_;
332 ObserverList<Listener> listeners_; 341 ObserverList<Listener> listeners_;
333 ServiceWorkerScriptCacheMap script_cache_map_; 342 ServiceWorkerScriptCacheMap script_cache_map_;
334 base::OneShotTimer<ServiceWorkerVersion> stop_worker_timer_; 343 base::OneShotTimer<ServiceWorkerVersion> stop_worker_timer_;
335 base::OneShotTimer<ServiceWorkerVersion> update_timer_; 344 base::OneShotTimer<ServiceWorkerVersion> update_timer_;
336 bool is_doomed_; 345 bool is_doomed_;
346 bool keep_alive_mode_;
337 347
338 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; 348 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_;
339 349
340 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); 350 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion);
341 }; 351 };
342 352
343 } // namespace content 353 } // namespace content
344 354
345 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ 355 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698