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

Unified Diff: content/browser/service_worker/service_worker_write_to_cache_job_unittest.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_write_to_cache_job_unittest.cc
diff --git a/content/browser/service_worker/service_worker_write_to_cache_job_unittest.cc b/content/browser/service_worker/service_worker_write_to_cache_job_unittest.cc
index 317ade5ef146e4a23b1f020d7c9bdf9b9c4a309a..1c5cd4d921e3dc282d21d8af14d9a748979be6d0 100644
--- a/content/browser/service_worker/service_worker_write_to_cache_job_unittest.cc
+++ b/content/browser/service_worker/service_worker_write_to_cache_job_unittest.cc
@@ -288,16 +288,14 @@ class ServiceWorkerWriteToCacheJobTest : public testing::Test {
base::WeakPtr<ServiceWorkerProviderHost> CreateHostForVersion(
int process_id,
- int provider_id,
const scoped_refptr<ServiceWorkerVersion>& version) {
std::unique_ptr<ServiceWorkerProviderHost> host =
CreateProviderHostForServiceWorkerContext(
- process_id, provider_id, true /* is_parent_frame_secure */,
+ process_id, true /* is_parent_frame_secure */, version.get(),
context()->AsWeakPtr(), &remote_endpoint_);
- base::WeakPtr<ServiceWorkerProviderHost> provider_host = host->AsWeakPtr();
+ base::WeakPtr<ServiceWorkerProviderHost> host_weakptr = host->AsWeakPtr();
context()->AddProviderHost(std::move(host));
- provider_host->running_hosted_version_ = version;
- return provider_host;
+ return host_weakptr;
}
void SetUpScriptRequest(int process_id, int provider_id) {
@@ -327,11 +325,9 @@ class ServiceWorkerWriteToCacheJobTest : public testing::Test {
scoped_refptr<ResourceRequestBodyImpl>());
}
- int NextProviderId() { return next_provider_id_++; }
int NextVersionId() { return next_version_id_++; }
void SetUp() override {
- int provider_id = NextProviderId();
helper_.reset(new EmbeddedWorkerTestHelper(base::FilePath()));
// A new unstored registration/version.
@@ -340,8 +336,8 @@ class ServiceWorkerWriteToCacheJobTest : public testing::Test {
version_ =
new ServiceWorkerVersion(registration_.get(), script_url_,
NextVersionId(), context()->AsWeakPtr());
- base::WeakPtr<ServiceWorkerProviderHost> host = CreateHostForVersion(
- helper_->mock_render_process_id(), provider_id, version_);
+ base::WeakPtr<ServiceWorkerProviderHost> host =
+ CreateHostForVersion(helper_->mock_render_process_id(), version_);
ASSERT_TRUE(host);
SetUpScriptRequest(helper_->mock_render_process_id(), host->provider_id());
@@ -391,14 +387,13 @@ class ServiceWorkerWriteToCacheJobTest : public testing::Test {
// to the script |response|. Returns the new version.
scoped_refptr<ServiceWorkerVersion> UpdateScript(
const std::string& response) {
- int provider_id = NextProviderId();
scoped_refptr<ServiceWorkerVersion> new_version =
new ServiceWorkerVersion(registration_.get(), script_url_,
NextVersionId(), context()->AsWeakPtr());
new_version->set_pause_after_download(true);
- base::WeakPtr<ServiceWorkerProviderHost> host = CreateHostForVersion(
- helper_->mock_render_process_id(), provider_id, new_version);
-
+ base::WeakPtr<ServiceWorkerProviderHost> host =
+ CreateHostForVersion(helper_->mock_render_process_id(), new_version);
+ EXPECT_TRUE(host);
SetUpScriptRequest(helper_->mock_render_process_id(), host->provider_id());
mock_protocol_handler_->SetCreateJobCallback(
base::Bind(&CreateResponseJob, response));
@@ -435,7 +430,6 @@ class ServiceWorkerWriteToCacheJobTest : public testing::Test {
std::unique_ptr<EmbeddedWorkerTestHelper> helper_;
scoped_refptr<ServiceWorkerRegistration> registration_;
scoped_refptr<ServiceWorkerVersion> version_;
- base::WeakPtr<ServiceWorkerProviderHost> provider_host_;
std::unique_ptr<net::URLRequestContext> url_request_context_;
std::unique_ptr<net::URLRequestJobFactoryImpl> url_request_job_factory_;
std::unique_ptr<net::URLRequest> request_;

Powered by Google App Engine
This is Rietveld 408576698