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

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

Issue 2638313002: Manage ServiceWorkerDispatcherHost in ServiceWorkerContextCore (Closed)
Patch Set: Rebase 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_ = CreateProviderHostForWindow(
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 true /* is_parent_frame_secure */, context()->AsWeakPtr());
262 SERVICE_WORKER_PROVIDER_FOR_WINDOW,
263 ServiceWorkerProviderHost::FrameSecurityLevel::SECURE,
264 context()->AsWeakPtr(), nullptr));
265 version_1->AddControllee(host_.get()); 262 version_1->AddControllee(host_.get());
266 263
267 // Give the active version an in-flight request. 264 // Give the active version an in-flight request.
268 inflight_request_id_ = CreateInflightRequest(version_1.get()); 265 inflight_request_id_ = CreateInflightRequest(version_1.get());
269 266
270 // Create a waiting version. 267 // Create a waiting version.
271 scoped_refptr<ServiceWorkerVersion> version_2 = new ServiceWorkerVersion( 268 scoped_refptr<ServiceWorkerVersion> version_2 = new ServiceWorkerVersion(
272 registration_.get(), kScript, storage()->NewVersionId(), 269 registration_.get(), kScript, storage()->NewVersionId(),
273 context()->AsWeakPtr()); 270 context()->AsWeakPtr());
274 version_2->set_fetch_handler_existence( 271 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()); 365 EXPECT_EQ(version_1.get(), reg->active_version());
369 366
370 // Finish the request. Activation should happen. 367 // Finish the request. Activation should happen.
371 version_1->FinishRequest(inflight_request_id(), true /* was_handled */, 368 version_1->FinishRequest(inflight_request_id(), true /* was_handled */,
372 base::Time::Now()); 369 base::Time::Now());
373 base::RunLoop().RunUntilIdle(); 370 base::RunLoop().RunUntilIdle();
374 EXPECT_EQ(version_2.get(), reg->active_version()); 371 EXPECT_EQ(version_2.get(), reg->active_version());
375 } 372 }
376 373
377 } // namespace content 374 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698