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

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

Issue 1171173002: [Background Sync] Use Mojo IPC to fire background sync events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Formatting fixes Created 5 years, 6 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 <queue> 9 #include <queue>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/basictypes.h" 14 #include "base/basictypes.h"
15 #include "base/callback.h" 15 #include "base/callback.h"
16 #include "base/gtest_prod_util.h" 16 #include "base/gtest_prod_util.h"
17 #include "base/id_map.h" 17 #include "base/id_map.h"
18 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
19 #include "base/memory/scoped_ptr.h" 19 #include "base/memory/scoped_ptr.h"
20 #include "base/observer_list.h" 20 #include "base/observer_list.h"
21 #include "base/timer/timer.h" 21 #include "base/timer/timer.h"
22 #include "content/browser/service_worker/embedded_worker_instance.h" 22 #include "content/browser/service_worker/embedded_worker_instance.h"
23 #include "content/browser/service_worker/service_worker_script_cache_map.h" 23 #include "content/browser/service_worker/service_worker_script_cache_map.h"
24 #include "content/common/background_sync_service.mojom.h"
24 #include "content/common/content_export.h" 25 #include "content/common/content_export.h"
25 #include "content/common/service_worker/service_worker_status_code.h" 26 #include "content/common/service_worker/service_worker_status_code.h"
26 #include "content/common/service_worker/service_worker_types.h" 27 #include "content/common/service_worker/service_worker_types.h"
27 #include "third_party/WebKit/public/platform/WebGeofencingEventType.h" 28 #include "third_party/WebKit/public/platform/WebGeofencingEventType.h"
28 #include "third_party/WebKit/public/platform/WebServiceWorkerEventResult.h" 29 #include "third_party/WebKit/public/platform/WebServiceWorkerEventResult.h"
29 30
30 // Windows headers will redefine SendMessage. 31 // Windows headers will redefine SendMessage.
31 #ifdef SendMessage 32 #ifdef SendMessage
32 #undef SendMessage 33 #undef SendMessage
33 #endif 34 #endif
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 void DispatchFetchEvent(const ServiceWorkerFetchRequest& request, 203 void DispatchFetchEvent(const ServiceWorkerFetchRequest& request,
203 const base::Closure& prepare_callback, 204 const base::Closure& prepare_callback,
204 const FetchCallback& fetch_callback); 205 const FetchCallback& fetch_callback);
205 206
206 // Sends sync event to the associated embedded worker and asynchronously calls 207 // Sends sync event to the associated embedded worker and asynchronously calls
207 // |callback| when it errors out or it gets a response from the worker to 208 // |callback| when it errors out or it gets a response from the worker to
208 // notify completion. 209 // notify completion.
209 // 210 //
210 // This must be called when the status() is ACTIVATED. 211 // This must be called when the status() is ACTIVATED.
211 void DispatchSyncEvent(const StatusCallback& callback); 212 void DispatchSyncEvent(const StatusCallback& callback);
213 void DispatchSyncEventOnUIThread(int render_process_id,
214 int thread_id,
215 const StatusCallback& callback);
216
217 // Handle callbacks from background sync events
218 void OnSyncEventFinished(const StatusCallback& callback,
219 BackgroundSyncEventStatus status);
220 void FinishSyncEventOnIOThread(const StatusCallback& callback,
221 BackgroundSyncEventStatus status);
212 222
213 // Sends notificationclick event to the associated embedded worker and 223 // Sends notificationclick event to the associated embedded worker and
214 // asynchronously calls |callback| when it errors out or it gets a response 224 // asynchronously calls |callback| when it errors out or it gets a response
215 // from the worker to notify completion. 225 // from the worker to notify completion.
216 // 226 //
217 // This must be called when the status() is ACTIVATED. 227 // This must be called when the status() is ACTIVATED.
218 void DispatchNotificationClickEvent( 228 void DispatchNotificationClickEvent(
219 const StatusCallback& callback, 229 const StatusCallback& callback,
220 int64_t persistent_notification_id, 230 int64_t persistent_notification_id,
221 const PlatformNotificationData& notification_data); 231 const PlatformNotificationData& notification_data);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
347 class Metrics; 357 class Metrics;
348 class PingController; 358 class PingController;
349 359
350 typedef ServiceWorkerVersion self; 360 typedef ServiceWorkerVersion self;
351 using ServiceWorkerClients = std::vector<ServiceWorkerClientInfo>; 361 using ServiceWorkerClients = std::vector<ServiceWorkerClientInfo>;
352 362
353 enum RequestType { 363 enum RequestType {
354 REQUEST_ACTIVATE, 364 REQUEST_ACTIVATE,
355 REQUEST_INSTALL, 365 REQUEST_INSTALL,
356 REQUEST_FETCH, 366 REQUEST_FETCH,
357 REQUEST_SYNC,
358 REQUEST_NOTIFICATION_CLICK, 367 REQUEST_NOTIFICATION_CLICK,
359 REQUEST_PUSH, 368 REQUEST_PUSH,
360 REQUEST_GEOFENCING, 369 REQUEST_GEOFENCING,
361 REQUEST_CROSS_ORIGIN_CONNECT 370 REQUEST_CROSS_ORIGIN_CONNECT
362 }; 371 };
363 372
364 struct RequestInfo { 373 struct RequestInfo {
365 RequestInfo(int id, RequestType type); 374 RequestInfo(int id, RequestType type);
366 ~RequestInfo(); 375 ~RequestInfo();
367 int id; 376 int id;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 void OnGetClients(int request_id, 418 void OnGetClients(int request_id,
410 const ServiceWorkerClientQueryOptions& options); 419 const ServiceWorkerClientQueryOptions& options);
411 420
412 void OnActivateEventFinished(int request_id, 421 void OnActivateEventFinished(int request_id,
413 blink::WebServiceWorkerEventResult result); 422 blink::WebServiceWorkerEventResult result);
414 void OnInstallEventFinished(int request_id, 423 void OnInstallEventFinished(int request_id,
415 blink::WebServiceWorkerEventResult result); 424 blink::WebServiceWorkerEventResult result);
416 void OnFetchEventFinished(int request_id, 425 void OnFetchEventFinished(int request_id,
417 ServiceWorkerFetchEventResult result, 426 ServiceWorkerFetchEventResult result,
418 const ServiceWorkerResponse& response); 427 const ServiceWorkerResponse& response);
419 void OnSyncEventFinished(int request_id,
420 blink::WebServiceWorkerEventResult result);
421 void OnNotificationClickEventFinished(int request_id); 428 void OnNotificationClickEventFinished(int request_id);
422 void OnPushEventFinished(int request_id, 429 void OnPushEventFinished(int request_id,
423 blink::WebServiceWorkerEventResult result); 430 blink::WebServiceWorkerEventResult result);
424 void OnGeofencingEventFinished(int request_id); 431 void OnGeofencingEventFinished(int request_id);
425 void OnCrossOriginConnectEventFinished(int request_id, 432 void OnCrossOriginConnectEventFinished(int request_id,
426 bool accept_connection); 433 bool accept_connection);
427 void OnOpenWindow(int request_id, GURL url); 434 void OnOpenWindow(int request_id, GURL url);
428 void DidOpenWindow(int request_id, 435 void DidOpenWindow(int request_id,
429 int render_process_id, 436 int render_process_id,
430 int render_frame_id); 437 int render_frame_id);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 scoped_ptr<EmbeddedWorkerInstance> embedded_worker_; 523 scoped_ptr<EmbeddedWorkerInstance> embedded_worker_;
517 std::vector<StatusCallback> start_callbacks_; 524 std::vector<StatusCallback> start_callbacks_;
518 std::vector<StatusCallback> stop_callbacks_; 525 std::vector<StatusCallback> stop_callbacks_;
519 std::vector<base::Closure> status_change_callbacks_; 526 std::vector<base::Closure> status_change_callbacks_;
520 527
521 // Message callbacks. (Update HasInflightRequests() too when you update this 528 // Message callbacks. (Update HasInflightRequests() too when you update this
522 // list.) 529 // list.)
523 IDMap<StatusCallback, IDMapOwnPointer> activate_callbacks_; 530 IDMap<StatusCallback, IDMapOwnPointer> activate_callbacks_;
524 IDMap<StatusCallback, IDMapOwnPointer> install_callbacks_; 531 IDMap<StatusCallback, IDMapOwnPointer> install_callbacks_;
525 IDMap<FetchCallback, IDMapOwnPointer> fetch_callbacks_; 532 IDMap<FetchCallback, IDMapOwnPointer> fetch_callbacks_;
526 IDMap<StatusCallback, IDMapOwnPointer> sync_callbacks_;
527 IDMap<StatusCallback, IDMapOwnPointer> notification_click_callbacks_; 533 IDMap<StatusCallback, IDMapOwnPointer> notification_click_callbacks_;
528 IDMap<StatusCallback, IDMapOwnPointer> push_callbacks_; 534 IDMap<StatusCallback, IDMapOwnPointer> push_callbacks_;
529 IDMap<StatusCallback, IDMapOwnPointer> geofencing_callbacks_; 535 IDMap<StatusCallback, IDMapOwnPointer> geofencing_callbacks_;
530 IDMap<CrossOriginConnectCallback, IDMapOwnPointer> 536 IDMap<CrossOriginConnectCallback, IDMapOwnPointer>
531 cross_origin_connect_callbacks_; 537 cross_origin_connect_callbacks_;
532 538
533 std::set<const ServiceWorkerURLRequestJob*> streaming_url_request_jobs_; 539 std::set<const ServiceWorkerURLRequestJob*> streaming_url_request_jobs_;
534 540
535 std::map<std::string, ServiceWorkerProviderHost*> controllee_map_; 541 std::map<std::string, ServiceWorkerProviderHost*> controllee_map_;
536 // Will be null while shutting down. 542 // Will be null while shutting down.
(...skipping 24 matching lines...) Expand all
561 567
562 // The status when StartWorker was invoked. Used for UMA. 568 // The status when StartWorker was invoked. Used for UMA.
563 Status prestart_status_ = NEW; 569 Status prestart_status_ = NEW;
564 // If not OK, the reason that StartWorker failed. Used for 570 // If not OK, the reason that StartWorker failed. Used for
565 // running |start_callbacks_|. 571 // running |start_callbacks_|.
566 ServiceWorkerStatusCode start_worker_status_ = SERVICE_WORKER_OK; 572 ServiceWorkerStatusCode start_worker_status_ = SERVICE_WORKER_OK;
567 573
568 scoped_ptr<PingController> ping_controller_; 574 scoped_ptr<PingController> ping_controller_;
569 scoped_ptr<Metrics> metrics_; 575 scoped_ptr<Metrics> metrics_;
570 576
577 BackgroundSyncServiceClientPtr background_sync_client_;
jkarlin 2015/06/10 12:21:33 Hmm, this whole class is IO and this one member is
iclelland 2015/06/12 15:01:18 Would a general ServiceWorkerEventDispatcher make
578
571 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; 579 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_;
572 580
573 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); 581 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion);
574 }; 582 };
575 583
576 } // namespace content 584 } // namespace content
577 585
578 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ 586 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698