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 <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 | 46 |
47 class EmbeddedWorkerRegistry; | 47 class EmbeddedWorkerRegistry; |
48 class ServiceWorkerContextCore; | 48 class ServiceWorkerContextCore; |
49 class ServiceWorkerProviderHost; | 49 class ServiceWorkerProviderHost; |
50 class ServiceWorkerRegistration; | 50 class ServiceWorkerRegistration; |
51 class ServiceWorkerURLRequestJob; | 51 class ServiceWorkerURLRequestJob; |
52 class ServiceWorkerVersionInfo; | 52 class ServiceWorkerVersionInfo; |
53 struct NavigatorConnectClient; | 53 struct NavigatorConnectClient; |
54 struct PlatformNotificationData; | 54 struct PlatformNotificationData; |
55 struct ServiceWorkerClientInfo; | 55 struct ServiceWorkerClientInfo; |
| 56 struct TransferredMessagePort; |
56 | 57 |
57 // This class corresponds to a specific version of a ServiceWorker | 58 // This class corresponds to a specific version of a ServiceWorker |
58 // script for a given pattern. When a script is upgraded, there may be | 59 // script for a given pattern. When a script is upgraded, there may be |
59 // more than one ServiceWorkerVersion "running" at a time, but only | 60 // more than one ServiceWorkerVersion "running" at a time, but only |
60 // one of them is activated. This class connects the actual script with a | 61 // one of them is activated. This class connects the actual script with a |
61 // running worker. | 62 // running worker. |
62 class CONTENT_EXPORT ServiceWorkerVersion | 63 class CONTENT_EXPORT ServiceWorkerVersion |
63 : NON_EXPORTED_BASE(public base::RefCounted<ServiceWorkerVersion>), | 64 : NON_EXPORTED_BASE(public base::RefCounted<ServiceWorkerVersion>), |
64 public EmbeddedWorkerInstance::Listener { | 65 public EmbeddedWorkerInstance::Listener { |
65 public: | 66 public: |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 void StartUpdate(); | 167 void StartUpdate(); |
167 | 168 |
168 // Sends an IPC message to the worker. | 169 // Sends an IPC message to the worker. |
169 // If the worker is not running this first tries to start it by | 170 // If the worker is not running this first tries to start it by |
170 // calling StartWorker internally. | 171 // calling StartWorker internally. |
171 // |callback| can be null if the sender does not need to know if the | 172 // |callback| can be null if the sender does not need to know if the |
172 // message is successfully sent or not. | 173 // message is successfully sent or not. |
173 void SendMessage(const IPC::Message& message, const StatusCallback& callback); | 174 void SendMessage(const IPC::Message& message, const StatusCallback& callback); |
174 | 175 |
175 // Sends a message event to the associated embedded worker. | 176 // Sends a message event to the associated embedded worker. |
176 void DispatchMessageEvent(const base::string16& message, | 177 void DispatchMessageEvent( |
177 const std::vector<int>& sent_message_port_ids, | 178 const base::string16& message, |
178 const StatusCallback& callback); | 179 const std::vector<TransferredMessagePort>& sent_message_ports, |
| 180 const StatusCallback& callback); |
179 | 181 |
180 // Sends install event to the associated embedded worker and asynchronously | 182 // Sends install event to the associated embedded worker and asynchronously |
181 // calls |callback| when it errors out or it gets a response from the worker | 183 // calls |callback| when it errors out or it gets a response from the worker |
182 // to notify install completion. | 184 // to notify install completion. |
183 // |active_version_id| must be a valid positive ID | 185 // |active_version_id| must be a valid positive ID |
184 // if there's an activated (previous) version running. | 186 // if there's an activated (previous) version running. |
185 // | 187 // |
186 // This must be called when the status() is NEW. Calling this changes | 188 // This must be called when the status() is NEW. Calling this changes |
187 // the version's status to INSTALLING. | 189 // the version's status to INSTALLING. |
188 // Upon completion, the version's status will be changed to INSTALLED | 190 // Upon completion, the version's status will be changed to INSTALLED |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 // asynchronously calls |callback| when the message was sent (or failed to | 259 // asynchronously calls |callback| when the message was sent (or failed to |
258 // sent). | 260 // sent). |
259 // It is the responsibility of the code calling this method to make sure that | 261 // It is the responsibility of the code calling this method to make sure that |
260 // any transferred message ports are put on hold while potentially a process | 262 // any transferred message ports are put on hold while potentially a process |
261 // for the service worker is spun up. | 263 // for the service worker is spun up. |
262 // | 264 // |
263 // This must be called when the status() is ACTIVATED. | 265 // This must be called when the status() is ACTIVATED. |
264 void DispatchCrossOriginMessageEvent( | 266 void DispatchCrossOriginMessageEvent( |
265 const NavigatorConnectClient& client, | 267 const NavigatorConnectClient& client, |
266 const base::string16& message, | 268 const base::string16& message, |
267 const std::vector<int>& sent_message_port_ids, | 269 const std::vector<TransferredMessagePort>& sent_message_ports, |
268 const StatusCallback& callback); | 270 const StatusCallback& callback); |
269 | 271 |
270 // Adds and removes |provider_host| as a controllee of this ServiceWorker. | 272 // Adds and removes |provider_host| as a controllee of this ServiceWorker. |
271 // A potential controllee is a host having the version as its .installing | 273 // A potential controllee is a host having the version as its .installing |
272 // or .waiting version. | 274 // or .waiting version. |
273 void AddControllee(ServiceWorkerProviderHost* provider_host); | 275 void AddControllee(ServiceWorkerProviderHost* provider_host); |
274 void RemoveControllee(ServiceWorkerProviderHost* provider_host); | 276 void RemoveControllee(ServiceWorkerProviderHost* provider_host); |
275 | 277 |
276 // Returns if it has controllee. | 278 // Returns if it has controllee. |
277 bool HasControllee() const { return !controllee_map_.empty(); } | 279 bool HasControllee() const { return !controllee_map_.empty(); } |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 bool OnMessageReceived(const IPC::Message& message) override; | 347 bool OnMessageReceived(const IPC::Message& message) override; |
346 | 348 |
347 void OnStartMessageSent(ServiceWorkerStatusCode status); | 349 void OnStartMessageSent(ServiceWorkerStatusCode status); |
348 | 350 |
349 void DispatchInstallEventAfterStartWorker(int active_version_id, | 351 void DispatchInstallEventAfterStartWorker(int active_version_id, |
350 const StatusCallback& callback); | 352 const StatusCallback& callback); |
351 void DispatchActivateEventAfterStartWorker(const StatusCallback& callback); | 353 void DispatchActivateEventAfterStartWorker(const StatusCallback& callback); |
352 | 354 |
353 void DispatchMessageEventInternal( | 355 void DispatchMessageEventInternal( |
354 const base::string16& message, | 356 const base::string16& message, |
355 const std::vector<int>& sent_message_port_ids, | 357 const std::vector<TransferredMessagePort>& sent_message_ports, |
356 const StatusCallback& callback); | 358 const StatusCallback& callback); |
357 | 359 |
358 // Message handlers. | 360 // Message handlers. |
359 void OnGetClientDocuments(int request_id); | 361 void OnGetClientDocuments(int request_id); |
360 void OnActivateEventFinished(int request_id, | 362 void OnActivateEventFinished(int request_id, |
361 blink::WebServiceWorkerEventResult result); | 363 blink::WebServiceWorkerEventResult result); |
362 void OnInstallEventFinished(int request_id, | 364 void OnInstallEventFinished(int request_id, |
363 blink::WebServiceWorkerEventResult result); | 365 blink::WebServiceWorkerEventResult result); |
364 void OnFetchEventFinished(int request_id, | 366 void OnFetchEventFinished(int request_id, |
365 ServiceWorkerFetchEventResult result, | 367 ServiceWorkerFetchEventResult result, |
(...skipping 11 matching lines...) Expand all Loading... |
377 int render_frame_id); | 379 int render_frame_id); |
378 void OnOpenWindowFinished(int request_id, | 380 void OnOpenWindowFinished(int request_id, |
379 int client_id, | 381 int client_id, |
380 const ServiceWorkerClientInfo& client_info); | 382 const ServiceWorkerClientInfo& client_info); |
381 | 383 |
382 void OnSetCachedMetadata(const GURL& url, const std::vector<char>& data); | 384 void OnSetCachedMetadata(const GURL& url, const std::vector<char>& data); |
383 void OnSetCachedMetadataFinished(int64 callback_id, int result); | 385 void OnSetCachedMetadataFinished(int64 callback_id, int result); |
384 void OnClearCachedMetadata(const GURL& url); | 386 void OnClearCachedMetadata(const GURL& url); |
385 void OnClearCachedMetadataFinished(int64 callback_id, int result); | 387 void OnClearCachedMetadataFinished(int64 callback_id, int result); |
386 | 388 |
387 void OnPostMessageToDocument(int client_id, | 389 void OnPostMessageToDocument( |
388 const base::string16& message, | 390 int client_id, |
389 const std::vector<int>& sent_message_port_ids); | 391 const base::string16& message, |
| 392 const std::vector<TransferredMessagePort>& sent_message_ports); |
390 void OnFocusClient(int request_id, int client_id); | 393 void OnFocusClient(int request_id, int client_id); |
391 void OnSkipWaiting(int request_id); | 394 void OnSkipWaiting(int request_id); |
392 void OnClaimClients(int request_id); | 395 void OnClaimClients(int request_id); |
393 void OnPongFromWorker(); | 396 void OnPongFromWorker(); |
394 | 397 |
395 void OnFocusClientFinished(int request_id, | 398 void OnFocusClientFinished(int request_id, |
396 int client_id, | 399 int client_id, |
397 const ServiceWorkerClientInfo& client); | 400 const ServiceWorkerClientInfo& client); |
398 | 401 |
399 void DidSkipWaiting(int request_id); | 402 void DidSkipWaiting(int request_id); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 scoped_ptr<net::HttpResponseInfo> main_script_http_info_; | 467 scoped_ptr<net::HttpResponseInfo> main_script_http_info_; |
465 | 468 |
466 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; | 469 base::WeakPtrFactory<ServiceWorkerVersion> weak_factory_; |
467 | 470 |
468 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); | 471 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerVersion); |
469 }; | 472 }; |
470 | 473 |
471 } // namespace content | 474 } // namespace content |
472 | 475 |
473 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ | 476 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_VERSION_H_ |
OLD | NEW |