| 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> |
| 12 #include <memory> |
| 11 #include <set> | 13 #include <set> |
| 14 #include <string> |
| 12 #include <vector> | 15 #include <vector> |
| 13 | 16 |
| 14 #include "base/gtest_prod_util.h" | 17 #include "base/gtest_prod_util.h" |
| 15 #include "base/macros.h" | 18 #include "base/macros.h" |
| 16 #include "base/memory/ref_counted.h" | 19 #include "base/memory/ref_counted.h" |
| 17 #include "base/memory/weak_ptr.h" | 20 #include "base/memory/weak_ptr.h" |
| 18 #include "content/browser/service_worker/service_worker_registration.h" | 21 #include "content/browser/service_worker/service_worker_registration.h" |
| 19 #include "content/common/content_export.h" | 22 #include "content/common/content_export.h" |
| 20 #include "content/common/service_worker/service_worker_types.h" | 23 #include "content/common/service_worker/service_worker_types.h" |
| 21 #include "content/public/common/request_context_frame_type.h" | 24 #include "content/public/common/request_context_frame_type.h" |
| 22 #include "content/public/common/request_context_type.h" | 25 #include "content/public/common/request_context_type.h" |
| 23 #include "content/public/common/resource_type.h" | 26 #include "content/public/common/resource_type.h" |
| 24 | 27 |
| 25 namespace IPC { | |
| 26 class Sender; | |
| 27 } | |
| 28 | |
| 29 namespace storage { | 28 namespace storage { |
| 30 class BlobStorageContext; | 29 class BlobStorageContext; |
| 31 } | 30 } |
| 32 | 31 |
| 33 namespace content { | 32 namespace content { |
| 34 | 33 |
| 35 class ResourceRequestBodyImpl; | 34 class ResourceRequestBodyImpl; |
| 36 class ServiceWorkerContextCore; | 35 class ServiceWorkerContextCore; |
| 37 class ServiceWorkerDispatcherHost; | 36 class ServiceWorkerDispatcherHost; |
| 38 class ServiceWorkerRequestHandler; | 37 class ServiceWorkerRequestHandler; |
| 39 class ServiceWorkerVersion; | 38 class ServiceWorkerVersion; |
| 40 | 39 |
| 41 // This class is the browser-process representation of a service worker | 40 // This class is the browser-process representation of a service worker |
| 42 // provider. There is a provider per document or a worker and the lifetime | 41 // provider. There are two general types of providers: 1) those for a client |
| 43 // of this object is tied to the lifetime of its document or the worker | 42 // (windows, dedicated workers, or shared workers), and 2) those for hosting a |
| 44 // in the renderer process. | 43 // running service worker. |
| 45 // This class holds service worker state that is scoped to an individual | |
| 46 // document or a worker. | |
| 47 // | 44 // |
| 48 // Note this class can also host a running service worker, in which | 45 // For client providers, there is a provider per document or a worker and the |
| 49 // case it will observe resource loads made directly by the service worker. | 46 // lifetime of this object is tied to the lifetime of its document or the worker |
| 47 // in the renderer process. This class holds service worker state that is scoped |
| 48 // to an individual document or a worker. |
| 49 // |
| 50 // For providers hosting a running service worker, this class will observe |
| 51 // resource loads made directly by the service worker. |
| 50 class CONTENT_EXPORT ServiceWorkerProviderHost | 52 class CONTENT_EXPORT ServiceWorkerProviderHost |
| 51 : public NON_EXPORTED_BASE(ServiceWorkerRegistration::Listener), | 53 : public NON_EXPORTED_BASE(ServiceWorkerRegistration::Listener), |
| 52 public base::SupportsWeakPtr<ServiceWorkerProviderHost> { | 54 public base::SupportsWeakPtr<ServiceWorkerProviderHost> { |
| 53 public: | 55 public: |
| 54 using GetRegistrationForReadyCallback = | 56 using GetRegistrationForReadyCallback = |
| 55 base::Callback<void(ServiceWorkerRegistration* reigstration)>; | 57 base::Callback<void(ServiceWorkerRegistration* reigstration)>; |
| 56 | 58 |
| 57 // PlzNavigate | 59 // PlzNavigate |
| 58 // Used to pre-create a ServiceWorkerProviderHost for a navigation. The | 60 // Used to pre-create a ServiceWorkerProviderHost for a navigation. The |
| 59 // ServiceWorkerNetworkProvider will later be created in the renderer, should | 61 // ServiceWorkerNetworkProvider will later be created in the renderer, should |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 318 bool IsReadyToSendMessages() const; | 320 bool IsReadyToSendMessages() const; |
| 319 void Send(IPC::Message* message) const; | 321 void Send(IPC::Message* message) const; |
| 320 | 322 |
| 321 // Finalizes cross-site transfers and navigation-initalized hosts. | 323 // Finalizes cross-site transfers and navigation-initalized hosts. |
| 322 void FinalizeInitialization(int process_id, | 324 void FinalizeInitialization(int process_id, |
| 323 int frame_routing_id, | 325 int frame_routing_id, |
| 324 ServiceWorkerDispatcherHost* dispatcher_host); | 326 ServiceWorkerDispatcherHost* dispatcher_host); |
| 325 | 327 |
| 326 std::string client_uuid_; | 328 std::string client_uuid_; |
| 327 int render_process_id_; | 329 int render_process_id_; |
| 330 |
| 331 // See the constructor's documentation. |
| 328 int route_id_; | 332 int route_id_; |
| 333 |
| 334 // For provider hosts that are hosting a running service worker, the id of the |
| 335 // service worker thread. Otherwise, |kDocumentMainThreadId|. May be |
| 336 // |kInvalidEmbeddedWorkerThreadId| before the hosted service worker starts |
| 337 // up, or during cross-site transfers. |
| 329 int render_thread_id_; | 338 int render_thread_id_; |
| 339 |
| 340 // Unique within the renderer process. |
| 330 int provider_id_; | 341 int provider_id_; |
| 342 |
| 331 ServiceWorkerProviderType provider_type_; | 343 ServiceWorkerProviderType provider_type_; |
| 332 FrameSecurityLevel parent_frame_security_level_; | 344 FrameSecurityLevel parent_frame_security_level_; |
| 333 GURL document_url_; | 345 GURL document_url_; |
| 334 GURL topmost_frame_url_; | 346 GURL topmost_frame_url_; |
| 335 | 347 |
| 336 std::vector<GURL> associated_patterns_; | 348 std::vector<GURL> associated_patterns_; |
| 337 scoped_refptr<ServiceWorkerRegistration> associated_registration_; | 349 scoped_refptr<ServiceWorkerRegistration> associated_registration_; |
| 338 | 350 |
| 339 // Keyed by registration scope URL length. | 351 // Keyed by registration scope URL length. |
| 340 typedef std::map<size_t, scoped_refptr<ServiceWorkerRegistration>> | 352 typedef std::map<size_t, scoped_refptr<ServiceWorkerRegistration>> |
| (...skipping 11 matching lines...) Expand all Loading... |
| 352 bool allow_association_; | 364 bool allow_association_; |
| 353 | 365 |
| 354 std::vector<base::Closure> queued_events_; | 366 std::vector<base::Closure> queued_events_; |
| 355 | 367 |
| 356 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderHost); | 368 DISALLOW_COPY_AND_ASSIGN(ServiceWorkerProviderHost); |
| 357 }; | 369 }; |
| 358 | 370 |
| 359 } // namespace content | 371 } // namespace content |
| 360 | 372 |
| 361 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ | 373 #endif // CONTENT_BROWSER_SERVICE_WORKER_SERVICE_WORKER_PROVIDER_HOST_H_ |
| OLD | NEW |