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

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

Issue 1110103003: Initial implementation of stashed message ports, content side (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 5 years, 7 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>
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 void OnClearCachedMetadataFinished(int64 callback_id, int result); 432 void OnClearCachedMetadataFinished(int64 callback_id, int result);
421 433
422 void OnPostMessageToClient( 434 void OnPostMessageToClient(
423 const std::string& client_uuid, 435 const std::string& client_uuid,
424 const base::string16& message, 436 const base::string16& message,
425 const std::vector<TransferredMessagePort>& sent_message_ports); 437 const std::vector<TransferredMessagePort>& sent_message_ports);
426 void OnFocusClient(int request_id, const std::string& client_uuid); 438 void OnFocusClient(int request_id, const std::string& client_uuid);
427 void OnSkipWaiting(int request_id); 439 void OnSkipWaiting(int request_id);
428 void OnClaimClients(int request_id); 440 void OnClaimClients(int request_id);
429 void OnPongFromWorker(); 441 void OnPongFromWorker();
442 void OnStashMessagePort(int message_port_id, const base::string16& name);
430 443
431 void OnFocusClientFinished(int request_id, 444 void OnFocusClientFinished(int request_id,
432 const std::string& client_uuid, 445 const std::string& client_uuid,
433 const ServiceWorkerClientInfo& client); 446 const ServiceWorkerClientInfo& client);
434 447
435 void DidEnsureLiveRegistrationForStartWorker( 448 void DidEnsureLiveRegistrationForStartWorker(
436 bool pause_after_download, 449 bool pause_after_download,
437 const StatusCallback& callback, 450 const StatusCallback& callback,
438 ServiceWorkerStatusCode status, 451 ServiceWorkerStatusCode status,
439 const scoped_refptr<ServiceWorkerRegistration>& protect); 452 const scoped_refptr<ServiceWorkerRegistration>& protect);
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 ServiceWorkerStatusCode start_worker_status_ = SERVICE_WORKER_OK; 567 ServiceWorkerStatusCode start_worker_status_ = SERVICE_WORKER_OK;
555 568
556 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; 569 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_;
557 570
558 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); 571 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion);
559 }; 572 };
560 573
561 } // namespace content 574 } // namespace content
562 575
563 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ 576 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698