Index: content/browser/service_worker/service_worker_provider_host.h |
diff --git a/content/browser/service_worker/service_worker_provider_host.h b/content/browser/service_worker/service_worker_provider_host.h |
index 8d5fee4ae4ce73d8e25dbf95a8821f8d689d734c..a851966b4d6becf68c0eea360e73e7f45c495e4f 100644 |
--- a/content/browser/service_worker/service_worker_provider_host.h |
+++ b/content/browser/service_worker/service_worker_provider_host.h |
@@ -22,11 +22,13 @@ |
#include "content/browser/service_worker/service_worker_registration.h" |
#include "content/common/content_export.h" |
#include "content/common/service_worker/service_worker_provider_host_info.h" |
+#include "content/common/service_worker/service_worker_provider_interfaces.mojom.h" |
#include "content/common/service_worker/service_worker_types.h" |
#include "content/common/worker_url_loader_factory_provider.mojom.h" |
#include "content/public/common/request_context_frame_type.h" |
#include "content/public/common/request_context_type.h" |
#include "content/public/common/resource_type.h" |
+#include "mojo/public/cpp/bindings/associated_binding.h" |
namespace storage { |
class BlobStorageContext; |
@@ -54,9 +56,20 @@ class WebContents; |
// |
// For providers hosting a running service worker, this class will observe |
// resource loads made directly by the service worker. |
+// |
+// This instance is created when navigation is started and |
falken
2017/05/30 04:12:31
s/This instance/A ServiceWorkerProviderHost instan
shimazu
2017/06/01 08:18:54
Addressed this at https://chromium-review.googleso
|
+// ServiceWorkerNetworkProvider is create on the renderer process. Mojo's |
falken
2017/05/30 04:12:32
s/create/created
shimazu
2017/06/01 08:18:54
Addressed this at https://chromium-review.googleso
|
+// connection from ServiceWorkerNetworkProvider is established on the creation |
+// time, and the instance is destroyed on disconnection from the renderer side. |
+// If PlzNavigate is turned on, this instance is pre-created on the browser |
falken
2017/05/30 04:12:32
s/this instance/an instance
shimazu
2017/06/01 08:18:54
Addressed this at https://chromium-review.googleso
|
+// before ServiceWorkerNetworkProvider is created on the renderer because |
+// navigation is possible to be initiated on the browser side. In that case, |
falken
2017/05/30 04:12:32
s/is possible to be/is/
shimazu
2017/06/01 08:18:54
Addressed this at https://chromium-review.googleso
|
+// establishment of Mojo's connection will be deferred until |
+// ServiceWorkerNetworkProvider is created on the renderer. |
falken
2017/05/30 04:12:31
Thanks for the comment!
shimazu
2017/06/01 08:18:54
Your welcome!:)
|
class CONTENT_EXPORT ServiceWorkerProviderHost |
: public NON_EXPORTED_BASE(ServiceWorkerRegistration::Listener), |
- public base::SupportsWeakPtr<ServiceWorkerProviderHost> { |
+ public base::SupportsWeakPtr<ServiceWorkerProviderHost>, |
+ public NON_EXPORTED_BASE(mojom::ServiceWorkerProviderHost) { |
public: |
using GetRegistrationForReadyCallback = |
base::Callback<void(ServiceWorkerRegistration* reigstration)>; |
@@ -84,7 +97,7 @@ class CONTENT_EXPORT ServiceWorkerProviderHost |
base::WeakPtr<ServiceWorkerContextCore> context, |
ServiceWorkerDispatcherHost* dispatcher_host); |
- virtual ~ServiceWorkerProviderHost(); |
+ ~ServiceWorkerProviderHost() override; |
const std::string& client_uuid() const { return client_uuid_; } |
int process_id() const { return render_process_id_; } |
@@ -250,7 +263,7 @@ class CONTENT_EXPORT ServiceWorkerProviderHost |
// Completes initialization of provider hosts used for navigation requests. |
void CompleteNavigationInitialized( |
int process_id, |
- int frame_routing_id, |
+ ServiceWorkerProviderHostInfo info, |
ServiceWorkerDispatcherHost* dispatcher_host); |
// Sends event messages to the renderer. Events for the worker are queued up |
@@ -318,7 +331,7 @@ class CONTENT_EXPORT ServiceWorkerProviderHost |
~OneShotGetReadyCallback(); |
}; |
- ServiceWorkerProviderHost(int render_process_id, |
+ ServiceWorkerProviderHost(int process_id, |
ServiceWorkerProviderHostInfo info, |
base::WeakPtr<ServiceWorkerContextCore> context, |
ServiceWorkerDispatcherHost* dispatcher_host); |
@@ -403,6 +416,14 @@ class CONTENT_EXPORT ServiceWorkerProviderHost |
ServiceWorkerDispatcherHost* dispatcher_host_; |
bool allow_association_; |
+ // |provider_| is the renderer-side Mojo endpoint for provider. |
+ mojom::ServiceWorkerProviderAssociatedPtr provider_; |
+ // |binding_| is the Mojo binding that keeps the connection to the |
+ // renderer-side counterpart (content::ServiceWorkerNetworkProvider). When the |
+ // connection bound on |binding_| gets killed from the renderer side, this |
+ // content::ServiceWorkerProviderHost will be destroyed. |
+ mojo::AssociatedBinding<mojom::ServiceWorkerProviderHost> binding_; |
+ |
std::vector<base::Closure> queued_events_; |
// Keeps ServiceWorkerWorkerClient pointers of dedicated or shared workers |