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_PROVIDER_HOST_H_ | 5 #ifndef CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ |
6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ | 6 #define CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <map> | 11 #include <map> |
12 #include <memory> | 12 #include <memory> |
13 #include <set> | 13 #include <set> |
14 #include <string> | 14 #include <string> |
| 15 #include <unordered_map> |
15 #include <vector> | 16 #include <vector> |
16 | 17 |
17 #include "base/gtest_prod_util.h" | 18 #include "base/gtest_prod_util.h" |
18 #include "base/macros.h" | 19 #include "base/macros.h" |
19 #include "base/memory/ref_counted.h" | 20 #include "base/memory/ref_counted.h" |
20 #include "base/memory/weak_ptr.h" | 21 #include "base/memory/weak_ptr.h" |
21 #include "content/browser/service_worker/service_worker_registration.h" | 22 #include "content/browser/service_worker/service_worker_registration.h" |
22 #include "content/common/content_export.h" | 23 #include "content/common/content_export.h" |
23 #include "content/common/service_worker/service_worker_provider_host_info.h" | 24 #include "content/common/service_worker/service_worker_provider_host_info.h" |
24 #include "content/common/service_worker/service_worker_types.h" | 25 #include "content/common/service_worker/service_worker_types.h" |
| 26 #include "content/common/worker_url_loader_factory_provider.mojom.h" |
25 #include "content/public/common/request_context_frame_type.h" | 27 #include "content/public/common/request_context_frame_type.h" |
26 #include "content/public/common/request_context_type.h" | 28 #include "content/public/common/request_context_type.h" |
27 #include "content/public/common/resource_type.h" | 29 #include "content/public/common/resource_type.h" |
28 | 30 |
29 namespace storage { | 31 namespace storage { |
30 class BlobStorageContext; | 32 class BlobStorageContext; |
31 } | 33 } |
32 | 34 |
33 namespace content { | 35 namespace content { |
34 | 36 |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 | 280 |
279 // An optimized implementation of [[Match Service Worker Registration]] | 281 // An optimized implementation of [[Match Service Worker Registration]] |
280 // for current document. | 282 // for current document. |
281 ServiceWorkerRegistration* MatchRegistration() const; | 283 ServiceWorkerRegistration* MatchRegistration() const; |
282 | 284 |
283 // Called when our controller has been terminated and doomed due to an | 285 // Called when our controller has been terminated and doomed due to an |
284 // exceptional condition like it could no longer be read from the script | 286 // exceptional condition like it could no longer be read from the script |
285 // cache. | 287 // cache. |
286 void NotifyControllerLost(); | 288 void NotifyControllerLost(); |
287 | 289 |
| 290 // Binds the ServiceWorkerWorkerClient of a dedicated (or shared) worker to |
| 291 // the parent frame's ServiceWorkerProviderHost. (This is used only when |
| 292 // off-main-thread-fetch is enabled.) |
| 293 void BindWorkerFetchContext( |
| 294 mojom::ServiceWorkerWorkerClientAssociatedPtrInfo client_ptr_info); |
| 295 |
288 private: | 296 private: |
289 friend class ForeignFetchRequestHandlerTest; | 297 friend class ForeignFetchRequestHandlerTest; |
290 friend class LinkHeaderServiceWorkerTest; | 298 friend class LinkHeaderServiceWorkerTest; |
291 friend class ServiceWorkerProviderHostTest; | 299 friend class ServiceWorkerProviderHostTest; |
292 friend class ServiceWorkerWriteToCacheJobTest; | 300 friend class ServiceWorkerWriteToCacheJobTest; |
293 friend class ServiceWorkerContextRequestHandlerTest; | 301 friend class ServiceWorkerContextRequestHandlerTest; |
294 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerWriteToCacheJobTest, Update_SameScript); | 302 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerWriteToCacheJobTest, Update_SameScript); |
295 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerWriteToCacheJobTest, | 303 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerWriteToCacheJobTest, |
296 Update_SameSizeScript); | 304 Update_SameSizeScript); |
297 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerWriteToCacheJobTest, | 305 FRIEND_TEST_ALL_PREFIXES(ServiceWorkerWriteToCacheJobTest, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
354 void ReturnRegistrationForReadyIfNeeded(); | 362 void ReturnRegistrationForReadyIfNeeded(); |
355 | 363 |
356 bool IsReadyToSendMessages() const; | 364 bool IsReadyToSendMessages() const; |
357 void Send(IPC::Message* message) const; | 365 void Send(IPC::Message* message) const; |
358 | 366 |
359 // Finalizes cross-site transfers and navigation-initalized hosts. | 367 // Finalizes cross-site transfers and navigation-initalized hosts. |
360 void FinalizeInitialization(int process_id, | 368 void FinalizeInitialization(int process_id, |
361 int frame_routing_id, | 369 int frame_routing_id, |
362 ServiceWorkerDispatcherHost* dispatcher_host); | 370 ServiceWorkerDispatcherHost* dispatcher_host); |
363 | 371 |
| 372 // Clears the information of the ServiceWorkerWorkerClient of dedicated (or |
| 373 // shared) worker, when the connection to the worker is disconnected. |
| 374 void UnregisterWorkerFetchContext(mojom::ServiceWorkerWorkerClient*); |
| 375 |
364 std::string client_uuid_; | 376 std::string client_uuid_; |
365 int render_process_id_; | 377 int render_process_id_; |
366 | 378 |
367 // See the constructor's documentation. | 379 // See the constructor's documentation. |
368 int route_id_; | 380 int route_id_; |
369 | 381 |
370 // For provider hosts that are hosting a running service worker, the id of the | 382 // For provider hosts that are hosting a running service worker, the id of the |
371 // service worker thread. Otherwise, |kDocumentMainThreadId|. May be | 383 // service worker thread. Otherwise, |kDocumentMainThreadId|. May be |
372 // |kInvalidEmbeddedWorkerThreadId| before the hosted service worker starts | 384 // |kInvalidEmbeddedWorkerThreadId| before the hosted service worker starts |
373 // up, or during cross-site transfers. | 385 // up, or during cross-site transfers. |
(...skipping 25 matching lines...) Expand all Loading... |
399 | 411 |
400 std::unique_ptr<OneShotGetReadyCallback> get_ready_callback_; | 412 std::unique_ptr<OneShotGetReadyCallback> get_ready_callback_; |
401 scoped_refptr<ServiceWorkerVersion> controlling_version_; | 413 scoped_refptr<ServiceWorkerVersion> controlling_version_; |
402 scoped_refptr<ServiceWorkerVersion> running_hosted_version_; | 414 scoped_refptr<ServiceWorkerVersion> running_hosted_version_; |
403 base::WeakPtr<ServiceWorkerContextCore> context_; | 415 base::WeakPtr<ServiceWorkerContextCore> context_; |
404 ServiceWorkerDispatcherHost* dispatcher_host_; | 416 ServiceWorkerDispatcherHost* dispatcher_host_; |
405 bool allow_association_; | 417 bool allow_association_; |
406 | 418 |
407 std::vector<base::Closure> queued_events_; | 419 std::vector<base::Closure> queued_events_; |
408 | 420 |
| 421 // Keeps ServiceWorkerWorkerClient pointers of dedicated or shared workers |
| 422 // which are associated with the ServiceWorkerProviderHost. |
| 423 std::unordered_map<mojom::ServiceWorkerWorkerClient*, |
| 424 mojom::ServiceWorkerWorkerClientAssociatedPtr> |
| 425 worker_clients_; |
| 426 |
409 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderHost); | 427 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderHost); |
410 }; | 428 }; |
411 | 429 |
412 } // namespace content | 430 } // namespace content |
413 | 431 |
414 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ | 432 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ |
OLD | NEW |