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

Unified Diff: content/browser/service_worker/service_worker_test_utils.cc

Issue 2779763004: Create ServiceWorkerProviderHost before starting worker (Closed)
Patch Set: Pass the param of BindWithProviderInfo by value instead of pointer Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/service_worker/service_worker_test_utils.cc
diff --git a/content/browser/service_worker/service_worker_test_utils.cc b/content/browser/service_worker/service_worker_test_utils.cc
index 4c8f7390b91924cba6bc779d126ad9be89b5cfe6..7d9941668b8b87cac9b01efc57879949a8bef346 100644
--- a/content/browser/service_worker/service_worker_test_utils.cc
+++ b/content/browser/service_worker/service_worker_test_utils.cc
@@ -7,6 +7,8 @@
#include <utility>
#include "content/browser/service_worker/service_worker_provider_host.h"
+#include "content/common/service_worker/service_worker_provider.mojom.h"
+#include "content/public/common/child_process_host.h"
namespace content {
@@ -26,6 +28,12 @@ void ServiceWorkerRemoteProviderEndpoint::BindWithProviderHostInfo(
info->host_request = mojo::MakeIsolatedRequest(&host_ptr_);
}
+void ServiceWorkerRemoteProviderEndpoint::BindWithProviderInfo(
+ mojom::ServiceWorkerProviderInfoForStartWorkerPtr info) {
+ client_request_ = std::move(info->client_request);
+ host_ptr_.Bind(std::move(info->host_ptr_info));
+}
+
std::unique_ptr<ServiceWorkerProviderHost> CreateProviderHostForWindow(
int process_id,
int provider_id,
@@ -43,16 +51,19 @@ std::unique_ptr<ServiceWorkerProviderHost> CreateProviderHostForWindow(
std::unique_ptr<ServiceWorkerProviderHost>
CreateProviderHostForServiceWorkerContext(
int process_id,
- int provider_id,
bool is_parent_frame_secure,
+ ServiceWorkerVersion* hosted_version,
base::WeakPtr<ServiceWorkerContextCore> context,
ServiceWorkerRemoteProviderEndpoint* output_endpoint) {
- ServiceWorkerProviderHostInfo info(provider_id, MSG_ROUTING_NONE,
- SERVICE_WORKER_PROVIDER_FOR_CONTROLLER,
- is_parent_frame_secure);
- output_endpoint->BindWithProviderHostInfo(&info);
- return ServiceWorkerProviderHost::Create(process_id, std::move(info),
- std::move(context), nullptr);
+ ServiceWorkerProviderHostInfo info(
+ kInvalidServiceWorkerProviderId, MSG_ROUTING_NONE,
+ SERVICE_WORKER_PROVIDER_FOR_CONTROLLER, is_parent_frame_secure);
+ std::unique_ptr<ServiceWorkerProviderHost> host =
+ ServiceWorkerProviderHost::PreCreateForController(std::move(context));
+ mojom::ServiceWorkerProviderInfoForStartWorkerPtr provider_info =
+ host->CompleteStartWorkerPreparation(process_id, hosted_version);
+ output_endpoint->BindWithProviderInfo(std::move(provider_info));
+ return host;
}
std::unique_ptr<ServiceWorkerProviderHost> CreateProviderHostWithDispatcherHost(

Powered by Google App Engine
This is Rietveld 408576698