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

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

Issue 2653493009: Add two interfaces for ServiceWorkerProviderContext/ProviderHost (Closed)
Patch Set: Skip unittest for CrossSiteTransfer when PlzNavigate 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 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 1328 matching lines...) Expand 10 before | Expand all | Expand 10 after
1339 1339
1340 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id1_, false)); 1340 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id1_, false));
1341 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id2_, false)); 1341 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id2_, false));
1342 } 1342 }
1343 1343
1344 TEST_F(ServiceWorkerResourceStorageTest, DeleteRegistration_ActiveVersion) { 1344 TEST_F(ServiceWorkerResourceStorageTest, DeleteRegistration_ActiveVersion) {
1345 // Promote the worker to active and add a controllee. 1345 // Promote the worker to active and add a controllee.
1346 registration_->SetActiveVersion(registration_->waiting_version()); 1346 registration_->SetActiveVersion(registration_->waiting_version());
1347 storage()->UpdateToActiveState( 1347 storage()->UpdateToActiveState(
1348 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); 1348 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback));
1349 ServiceWorkerRemoteProviderEndpoint remote_endpoint;
1349 std::unique_ptr<ServiceWorkerProviderHost> host = CreateProviderHostForWindow( 1350 std::unique_ptr<ServiceWorkerProviderHost> host = CreateProviderHostForWindow(
1350 33 /* dummy render process id */, 1 /* dummy provider_id */, 1351 33 /* dummy render process id */, 1 /* dummy provider_id */,
1351 true /* is_parent_frame_secure */, context()->AsWeakPtr()); 1352 true /* is_parent_frame_secure */, context()->AsWeakPtr(),
1353 &remote_endpoint);
1352 registration_->active_version()->AddControllee(host.get()); 1354 registration_->active_version()->AddControllee(host.get());
1353 1355
1354 bool was_called = false; 1356 bool was_called = false;
1355 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; 1357 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED;
1356 std::set<int64_t> verify_ids; 1358 std::set<int64_t> verify_ids;
1357 1359
1358 // Deleting the registration should move the resources to the purgeable list 1360 // Deleting the registration should move the resources to the purgeable list
1359 // but keep them available. 1361 // but keep them available.
1360 storage()->DeleteRegistration( 1362 storage()->DeleteRegistration(
1361 registration_->id(), 1363 registration_->id(),
(...skipping 27 matching lines...) Expand all
1389 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id1_, false)); 1391 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id1_, false));
1390 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id2_, false)); 1392 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id2_, false));
1391 } 1393 }
1392 1394
1393 TEST_F(ServiceWorkerResourceStorageDiskTest, CleanupOnRestart) { 1395 TEST_F(ServiceWorkerResourceStorageDiskTest, CleanupOnRestart) {
1394 // Promote the worker to active and add a controllee. 1396 // Promote the worker to active and add a controllee.
1395 registration_->SetActiveVersion(registration_->waiting_version()); 1397 registration_->SetActiveVersion(registration_->waiting_version());
1396 registration_->SetWaitingVersion(NULL); 1398 registration_->SetWaitingVersion(NULL);
1397 storage()->UpdateToActiveState( 1399 storage()->UpdateToActiveState(
1398 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); 1400 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback));
1401 ServiceWorkerRemoteProviderEndpoint remote_endpoint;
1399 std::unique_ptr<ServiceWorkerProviderHost> host = CreateProviderHostForWindow( 1402 std::unique_ptr<ServiceWorkerProviderHost> host = CreateProviderHostForWindow(
1400 33 /* dummy render process id */, 1 /* dummy provider_id */, 1403 33 /* dummy render process id */, 1 /* dummy provider_id */,
1401 true /* is_parent_frame_secure */, context()->AsWeakPtr()); 1404 true /* is_parent_frame_secure */, context()->AsWeakPtr(),
1405 &remote_endpoint);
1402 registration_->active_version()->AddControllee(host.get()); 1406 registration_->active_version()->AddControllee(host.get());
1403 1407
1404 bool was_called = false; 1408 bool was_called = false;
1405 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; 1409 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED;
1406 std::set<int64_t> verify_ids; 1410 std::set<int64_t> verify_ids;
1407 1411
1408 // Deleting the registration should move the resources to the purgeable list 1412 // Deleting the registration should move the resources to the purgeable list
1409 // but keep them available. 1413 // but keep them available.
1410 storage()->DeleteRegistration( 1414 storage()->DeleteRegistration(
1411 registration_->id(), 1415 registration_->id(),
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1547 EXPECT_FALSE(base::DirectoryExists(storage()->GetDiskCachePath())); 1551 EXPECT_FALSE(base::DirectoryExists(storage()->GetDiskCachePath()));
1548 EXPECT_FALSE(base::DirectoryExists(storage()->GetDatabasePath())); 1552 EXPECT_FALSE(base::DirectoryExists(storage()->GetDatabasePath()));
1549 #endif 1553 #endif
1550 } 1554 }
1551 1555
1552 TEST_F(ServiceWorkerResourceStorageTest, UpdateRegistration) { 1556 TEST_F(ServiceWorkerResourceStorageTest, UpdateRegistration) {
1553 // Promote the worker to active worker and add a controllee. 1557 // Promote the worker to active worker and add a controllee.
1554 registration_->SetActiveVersion(registration_->waiting_version()); 1558 registration_->SetActiveVersion(registration_->waiting_version());
1555 storage()->UpdateToActiveState( 1559 storage()->UpdateToActiveState(
1556 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); 1560 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback));
1561 ServiceWorkerRemoteProviderEndpoint remote_endpoint;
1557 std::unique_ptr<ServiceWorkerProviderHost> host = CreateProviderHostForWindow( 1562 std::unique_ptr<ServiceWorkerProviderHost> host = CreateProviderHostForWindow(
1558 33 /* dummy render process id */, 1 /* dummy provider_id */, 1563 33 /* dummy render process id */, 1 /* dummy provider_id */,
1559 true /* is_parent_frame_secure */, helper_->context()->AsWeakPtr()); 1564 true /* is_parent_frame_secure */, helper_->context()->AsWeakPtr(),
1565 &remote_endpoint);
1560 registration_->active_version()->AddControllee(host.get()); 1566 registration_->active_version()->AddControllee(host.get());
1561 1567
1562 bool was_called = false; 1568 bool was_called = false;
1563 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; 1569 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED;
1564 std::set<int64_t> verify_ids; 1570 std::set<int64_t> verify_ids;
1565 1571
1566 // Make an updated registration. 1572 // Make an updated registration.
1567 scoped_refptr<ServiceWorkerVersion> live_version = new ServiceWorkerVersion( 1573 scoped_refptr<ServiceWorkerVersion> live_version = new ServiceWorkerVersion(
1568 registration_.get(), script_, storage()->NewVersionId(), 1574 registration_.get(), script_, storage()->NewVersionId(),
1569 context()->AsWeakPtr()); 1575 context()->AsWeakPtr());
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
2123 EXPECT_TRUE(registration_state.enabled); 2129 EXPECT_TRUE(registration_state.enabled);
2124 EXPECT_EQ(kHeaderValue, registration_state.header); 2130 EXPECT_EQ(kHeaderValue, registration_state.header);
2125 ASSERT_TRUE(found_registration->active_version()); 2131 ASSERT_TRUE(found_registration->active_version());
2126 const NavigationPreloadState& state = 2132 const NavigationPreloadState& state =
2127 found_registration->active_version()->navigation_preload_state(); 2133 found_registration->active_version()->navigation_preload_state();
2128 EXPECT_TRUE(state.enabled); 2134 EXPECT_TRUE(state.enabled);
2129 EXPECT_EQ(kHeaderValue, state.header); 2135 EXPECT_EQ(kHeaderValue, state.header);
2130 } 2136 }
2131 2137
2132 } // namespace content 2138 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698