OLD | NEW |
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> |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 | 168 |
169 // If an update is scheduled but not yet started, this resets the timer | 169 // If an update is scheduled but not yet started, this resets the timer |
170 // delaying the start time by a 'small' amount. | 170 // delaying the start time by a 'small' amount. |
171 void DeferScheduledUpdate(); | 171 void DeferScheduledUpdate(); |
172 | 172 |
173 // Starts an update now. | 173 // Starts an update now. |
174 void StartUpdate(); | 174 void StartUpdate(); |
175 | 175 |
176 // Sends a message event to the associated embedded worker. | 176 // Sends a message event to the associated embedded worker. |
177 void DispatchMessageEvent( | 177 void DispatchMessageEvent( |
| 178 ServiceWorkerProviderHost* provider_host, |
178 const base::string16& message, | 179 const base::string16& message, |
179 const std::vector<TransferredMessagePort>& sent_message_ports, | 180 const std::vector<TransferredMessagePort>& sent_message_ports, |
180 const StatusCallback& callback); | 181 const StatusCallback& callback); |
181 | 182 |
182 // Sends install event to the associated embedded worker and asynchronously | 183 // Sends install event to the associated embedded worker and asynchronously |
183 // calls |callback| when it errors out or it gets a response from the worker | 184 // calls |callback| when it errors out or it gets a response from the worker |
184 // to notify install completion. | 185 // to notify install completion. |
185 // | 186 // |
186 // This must be called when the status() is NEW. Calling this changes | 187 // This must be called when the status() is NEW. Calling this changes |
187 // the version's status to INSTALLING. | 188 // the version's status to INSTALLING. |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
363 using ServiceWorkerClients = std::vector<ServiceWorkerClientInfo>; | 364 using ServiceWorkerClients = std::vector<ServiceWorkerClientInfo>; |
364 | 365 |
365 enum RequestType { | 366 enum RequestType { |
366 REQUEST_ACTIVATE, | 367 REQUEST_ACTIVATE, |
367 REQUEST_INSTALL, | 368 REQUEST_INSTALL, |
368 REQUEST_FETCH, | 369 REQUEST_FETCH, |
369 REQUEST_SYNC, | 370 REQUEST_SYNC, |
370 REQUEST_NOTIFICATION_CLICK, | 371 REQUEST_NOTIFICATION_CLICK, |
371 REQUEST_PUSH, | 372 REQUEST_PUSH, |
372 REQUEST_GEOFENCING, | 373 REQUEST_GEOFENCING, |
373 REQUEST_CROSS_ORIGIN_CONNECT | 374 REQUEST_CROSS_ORIGIN_CONNECT, |
| 375 REQUEST_MESSAGE, |
374 }; | 376 }; |
375 | 377 |
376 struct RequestInfo { | 378 struct RequestInfo { |
377 RequestInfo(int id, RequestType type); | 379 RequestInfo(int id, RequestType type); |
378 ~RequestInfo(); | 380 ~RequestInfo(); |
379 int id; | 381 int id; |
380 RequestType type; | 382 RequestType type; |
381 base::TimeTicks time; | 383 base::TimeTicks time; |
382 }; | 384 }; |
383 | 385 |
(...skipping 20 matching lines...) Expand all Loading... |
404 const base::string16& message, | 406 const base::string16& message, |
405 int line_number, | 407 int line_number, |
406 const GURL& source_url) override; | 408 const GURL& source_url) override; |
407 bool OnMessageReceived(const IPC::Message& message) override; | 409 bool OnMessageReceived(const IPC::Message& message) override; |
408 | 410 |
409 void OnStartSentAndScriptEvaluated(ServiceWorkerStatusCode status); | 411 void OnStartSentAndScriptEvaluated(ServiceWorkerStatusCode status); |
410 | 412 |
411 void DispatchInstallEventAfterStartWorker(const StatusCallback& callback); | 413 void DispatchInstallEventAfterStartWorker(const StatusCallback& callback); |
412 void DispatchActivateEventAfterStartWorker(const StatusCallback& callback); | 414 void DispatchActivateEventAfterStartWorker(const StatusCallback& callback); |
413 | 415 |
414 void DispatchMessageEventInternal( | 416 void DispatchClientMessageEventInternal( |
415 const base::string16& message, | 417 const base::string16& message, |
416 const std::vector<TransferredMessagePort>& sent_message_ports, | 418 const std::vector<TransferredMessagePort>& sent_message_ports, |
| 419 const std::string& client_uuid, |
| 420 const StatusCallback& callback, |
| 421 const ServiceWorkerClientInfo& client_info); |
| 422 void DispatchWorkerMessageEventInternal( |
| 423 const base::string16& message, |
| 424 const std::vector<TransferredMessagePort>& sent_message_ports, |
| 425 const ServiceWorkerObjectInfo& worker_info, |
417 const StatusCallback& callback); | 426 const StatusCallback& callback); |
418 | 427 |
419 // Message handlers. | 428 // Message handlers. |
420 | 429 |
421 // This corresponds to the spec's matchAll(options) steps. | 430 // This corresponds to the spec's matchAll(options) steps. |
422 void OnGetClients(int request_id, | 431 void OnGetClients(int request_id, |
423 const ServiceWorkerClientQueryOptions& options); | 432 const ServiceWorkerClientQueryOptions& options); |
424 | 433 |
425 void OnActivateEventFinished(int request_id, | 434 void OnActivateEventFinished(int request_id, |
426 blink::WebServiceWorkerEventResult result); | 435 blink::WebServiceWorkerEventResult result); |
427 void OnInstallEventFinished(int request_id, | 436 void OnInstallEventFinished(int request_id, |
428 blink::WebServiceWorkerEventResult result); | 437 blink::WebServiceWorkerEventResult result); |
429 void OnFetchEventFinished(int request_id, | 438 void OnFetchEventFinished(int request_id, |
430 ServiceWorkerFetchEventResult result, | 439 ServiceWorkerFetchEventResult result, |
431 const ServiceWorkerResponse& response); | 440 const ServiceWorkerResponse& response); |
432 void OnSyncEventFinished(int request_id, | 441 void OnSyncEventFinished(int request_id, |
433 blink::WebServiceWorkerEventResult result); | 442 blink::WebServiceWorkerEventResult result); |
434 void OnNotificationClickEventFinished(int request_id); | 443 void OnNotificationClickEventFinished(int request_id); |
435 void OnPushEventFinished(int request_id, | 444 void OnPushEventFinished(int request_id, |
436 blink::WebServiceWorkerEventResult result); | 445 blink::WebServiceWorkerEventResult result); |
437 void OnGeofencingEventFinished(int request_id); | 446 void OnGeofencingEventFinished(int request_id); |
438 void OnCrossOriginConnectEventFinished(int request_id, | 447 void OnCrossOriginConnectEventFinished(int request_id, |
439 bool accept_connection); | 448 bool accept_connection); |
| 449 void OnMessageEventFinished(int request_id); |
440 void OnOpenWindow(int request_id, GURL url); | 450 void OnOpenWindow(int request_id, GURL url); |
441 void DidOpenWindow(int request_id, | 451 void DidOpenWindow(int request_id, |
442 int render_process_id, | 452 int render_process_id, |
443 int render_frame_id); | 453 int render_frame_id); |
444 void OnOpenWindowFinished(int request_id, | 454 void OnOpenWindowFinished(int request_id, |
445 const std::string& client_uuid, | 455 const std::string& client_uuid, |
446 const ServiceWorkerClientInfo& client_info); | 456 const ServiceWorkerClientInfo& client_info); |
447 | 457 |
448 void OnSetCachedMetadata(const GURL& url, const std::vector<char>& data); | 458 void OnSetCachedMetadata(const GURL& url, const std::vector<char>& data); |
449 void OnSetCachedMetadataFinished(int64 callback_id, int result); | 459 void OnSetCachedMetadataFinished(int64 callback_id, int result); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 // list.) | 555 // list.) |
546 IDMap<StatusCallback, IDMapOwnPointer> activate_callbacks_; | 556 IDMap<StatusCallback, IDMapOwnPointer> activate_callbacks_; |
547 IDMap<StatusCallback, IDMapOwnPointer> install_callbacks_; | 557 IDMap<StatusCallback, IDMapOwnPointer> install_callbacks_; |
548 IDMap<FetchCallback, IDMapOwnPointer> fetch_callbacks_; | 558 IDMap<FetchCallback, IDMapOwnPointer> fetch_callbacks_; |
549 IDMap<StatusCallback, IDMapOwnPointer> sync_callbacks_; | 559 IDMap<StatusCallback, IDMapOwnPointer> sync_callbacks_; |
550 IDMap<StatusCallback, IDMapOwnPointer> notification_click_callbacks_; | 560 IDMap<StatusCallback, IDMapOwnPointer> notification_click_callbacks_; |
551 IDMap<StatusCallback, IDMapOwnPointer> push_callbacks_; | 561 IDMap<StatusCallback, IDMapOwnPointer> push_callbacks_; |
552 IDMap<StatusCallback, IDMapOwnPointer> geofencing_callbacks_; | 562 IDMap<StatusCallback, IDMapOwnPointer> geofencing_callbacks_; |
553 IDMap<CrossOriginConnectCallback, IDMapOwnPointer> | 563 IDMap<CrossOriginConnectCallback, IDMapOwnPointer> |
554 cross_origin_connect_callbacks_; | 564 cross_origin_connect_callbacks_; |
| 565 IDMap<StatusCallback, IDMapOwnPointer> message_callbacks_; |
555 | 566 |
556 std::set<const ServiceWorkerURLRequestJob*> streaming_url_request_jobs_; | 567 std::set<const ServiceWorkerURLRequestJob*> streaming_url_request_jobs_; |
557 | 568 |
558 std::map<std::string, ServiceWorkerProviderHost*> controllee_map_; | 569 std::map<std::string, ServiceWorkerProviderHost*> controllee_map_; |
559 // Will be null while shutting down. | 570 // Will be null while shutting down. |
560 base::WeakPtr<ServiceWorkerContextCore> context_; | 571 base::WeakPtr<ServiceWorkerContextCore> context_; |
561 base::ObserverList<Listener> listeners_; | 572 base::ObserverList<Listener> listeners_; |
562 ServiceWorkerScriptCacheMap script_cache_map_; | 573 ServiceWorkerScriptCacheMap script_cache_map_; |
563 base::OneShotTimer<ServiceWorkerVersion> update_timer_; | 574 base::OneShotTimer<ServiceWorkerVersion> update_timer_; |
564 | 575 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
599 scoped_ptr<Metrics> metrics_; | 610 scoped_ptr<Metrics> metrics_; |
600 | 611 |
601 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; | 612 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; |
602 | 613 |
603 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); | 614 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); |
604 }; | 615 }; |
605 | 616 |
606 } // namespace content | 617 } // namespace content |
607 | 618 |
608 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 619 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
OLD | NEW |