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

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

Issue 871013003: Gather the ServiceWorker client information in the browser process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@rfh_getvisibilitystate
Patch Set: review comments Created 5 years, 11 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
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 <set> 9 #include <set>
10 #include <string> 10 #include <string>
(...skipping 18 matching lines...) Expand all
29 29
30 class GURL; 30 class GURL;
31 31
32 namespace blink { 32 namespace blink {
33 struct WebCircularGeofencingRegion; 33 struct WebCircularGeofencingRegion;
34 } 34 }
35 35
36 namespace content { 36 namespace content {
37 37
38 class EmbeddedWorkerRegistry; 38 class EmbeddedWorkerRegistry;
39 struct NavigatorConnectClient;
40 struct PlatformNotificationData;
41 class ServiceWorkerContextCore; 39 class ServiceWorkerContextCore;
42 class ServiceWorkerProviderHost; 40 class ServiceWorkerProviderHost;
43 class ServiceWorkerRegistration; 41 class ServiceWorkerRegistration;
44 class ServiceWorkerURLRequestJob; 42 class ServiceWorkerURLRequestJob;
45 class ServiceWorkerVersionInfo; 43 class ServiceWorkerVersionInfo;
44 struct NavigatorConnectClient;
45 struct PlatformNotificationData;
46 struct ServiceWorkerClientInfo;
46 47
47 // This class corresponds to a specific version of a ServiceWorker 48 // This class corresponds to a specific version of a ServiceWorker
48 // script for a given pattern. When a script is upgraded, there may be 49 // script for a given pattern. When a script is upgraded, there may be
49 // more than one ServiceWorkerVersion "running" at a time, but only 50 // more than one ServiceWorkerVersion "running" at a time, but only
50 // one of them is activated. This class connects the actual script with a 51 // one of them is activated. This class connects the actual script with a
51 // running worker. 52 // running worker.
52 class CONTENT_EXPORT ServiceWorkerVersion 53 class CONTENT_EXPORT ServiceWorkerVersion
53 : NON_EXPORTED_BASE(public base::RefCounted<ServiceWorkerVersion>), 54 : NON_EXPORTED_BASE(public base::RefCounted<ServiceWorkerVersion>),
54 public EmbeddedWorkerInstance::Listener { 55 public EmbeddedWorkerInstance::Listener {
55 public: 56 public:
56 typedef base::Callback<void(ServiceWorkerStatusCode)> StatusCallback; 57 typedef base::Callback<void(ServiceWorkerStatusCode)> StatusCallback;
57 typedef base::Callback<void(ServiceWorkerStatusCode, 58 typedef base::Callback<void(ServiceWorkerStatusCode,
58 const IPC::Message& message)> MessageCallback; 59 const IPC::Message& message)> MessageCallback;
59 typedef base::Callback<void(ServiceWorkerStatusCode, 60 typedef base::Callback<void(ServiceWorkerStatusCode,
60 ServiceWorkerFetchEventResult, 61 ServiceWorkerFetchEventResult,
61 const ServiceWorkerResponse&)> FetchCallback; 62 const ServiceWorkerResponse&)> FetchCallback;
62 typedef base::Callback<void(ServiceWorkerStatusCode,
63 const ServiceWorkerClientInfo&)>
64 GetClientInfoCallback;
65 typedef base::Callback<void(ServiceWorkerStatusCode, bool)> 63 typedef base::Callback<void(ServiceWorkerStatusCode, bool)>
66 CrossOriginConnectCallback; 64 CrossOriginConnectCallback;
67 65
68 enum RunningStatus { 66 enum RunningStatus {
69 STOPPED = EmbeddedWorkerInstance::STOPPED, 67 STOPPED = EmbeddedWorkerInstance::STOPPED,
70 STARTING = EmbeddedWorkerInstance::STARTING, 68 STARTING = EmbeddedWorkerInstance::STARTING,
71 RUNNING = EmbeddedWorkerInstance::RUNNING, 69 RUNNING = EmbeddedWorkerInstance::RUNNING,
72 STOPPING = EmbeddedWorkerInstance::STOPPING, 70 STOPPING = EmbeddedWorkerInstance::STOPPING,
73 }; 71 };
74 72
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 const StatusCallback& callback); 326 const StatusCallback& callback);
329 void DispatchActivateEventAfterStartWorker(const StatusCallback& callback); 327 void DispatchActivateEventAfterStartWorker(const StatusCallback& callback);
330 328
331 void DispatchMessageEventInternal( 329 void DispatchMessageEventInternal(
332 const base::string16& message, 330 const base::string16& message,
333 const std::vector<int>& sent_message_port_ids, 331 const std::vector<int>& sent_message_port_ids,
334 const StatusCallback& callback); 332 const StatusCallback& callback);
335 333
336 // Message handlers. 334 // Message handlers.
337 void OnGetClientDocuments(int request_id); 335 void OnGetClientDocuments(int request_id);
338 void OnGetClientInfoSuccess(int request_id,
339 const ServiceWorkerClientInfo& info);
340 void OnGetClientInfoError(int request_id);
341 void OnActivateEventFinished(int request_id, 336 void OnActivateEventFinished(int request_id,
342 blink::WebServiceWorkerEventResult result); 337 blink::WebServiceWorkerEventResult result);
343 void OnInstallEventFinished(int request_id, 338 void OnInstallEventFinished(int request_id,
344 blink::WebServiceWorkerEventResult result); 339 blink::WebServiceWorkerEventResult result);
345 void OnFetchEventFinished(int request_id, 340 void OnFetchEventFinished(int request_id,
346 ServiceWorkerFetchEventResult result, 341 ServiceWorkerFetchEventResult result,
347 const ServiceWorkerResponse& response); 342 const ServiceWorkerResponse& response);
348 void OnSyncEventFinished(int request_id); 343 void OnSyncEventFinished(int request_id);
349 void OnNotificationClickEventFinished(int request_id); 344 void OnNotificationClickEventFinished(int request_id);
350 void OnPushEventFinished(int request_id, 345 void OnPushEventFinished(int request_id,
351 blink::WebServiceWorkerEventResult result); 346 blink::WebServiceWorkerEventResult result);
352 void OnGeofencingEventFinished(int request_id); 347 void OnGeofencingEventFinished(int request_id);
353 void OnCrossOriginConnectEventFinished(int request_id, 348 void OnCrossOriginConnectEventFinished(int request_id,
354 bool accept_connection); 349 bool accept_connection);
355 void OnPostMessageToDocument(int client_id, 350 void OnPostMessageToDocument(int client_id,
356 const base::string16& message, 351 const base::string16& message,
357 const std::vector<int>& sent_message_port_ids); 352 const std::vector<int>& sent_message_port_ids);
358 void OnFocusClient(int request_id, int client_id); 353 void OnFocusClient(int request_id, int client_id);
359 void OnSkipWaiting(int request_id); 354 void OnSkipWaiting(int request_id);
360 355
361 void OnFocusClientFinished(int request_id, bool result); 356 void OnFocusClientFinished(int request_id, bool result);
362 void DidSkipWaiting(int request_id); 357 void DidSkipWaiting(int request_id);
363 void DidGetClientInfo(int client_id, 358 void DidGetClientInfo(int client_id,
364 scoped_refptr<GetClientDocumentsCallback> callback, 359 scoped_refptr<GetClientDocumentsCallback> callback,
365 ServiceWorkerStatusCode status,
366 const ServiceWorkerClientInfo& info); 360 const ServiceWorkerClientInfo& info);
367 void ScheduleStopWorker(); 361 void ScheduleStopWorker();
368 void StopWorkerIfIdle(); 362 void StopWorkerIfIdle();
369 bool HasInflightRequests() const; 363 bool HasInflightRequests() const;
370 364
371 void DoomInternal(); 365 void DoomInternal();
372 366
373 template <typename IDMAP> 367 template <typename IDMAP>
374 void RemoveCallbackAndStopIfDoomed(IDMAP* callbacks, int request_id); 368 void RemoveCallbackAndStopIfDoomed(IDMAP* callbacks, int request_id);
375 369
(...skipping 10 matching lines...) Expand all
386 380
387 // Message callbacks. (Update HasInflightRequests() too when you update this 381 // Message callbacks. (Update HasInflightRequests() too when you update this
388 // list.) 382 // list.)
389 IDMap<StatusCallback, IDMapOwnPointer> activate_callbacks_; 383 IDMap<StatusCallback, IDMapOwnPointer> activate_callbacks_;
390 IDMap<StatusCallback, IDMapOwnPointer> install_callbacks_; 384 IDMap<StatusCallback, IDMapOwnPointer> install_callbacks_;
391 IDMap<FetchCallback, IDMapOwnPointer> fetch_callbacks_; 385 IDMap<FetchCallback, IDMapOwnPointer> fetch_callbacks_;
392 IDMap<StatusCallback, IDMapOwnPointer> sync_callbacks_; 386 IDMap<StatusCallback, IDMapOwnPointer> sync_callbacks_;
393 IDMap<StatusCallback, IDMapOwnPointer> notification_click_callbacks_; 387 IDMap<StatusCallback, IDMapOwnPointer> notification_click_callbacks_;
394 IDMap<StatusCallback, IDMapOwnPointer> push_callbacks_; 388 IDMap<StatusCallback, IDMapOwnPointer> push_callbacks_;
395 IDMap<StatusCallback, IDMapOwnPointer> geofencing_callbacks_; 389 IDMap<StatusCallback, IDMapOwnPointer> geofencing_callbacks_;
396 IDMap<GetClientInfoCallback, IDMapOwnPointer> get_client_info_callbacks_;
397 IDMap<CrossOriginConnectCallback, IDMapOwnPointer> 390 IDMap<CrossOriginConnectCallback, IDMapOwnPointer>
398 cross_origin_connect_callbacks_; 391 cross_origin_connect_callbacks_;
399 392
400 std::set<const ServiceWorkerURLRequestJob*> streaming_url_request_jobs_; 393 std::set<const ServiceWorkerURLRequestJob*> streaming_url_request_jobs_;
401 394
402 ControlleeMap controllee_map_; 395 ControlleeMap controllee_map_;
403 ControlleeByIDMap controllee_by_id_; 396 ControlleeByIDMap controllee_by_id_;
404 base::WeakPtr<ServiceWorkerContextCore> context_; 397 base::WeakPtr<ServiceWorkerContextCore> context_;
405 ObserverList<Listener> listeners_; 398 ObserverList<Listener> listeners_;
406 ServiceWorkerScriptCacheMap script_cache_map_; 399 ServiceWorkerScriptCacheMap script_cache_map_;
407 base::OneShotTimer<ServiceWorkerVersion> stop_worker_timer_; 400 base::OneShotTimer<ServiceWorkerVersion> stop_worker_timer_;
408 base::OneShotTimer<ServiceWorkerVersion> update_timer_; 401 base::OneShotTimer<ServiceWorkerVersion> update_timer_;
409 bool is_doomed_; 402 bool is_doomed_;
410 std::vector<int> pending_skip_waiting_requests_; 403 std::vector<int> pending_skip_waiting_requests_;
411 bool skip_waiting_; 404 bool skip_waiting_;
412 405
413 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; 406 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_;
414 407
415 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); 408 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion);
416 }; 409 };
417 410
418 } // namespace content 411 } // namespace content
419 412
420 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ 413 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698