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

Side by Side Diff: content/browser/service_worker/service_worker_registration_unittest.cc

Issue 2638313002: Manage ServiceWorkerDispatcherHost in ServiceWorkerContextCore (Closed)
Patch Set: Add a newline Created 3 years, 10 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 unified diff | Download patch
OLDNEW
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 #include "content/browser/service_worker/service_worker_registration.h" 5 #include "content/browser/service_worker/service_worker_registration.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/files/scoped_temp_dir.h" 10 #include "base/files/scoped_temp_dir.h"
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 version_1->SetMainScriptHttpResponseInfo( 249 version_1->SetMainScriptHttpResponseInfo(
250 EmbeddedWorkerTestHelper::CreateHttpResponseInfo()); 250 EmbeddedWorkerTestHelper::CreateHttpResponseInfo());
251 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_MAX_VALUE; 251 ServiceWorkerStatusCode status = SERVICE_WORKER_ERROR_MAX_VALUE;
252 context()->storage()->StoreRegistration( 252 context()->storage()->StoreRegistration(
253 registration_.get(), version_1.get(), 253 registration_.get(), version_1.get(),
254 CreateReceiverOnCurrentThread(&status)); 254 CreateReceiverOnCurrentThread(&status));
255 base::RunLoop().RunUntilIdle(); 255 base::RunLoop().RunUntilIdle();
256 ASSERT_EQ(SERVICE_WORKER_OK, status); 256 ASSERT_EQ(SERVICE_WORKER_OK, status);
257 257
258 // Give the active version a controllee. 258 // Give the active version a controllee.
259 host_.reset(new ServiceWorkerProviderHost( 259 host_ = ServiceWorkerProviderHost::CreateForTesting(
260 33 /* dummy render process id */, 260 33 /* dummy render process id */, 1 /* dummy provider_id */,
261 MSG_ROUTING_NONE /* render_frame_id */, 1 /* dummy provider_id */, 261 SERVICE_WORKER_PROVIDER_FOR_WINDOW, context()->AsWeakPtr());
262 SERVICE_WORKER_PROVIDER_FOR_WINDOW, 262 host_->set_parent_frame_secure(true);
263 ServiceWorkerProviderHost::FrameSecurityLevel::SECURE,
264 context()->AsWeakPtr(), nullptr));
265 version_1->AddControllee(host_.get()); 263 version_1->AddControllee(host_.get());
266 264
267 // Give the active version an in-flight request. 265 // Give the active version an in-flight request.
268 inflight_request_id_ = CreateInflightRequest(version_1.get()); 266 inflight_request_id_ = CreateInflightRequest(version_1.get());
269 267
270 // Create a waiting version. 268 // Create a waiting version.
271 scoped_refptr<ServiceWorkerVersion> version_2 = new ServiceWorkerVersion( 269 scoped_refptr<ServiceWorkerVersion> version_2 = new ServiceWorkerVersion(
272 registration_.get(), kScript, storage()->NewVersionId(), 270 registration_.get(), kScript, storage()->NewVersionId(),
273 context()->AsWeakPtr()); 271 context()->AsWeakPtr());
274 version_2->set_fetch_handler_existence( 272 version_2->set_fetch_handler_existence(
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 EXPECT_EQ(version_1.get(), reg->active_version()); 366 EXPECT_EQ(version_1.get(), reg->active_version());
369 367
370 // Finish the request. Activation should happen. 368 // Finish the request. Activation should happen.
371 version_1->FinishRequest(inflight_request_id(), true /* was_handled */, 369 version_1->FinishRequest(inflight_request_id(), true /* was_handled */,
372 base::Time::Now()); 370 base::Time::Now());
373 base::RunLoop().RunUntilIdle(); 371 base::RunLoop().RunUntilIdle();
374 EXPECT_EQ(version_2.get(), reg->active_version()); 372 EXPECT_EQ(version_2.get(), reg->active_version());
375 } 373 }
376 374
377 } // namespace content 375 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698