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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 : NON_EXPORTED_BASE(public base::RefCounted<ServiceWorkerVersion>), | 64 : NON_EXPORTED_BASE(public base::RefCounted<ServiceWorkerVersion>), |
65 public EmbeddedWorkerInstance::Listener { | 65 public EmbeddedWorkerInstance::Listener { |
66 public: | 66 public: |
67 typedef base::Callback<void(ServiceWorkerStatusCode)> StatusCallback; | 67 typedef base::Callback<void(ServiceWorkerStatusCode)> StatusCallback; |
68 typedef base::Callback<void(ServiceWorkerStatusCode, | 68 typedef base::Callback<void(ServiceWorkerStatusCode, |
69 ServiceWorkerFetchEventResult, | 69 ServiceWorkerFetchEventResult, |
70 const ServiceWorkerResponse&)> FetchCallback; | 70 const ServiceWorkerResponse&)> FetchCallback; |
71 typedef base::Callback<void(ServiceWorkerStatusCode, | 71 typedef base::Callback<void(ServiceWorkerStatusCode, |
72 bool /* accept_connction */)> | 72 bool /* accept_connction */)> |
73 CrossOriginConnectCallback; | 73 CrossOriginConnectCallback; |
| 74 typedef base::Callback<void(ServiceWorkerStatusCode, const std::vector<int>&)> |
| 75 SendStashedPortsCallback; |
74 | 76 |
75 enum RunningStatus { | 77 enum RunningStatus { |
76 STOPPED = EmbeddedWorkerInstance::STOPPED, | 78 STOPPED = EmbeddedWorkerInstance::STOPPED, |
77 STARTING = EmbeddedWorkerInstance::STARTING, | 79 STARTING = EmbeddedWorkerInstance::STARTING, |
78 RUNNING = EmbeddedWorkerInstance::RUNNING, | 80 RUNNING = EmbeddedWorkerInstance::RUNNING, |
79 STOPPING = EmbeddedWorkerInstance::STOPPING, | 81 STOPPING = EmbeddedWorkerInstance::STOPPING, |
80 }; | 82 }; |
81 | 83 |
82 // Current version status; some of the status (e.g. INSTALLED and ACTIVATED) | 84 // Current version status; some of the status (e.g. INSTALLED and ACTIVATED) |
83 // should be persisted unlike running status. | 85 // should be persisted unlike running status. |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 // any transferred message ports are put on hold while potentially a process | 254 // any transferred message ports are put on hold while potentially a process |
253 // for the service worker is spun up. | 255 // for the service worker is spun up. |
254 // | 256 // |
255 // This must be called when the status() is ACTIVATED. | 257 // This must be called when the status() is ACTIVATED. |
256 void DispatchCrossOriginMessageEvent( | 258 void DispatchCrossOriginMessageEvent( |
257 const NavigatorConnectClient& client, | 259 const NavigatorConnectClient& client, |
258 const base::string16& message, | 260 const base::string16& message, |
259 const std::vector<TransferredMessagePort>& sent_message_ports, | 261 const std::vector<TransferredMessagePort>& sent_message_ports, |
260 const StatusCallback& callback); | 262 const StatusCallback& callback); |
261 | 263 |
| 264 // Transfers one or more stashed message ports to the associated embedded |
| 265 // worker, and asynchronously calls |callback| with the new route ids for the |
| 266 // transferred ports as soon as the ports are sent to the renderer. |
| 267 // Once the ports are received by the renderer, the ports themselves will |
| 268 // inform MessagePortService, which will enable actual messages to be sent. |
| 269 void SendStashedMessagePorts( |
| 270 const std::vector<TransferredMessagePort>& stashed_message_ports, |
| 271 const std::vector<base::string16>& port_names, |
| 272 const SendStashedPortsCallback& callback); |
| 273 |
262 // Adds and removes |provider_host| as a controllee of this ServiceWorker. | 274 // Adds and removes |provider_host| as a controllee of this ServiceWorker. |
263 // A potential controllee is a host having the version as its .installing | 275 // A potential controllee is a host having the version as its .installing |
264 // or .waiting version. | 276 // or .waiting version. |
265 void AddControllee(ServiceWorkerProviderHost* provider_host); | 277 void AddControllee(ServiceWorkerProviderHost* provider_host); |
266 void RemoveControllee(ServiceWorkerProviderHost* provider_host); | 278 void RemoveControllee(ServiceWorkerProviderHost* provider_host); |
267 | 279 |
268 // Returns if it has controllee. | 280 // Returns if it has controllee. |
269 bool HasControllee() const { return !controllee_map_.empty(); } | 281 bool HasControllee() const { return !controllee_map_.empty(); } |
270 | 282 |
271 // Adds and removes |request_job| as a dependent job not to stop the | 283 // Adds and removes |request_job| as a dependent job not to stop the |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 void OnClearCachedMetadataFinished(int64 callback_id, int result); | 434 void OnClearCachedMetadataFinished(int64 callback_id, int result); |
423 | 435 |
424 void OnPostMessageToClient( | 436 void OnPostMessageToClient( |
425 const std::string& client_uuid, | 437 const std::string& client_uuid, |
426 const base::string16& message, | 438 const base::string16& message, |
427 const std::vector<TransferredMessagePort>& sent_message_ports); | 439 const std::vector<TransferredMessagePort>& sent_message_ports); |
428 void OnFocusClient(int request_id, const std::string& client_uuid); | 440 void OnFocusClient(int request_id, const std::string& client_uuid); |
429 void OnSkipWaiting(int request_id); | 441 void OnSkipWaiting(int request_id); |
430 void OnClaimClients(int request_id); | 442 void OnClaimClients(int request_id); |
431 void OnPongFromWorker(); | 443 void OnPongFromWorker(); |
| 444 void OnStashMessagePort(int message_port_id, const base::string16& name); |
432 | 445 |
433 void OnFocusClientFinished(int request_id, | 446 void OnFocusClientFinished(int request_id, |
434 const std::string& client_uuid, | 447 const std::string& client_uuid, |
435 const ServiceWorkerClientInfo& client); | 448 const ServiceWorkerClientInfo& client); |
436 | 449 |
437 void DidEnsureLiveRegistrationForStartWorker( | 450 void DidEnsureLiveRegistrationForStartWorker( |
438 bool pause_after_download, | 451 bool pause_after_download, |
439 const StatusCallback& callback, | 452 const StatusCallback& callback, |
440 ServiceWorkerStatusCode status, | 453 ServiceWorkerStatusCode status, |
441 const scoped_refptr<ServiceWorkerRegistration>& protect); | 454 const scoped_refptr<ServiceWorkerRegistration>& protect); |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
558 scoped_ptr<ServiceWorkerEventMetrics> metrics_; | 571 scoped_ptr<ServiceWorkerEventMetrics> metrics_; |
559 | 572 |
560 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; | 573 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; |
561 | 574 |
562 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); | 575 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); |
563 }; | 576 }; |
564 | 577 |
565 } // namespace content | 578 } // namespace content |
566 | 579 |
567 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 580 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
OLD | NEW |