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

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

Issue 2638313002: Manage ServiceWorkerDispatcherHost in ServiceWorkerContextCore (Closed)
Patch Set: Fix an include guard 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_storage.h" 5 #include "content/browser/service_worker/service_worker_storage.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 1324 matching lines...) Expand 10 before | Expand all | Expand 10 after
1335 1335
1336 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id1_, false)); 1336 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id1_, false));
1337 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id2_, false)); 1337 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id2_, false));
1338 } 1338 }
1339 1339
1340 TEST_F(ServiceWorkerResourceStorageTest, DeleteRegistration_ActiveVersion) { 1340 TEST_F(ServiceWorkerResourceStorageTest, DeleteRegistration_ActiveVersion) {
1341 // Promote the worker to active and add a controllee. 1341 // Promote the worker to active and add a controllee.
1342 registration_->SetActiveVersion(registration_->waiting_version()); 1342 registration_->SetActiveVersion(registration_->waiting_version());
1343 storage()->UpdateToActiveState( 1343 storage()->UpdateToActiveState(
1344 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); 1344 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback));
1345 std::unique_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( 1345 std::unique_ptr<ServiceWorkerProviderHost> host = CreateProviderHostForWindow(
1346 33 /* dummy render process id */, MSG_ROUTING_NONE, 1346 33 /* dummy render process id */, 1 /* dummy provider_id */,
1347 1 /* dummy provider_id */, SERVICE_WORKER_PROVIDER_FOR_WINDOW, 1347 true /* is_parent_frame_secure */, context()->AsWeakPtr());
1348 ServiceWorkerProviderHost::FrameSecurityLevel::SECURE,
1349 context()->AsWeakPtr(), NULL));
1350 registration_->active_version()->AddControllee(host.get()); 1348 registration_->active_version()->AddControllee(host.get());
1351 1349
1352 bool was_called = false; 1350 bool was_called = false;
1353 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; 1351 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED;
1354 std::set<int64_t> verify_ids; 1352 std::set<int64_t> verify_ids;
1355 1353
1356 // Deleting the registration should move the resources to the purgeable list 1354 // Deleting the registration should move the resources to the purgeable list
1357 // but keep them available. 1355 // but keep them available.
1358 storage()->DeleteRegistration( 1356 storage()->DeleteRegistration(
1359 registration_->id(), 1357 registration_->id(),
(...skipping 27 matching lines...) Expand all
1387 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id1_, false)); 1385 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id1_, false));
1388 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id2_, false)); 1386 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id2_, false));
1389 } 1387 }
1390 1388
1391 TEST_F(ServiceWorkerResourceStorageDiskTest, CleanupOnRestart) { 1389 TEST_F(ServiceWorkerResourceStorageDiskTest, CleanupOnRestart) {
1392 // Promote the worker to active and add a controllee. 1390 // Promote the worker to active and add a controllee.
1393 registration_->SetActiveVersion(registration_->waiting_version()); 1391 registration_->SetActiveVersion(registration_->waiting_version());
1394 registration_->SetWaitingVersion(NULL); 1392 registration_->SetWaitingVersion(NULL);
1395 storage()->UpdateToActiveState( 1393 storage()->UpdateToActiveState(
1396 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); 1394 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback));
1397 std::unique_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( 1395 std::unique_ptr<ServiceWorkerProviderHost> host = CreateProviderHostForWindow(
1398 33 /* dummy render process id */, MSG_ROUTING_NONE, 1396 33 /* dummy render process id */, 1 /* dummy provider_id */,
1399 1 /* dummy provider_id */, SERVICE_WORKER_PROVIDER_FOR_WINDOW, 1397 true /* is_parent_frame_secure */, context()->AsWeakPtr());
1400 ServiceWorkerProviderHost::FrameSecurityLevel::SECURE,
1401 context()->AsWeakPtr(), NULL));
1402 registration_->active_version()->AddControllee(host.get()); 1398 registration_->active_version()->AddControllee(host.get());
1403 1399
1404 bool was_called = false; 1400 bool was_called = false;
1405 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; 1401 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED;
1406 std::set<int64_t> verify_ids; 1402 std::set<int64_t> verify_ids;
1407 1403
1408 // Deleting the registration should move the resources to the purgeable list 1404 // Deleting the registration should move the resources to the purgeable list
1409 // but keep them available. 1405 // but keep them available.
1410 storage()->DeleteRegistration( 1406 storage()->DeleteRegistration(
1411 registration_->id(), 1407 registration_->id(),
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1547 EXPECT_FALSE(base::DirectoryExists(storage()->GetDiskCachePath())); 1543 EXPECT_FALSE(base::DirectoryExists(storage()->GetDiskCachePath()));
1548 EXPECT_FALSE(base::DirectoryExists(storage()->GetDatabasePath())); 1544 EXPECT_FALSE(base::DirectoryExists(storage()->GetDatabasePath()));
1549 #endif 1545 #endif
1550 } 1546 }
1551 1547
1552 TEST_F(ServiceWorkerResourceStorageTest, UpdateRegistration) { 1548 TEST_F(ServiceWorkerResourceStorageTest, UpdateRegistration) {
1553 // Promote the worker to active worker and add a controllee. 1549 // Promote the worker to active worker and add a controllee.
1554 registration_->SetActiveVersion(registration_->waiting_version()); 1550 registration_->SetActiveVersion(registration_->waiting_version());
1555 storage()->UpdateToActiveState( 1551 storage()->UpdateToActiveState(
1556 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); 1552 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback));
1557 std::unique_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( 1553 std::unique_ptr<ServiceWorkerProviderHost> host = CreateProviderHostForWindow(
1558 33 /* dummy render process id */, MSG_ROUTING_NONE, 1554 33 /* dummy render process id */, 1 /* dummy provider_id */,
1559 1 /* dummy provider_id */, SERVICE_WORKER_PROVIDER_FOR_WINDOW, 1555 true /* is_parent_frame_secure */, helper_->context()->AsWeakPtr());
1560 ServiceWorkerProviderHost::FrameSecurityLevel::SECURE,
1561 context()->AsWeakPtr(), NULL));
1562 registration_->active_version()->AddControllee(host.get()); 1556 registration_->active_version()->AddControllee(host.get());
1563 1557
1564 bool was_called = false; 1558 bool was_called = false;
1565 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; 1559 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED;
1566 std::set<int64_t> verify_ids; 1560 std::set<int64_t> verify_ids;
1567 1561
1568 // Make an updated registration. 1562 // Make an updated registration.
1569 scoped_refptr<ServiceWorkerVersion> live_version = new ServiceWorkerVersion( 1563 scoped_refptr<ServiceWorkerVersion> live_version = new ServiceWorkerVersion(
1570 registration_.get(), script_, storage()->NewVersionId(), 1564 registration_.get(), script_, storage()->NewVersionId(),
1571 context()->AsWeakPtr()); 1565 context()->AsWeakPtr());
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
2128 EXPECT_TRUE(registration_state.enabled); 2122 EXPECT_TRUE(registration_state.enabled);
2129 EXPECT_EQ(kHeaderValue, registration_state.header); 2123 EXPECT_EQ(kHeaderValue, registration_state.header);
2130 ASSERT_TRUE(found_registration->active_version()); 2124 ASSERT_TRUE(found_registration->active_version());
2131 const NavigationPreloadState& state = 2125 const NavigationPreloadState& state =
2132 found_registration->active_version()->navigation_preload_state(); 2126 found_registration->active_version()->navigation_preload_state();
2133 EXPECT_TRUE(state.enabled); 2127 EXPECT_TRUE(state.enabled);
2134 EXPECT_EQ(kHeaderValue, state.header); 2128 EXPECT_EQ(kHeaderValue, state.header);
2135 } 2129 }
2136 2130
2137 } // namespace content 2131 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698