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

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: ASSERT_TRUE -> DCHECK :( 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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 EmbeddedWorkerInstance* embedded_worker() { return embedded_worker_.get(); } 246 EmbeddedWorkerInstance* embedded_worker() { return embedded_worker_.get(); }
247 247
248 // Dooms this version to have REDUNDANT status and its resources deleted. If 248 // Dooms this version to have REDUNDANT status and its resources deleted. If
249 // the version is controlling a page, these changes will happen when the 249 // the version is controlling a page, these changes will happen when the
250 // version no longer controls any pages. 250 // version no longer controls any pages.
251 void Doom(); 251 void Doom();
252 bool is_doomed() const { return is_doomed_; } 252 bool is_doomed() const { return is_doomed_; }
253 253
254 bool skip_waiting() const { return skip_waiting_; } 254 bool skip_waiting() const { return skip_waiting_; }
255 255
256 void SetDevToolsAttached(bool attached);
257
256 private: 258 private:
257 class GetClientDocumentsCallback; 259 class GetClientDocumentsCallback;
258 class GetClientInfoCallback; 260 class GetClientInfoCallback;
259 261
260 friend class base::RefCounted<ServiceWorkerVersion>; 262 friend class base::RefCounted<ServiceWorkerVersion>;
261 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerControlleeRequestHandlerTest, 263 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerControlleeRequestHandlerTest,
262 ActivateWaitingVersion); 264 ActivateWaitingVersion);
263 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, ScheduleStopWorker); 265 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, ScheduleStopWorker);
266 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, KeepAlive);
264 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, ListenerAvailability); 267 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerVersionTest, ListenerAvailability);
265 typedef ServiceWorkerVersion self; 268 typedef ServiceWorkerVersion self;
266 typedef std::map<ServiceWorkerProviderHost*, int> ControlleeMap; 269 typedef std::map<ServiceWorkerProviderHost*, int> ControlleeMap;
267 typedef IDMap<ServiceWorkerProviderHost> ControlleeByIDMap; 270 typedef IDMap<ServiceWorkerProviderHost> ControlleeByIDMap;
268 271
269 ~ServiceWorkerVersion() override; 272 ~ServiceWorkerVersion() override;
270 273
271 // EmbeddedWorkerInstance::Listener overrides: 274 // EmbeddedWorkerInstance::Listener overrides:
272 void OnStarted() override; 275 void OnStarted() override;
273 void OnStopped(EmbeddedWorkerInstance::Status old_status) override; 276 void OnStopped(EmbeddedWorkerInstance::Status old_status) override;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 void OnGeofencingEventFinished(int request_id); 315 void OnGeofencingEventFinished(int request_id);
313 void OnPostMessageToDocument(int client_id, 316 void OnPostMessageToDocument(int client_id,
314 const base::string16& message, 317 const base::string16& message,
315 const std::vector<int>& sent_message_port_ids); 318 const std::vector<int>& sent_message_port_ids);
316 void OnFocusClient(int request_id, int client_id); 319 void OnFocusClient(int request_id, int client_id);
317 void OnSkipWaiting(int request_id); 320 void OnSkipWaiting(int request_id);
318 321
319 void OnFocusClientFinished(int request_id, bool result); 322 void OnFocusClientFinished(int request_id, bool result);
320 void DidSkipWaiting(int request_id); 323 void DidSkipWaiting(int request_id);
321 void ScheduleStopWorker(); 324 void ScheduleStopWorker();
325 void StopWorkerIfIdle();
326 bool HasInflightRequests() const;
327
322 void DoomInternal(); 328 void DoomInternal();
323 329
324 const int64 version_id_; 330 const int64 version_id_;
325 int64 registration_id_; 331 int64 registration_id_;
326 GURL script_url_; 332 GURL script_url_;
327 GURL scope_; 333 GURL scope_;
328 Status status_; 334 Status status_;
329 scoped_ptr<EmbeddedWorkerInstance> embedded_worker_; 335 scoped_ptr<EmbeddedWorkerInstance> embedded_worker_;
330 scoped_ptr<ServiceWorkerCacheListener> cache_listener_; 336 scoped_ptr<ServiceWorkerCacheListener> cache_listener_;
331 std::vector<StatusCallback> start_callbacks_; 337 std::vector<StatusCallback> start_callbacks_;
332 std::vector<StatusCallback> stop_callbacks_; 338 std::vector<StatusCallback> stop_callbacks_;
333 std::vector<base::Closure> status_change_callbacks_; 339 std::vector<base::Closure> status_change_callbacks_;
334 340
335 // Message callbacks. 341 // Message callbacks. (Update HasInflightRequests() too when you update this
342 // list.)
336 IDMap<StatusCallback, IDMapOwnPointer> activate_callbacks_; 343 IDMap<StatusCallback, IDMapOwnPointer> activate_callbacks_;
337 IDMap<StatusCallback, IDMapOwnPointer> install_callbacks_; 344 IDMap<StatusCallback, IDMapOwnPointer> install_callbacks_;
338 IDMap<FetchCallback, IDMapOwnPointer> fetch_callbacks_; 345 IDMap<FetchCallback, IDMapOwnPointer> fetch_callbacks_;
339 IDMap<StatusCallback, IDMapOwnPointer> sync_callbacks_; 346 IDMap<StatusCallback, IDMapOwnPointer> sync_callbacks_;
340 IDMap<StatusCallback, IDMapOwnPointer> notification_click_callbacks_; 347 IDMap<StatusCallback, IDMapOwnPointer> notification_click_callbacks_;
341 IDMap<StatusCallback, IDMapOwnPointer> push_callbacks_; 348 IDMap<StatusCallback, IDMapOwnPointer> push_callbacks_;
342 IDMap<StatusCallback, IDMapOwnPointer> geofencing_callbacks_; 349 IDMap<StatusCallback, IDMapOwnPointer> geofencing_callbacks_;
343 IDMap<GetClientInfoCallback, IDMapOwnPointer> get_client_info_callbacks_; 350 IDMap<GetClientInfoCallback, IDMapOwnPointer> get_client_info_callbacks_;
344 351
345 ControlleeMap controllee_map_; 352 ControlleeMap controllee_map_;
346 ControlleeByIDMap controllee_by_id_; 353 ControlleeByIDMap controllee_by_id_;
347 base::WeakPtr<ServiceWorkerContextCore> context_; 354 base::WeakPtr<ServiceWorkerContextCore> context_;
348 ObserverList<Listener> listeners_; 355 ObserverList<Listener> listeners_;
349 ServiceWorkerScriptCacheMap script_cache_map_; 356 ServiceWorkerScriptCacheMap script_cache_map_;
350 base::OneShotTimer<ServiceWorkerVersion> stop_worker_timer_; 357 base::OneShotTimer<ServiceWorkerVersion> stop_worker_timer_;
351 base::OneShotTimer<ServiceWorkerVersion> update_timer_; 358 base::OneShotTimer<ServiceWorkerVersion> update_timer_;
352 bool is_doomed_; 359 bool is_doomed_;
353 std::vector<int> pending_skip_waiting_requests_; 360 std::vector<int> pending_skip_waiting_requests_;
354 bool skip_waiting_; 361 bool skip_waiting_;
355 362
356 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; 363 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_;
357 364
358 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); 365 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion);
359 }; 366 };
360 367
361 } // namespace content 368 } // namespace content
362 369
363 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ 370 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698