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

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

Issue 2936623002: Implement dumb URLLoader{Factory} for ServiceWorker script loading (for try)
Patch Set: . 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/embedded_worker_test_helper.cc
diff --git a/content/browser/service_worker/embedded_worker_test_helper.cc b/content/browser/service_worker/embedded_worker_test_helper.cc
index 3485ac1987f2bbef0cb9b690ad829564a0a4b118..a13843c82acf007fdecde6af0b0727b5de9b1297 100644
--- a/content/browser/service_worker/embedded_worker_test_helper.cc
+++ b/content/browser/service_worker/embedded_worker_test_helper.cc
@@ -73,7 +73,8 @@ EmbeddedWorkerTestHelper::MockEmbeddedWorkerInstanceClient::
void EmbeddedWorkerTestHelper::MockEmbeddedWorkerInstanceClient::StartWorker(
const EmbeddedWorkerStartParams& params,
mojom::ServiceWorkerEventDispatcherRequest dispatcher_request,
- mojom::EmbeddedWorkerInstanceHostAssociatedPtrInfo instance_host) {
+ mojom::EmbeddedWorkerInstanceHostAssociatedPtrInfo instance_host,
+ mojom::ServiceWorkerProviderClientInfoPtr provider_client_info) {
if (!helper_)
return;
@@ -85,7 +86,8 @@ void EmbeddedWorkerTestHelper::MockEmbeddedWorkerInstanceClient::StartWorker(
EXPECT_EQ(EmbeddedWorkerStatus::STARTING, worker->status());
helper_->OnStartWorkerStub(params, std::move(dispatcher_request),
- std::move(instance_host));
+ std::move(instance_host),
+ std::move(provider_client_info));
}
void EmbeddedWorkerTestHelper::MockEmbeddedWorkerInstanceClient::StopWorker() {
@@ -290,7 +292,6 @@ EmbeddedWorkerTestHelper::EmbeddedWorkerTestHelper(
wrapper_(new ServiceWorkerContextWrapper(browser_context_.get())),
mock_instance_clients_next_index_(0),
next_thread_id_(0),
- next_provider_id_(1000),
mock_render_process_id_(render_process_host_->GetID()),
new_mock_render_process_id_(new_render_process_host_->GetID()),
weak_factory_(this) {
@@ -298,7 +299,8 @@ EmbeddedWorkerTestHelper::EmbeddedWorkerTestHelper(
new MockServiceWorkerDatabaseTaskManager(
base::ThreadTaskRunnerHandle::Get()));
wrapper_->InitInternal(user_data_directory, std::move(database_task_manager),
- base::ThreadTaskRunnerHandle::Get(), nullptr, nullptr);
+ base::ThreadTaskRunnerHandle::Get(), nullptr, nullptr,
+ nullptr, nullptr);
wrapper_->process_manager()->SetProcessIdForTest(mock_render_process_id());
wrapper_->process_manager()->SetNewProcessIdForTest(new_render_process_id());
@@ -395,7 +397,8 @@ void EmbeddedWorkerTestHelper::OnStartWorker(
const GURL& script_url,
bool pause_after_download,
mojom::ServiceWorkerEventDispatcherRequest request,
- mojom::EmbeddedWorkerInstanceHostAssociatedPtrInfo instance_host) {
+ mojom::EmbeddedWorkerInstanceHostAssociatedPtrInfo instance_host,
+ mojom::ServiceWorkerProviderClientInfoPtr provider_client_info) {
EmbeddedWorkerInstance* worker = registry()->GetWorker(embedded_worker_id);
ASSERT_TRUE(worker);
MockServiceWorkerEventDispatcher::Create(AsWeakPtr(), worker->thread_id(),
@@ -405,6 +408,9 @@ void EmbeddedWorkerTestHelper::OnStartWorker(
service_worker_version_id;
embedded_worker_id_instance_host_ptr_map_[embedded_worker_id].Bind(
std::move(instance_host));
+ ServiceWorkerRemoteProviderEndpoint* provider_endpoint =
+ &embedded_worker_id_remote_provider_map_[embedded_worker_id];
+ provider_endpoint->BindWithProviderClientInfo(provider_client_info.get());
SimulateWorkerReadyForInspection(embedded_worker_id);
SimulateWorkerScriptCached(embedded_worker_id);
@@ -414,8 +420,7 @@ void EmbeddedWorkerTestHelper::OnStartWorker(
}
void EmbeddedWorkerTestHelper::OnResumeAfterDownload(int embedded_worker_id) {
- SimulateWorkerThreadStarted(GetNextThreadId(), embedded_worker_id,
- GetNextProviderId());
+ SimulateWorkerThreadStarted(GetNextThreadId(), embedded_worker_id);
SimulateWorkerScriptEvaluated(embedded_worker_id, true /* success */);
SimulateWorkerStarted(embedded_worker_id);
}
@@ -576,22 +581,12 @@ void EmbeddedWorkerTestHelper::SimulateWorkerScriptLoaded(
void EmbeddedWorkerTestHelper::SimulateWorkerThreadStarted(
int thread_id,
- int embedded_worker_id,
- int provider_id) {
+ int embedded_worker_id) {
EmbeddedWorkerInstance* worker = registry()->GetWorker(embedded_worker_id);
ASSERT_TRUE(worker);
ASSERT_TRUE(embedded_worker_id_instance_host_ptr_map_[embedded_worker_id]);
-
- // Prepare a provider host to be used by following OnThreadStarted().
- std::unique_ptr<ServiceWorkerProviderHost> host =
- CreateProviderHostForServiceWorkerContext(
- worker->process_id(), provider_id, true /* is_parent_frame_secure */,
- context()->AsWeakPtr(),
- &embedded_worker_id_remote_provider_map_[embedded_worker_id]);
- context()->AddProviderHost(std::move(host));
-
embedded_worker_id_instance_host_ptr_map_[embedded_worker_id]
- ->OnThreadStarted(thread_id, provider_id);
+ ->OnThreadStarted(thread_id);
base::RunLoop().RunUntilIdle();
}
@@ -631,7 +626,8 @@ void EmbeddedWorkerTestHelper::SimulateSend(IPC::Message* message) {
void EmbeddedWorkerTestHelper::OnStartWorkerStub(
const EmbeddedWorkerStartParams& params,
mojom::ServiceWorkerEventDispatcherRequest request,
- mojom::EmbeddedWorkerInstanceHostAssociatedPtrInfo instance_host) {
+ mojom::EmbeddedWorkerInstanceHostAssociatedPtrInfo instance_host,
+ mojom::ServiceWorkerProviderClientInfoPtr provider_client_info) {
EmbeddedWorkerInstance* worker =
registry()->GetWorker(params.embedded_worker_id);
ASSERT_TRUE(worker);
@@ -641,7 +637,8 @@ void EmbeddedWorkerTestHelper::OnStartWorkerStub(
base::Bind(&EmbeddedWorkerTestHelper::OnStartWorker, AsWeakPtr(),
params.embedded_worker_id, params.service_worker_version_id,
params.scope, params.script_url, params.pause_after_download,
- base::Passed(&request), base::Passed(&instance_host)));
+ base::Passed(&request), base::Passed(&instance_host),
+ base::Passed(&provider_client_info)));
}
void EmbeddedWorkerTestHelper::OnResumeAfterDownloadStub(

Powered by Google App Engine
This is Rietveld 408576698