| OLD | NEW |
| 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 1258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1269 } | 1269 } |
| 1270 | 1270 |
| 1271 TEST_F(ServiceWorkerResourceStorageTest, DeleteRegistration_ActiveVersion) { | 1271 TEST_F(ServiceWorkerResourceStorageTest, DeleteRegistration_ActiveVersion) { |
| 1272 // Promote the worker to active and add a controllee. | 1272 // Promote the worker to active and add a controllee. |
| 1273 registration_->SetActiveVersion(registration_->waiting_version()); | 1273 registration_->SetActiveVersion(registration_->waiting_version()); |
| 1274 storage()->UpdateToActiveState( | 1274 storage()->UpdateToActiveState( |
| 1275 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 1275 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
| 1276 std::unique_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( | 1276 std::unique_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( |
| 1277 33 /* dummy render process id */, MSG_ROUTING_NONE, | 1277 33 /* dummy render process id */, MSG_ROUTING_NONE, |
| 1278 1 /* dummy provider_id */, SERVICE_WORKER_PROVIDER_FOR_WINDOW, | 1278 1 /* dummy provider_id */, SERVICE_WORKER_PROVIDER_FOR_WINDOW, |
| 1279 ServiceWorkerProviderHost::FrameSecurityLevel::SECURE, |
| 1279 context()->AsWeakPtr(), NULL)); | 1280 context()->AsWeakPtr(), NULL)); |
| 1280 registration_->active_version()->AddControllee(host.get()); | 1281 registration_->active_version()->AddControllee(host.get()); |
| 1281 | 1282 |
| 1282 bool was_called = false; | 1283 bool was_called = false; |
| 1283 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; | 1284 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; |
| 1284 std::set<int64_t> verify_ids; | 1285 std::set<int64_t> verify_ids; |
| 1285 | 1286 |
| 1286 // Deleting the registration should move the resources to the purgeable list | 1287 // Deleting the registration should move the resources to the purgeable list |
| 1287 // but keep them available. | 1288 // but keep them available. |
| 1288 storage()->DeleteRegistration( | 1289 storage()->DeleteRegistration( |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1320 | 1321 |
| 1321 TEST_F(ServiceWorkerResourceStorageDiskTest, CleanupOnRestart) { | 1322 TEST_F(ServiceWorkerResourceStorageDiskTest, CleanupOnRestart) { |
| 1322 // Promote the worker to active and add a controllee. | 1323 // Promote the worker to active and add a controllee. |
| 1323 registration_->SetActiveVersion(registration_->waiting_version()); | 1324 registration_->SetActiveVersion(registration_->waiting_version()); |
| 1324 registration_->SetWaitingVersion(NULL); | 1325 registration_->SetWaitingVersion(NULL); |
| 1325 storage()->UpdateToActiveState( | 1326 storage()->UpdateToActiveState( |
| 1326 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 1327 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
| 1327 std::unique_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( | 1328 std::unique_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( |
| 1328 33 /* dummy render process id */, MSG_ROUTING_NONE, | 1329 33 /* dummy render process id */, MSG_ROUTING_NONE, |
| 1329 1 /* dummy provider_id */, SERVICE_WORKER_PROVIDER_FOR_WINDOW, | 1330 1 /* dummy provider_id */, SERVICE_WORKER_PROVIDER_FOR_WINDOW, |
| 1331 ServiceWorkerProviderHost::FrameSecurityLevel::SECURE, |
| 1330 context()->AsWeakPtr(), NULL)); | 1332 context()->AsWeakPtr(), NULL)); |
| 1331 registration_->active_version()->AddControllee(host.get()); | 1333 registration_->active_version()->AddControllee(host.get()); |
| 1332 | 1334 |
| 1333 bool was_called = false; | 1335 bool was_called = false; |
| 1334 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; | 1336 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; |
| 1335 std::set<int64_t> verify_ids; | 1337 std::set<int64_t> verify_ids; |
| 1336 | 1338 |
| 1337 // Deleting the registration should move the resources to the purgeable list | 1339 // Deleting the registration should move the resources to the purgeable list |
| 1338 // but keep them available. | 1340 // but keep them available. |
| 1339 storage()->DeleteRegistration( | 1341 storage()->DeleteRegistration( |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1479 } | 1481 } |
| 1480 | 1482 |
| 1481 TEST_F(ServiceWorkerResourceStorageTest, UpdateRegistration) { | 1483 TEST_F(ServiceWorkerResourceStorageTest, UpdateRegistration) { |
| 1482 // Promote the worker to active worker and add a controllee. | 1484 // Promote the worker to active worker and add a controllee. |
| 1483 registration_->SetActiveVersion(registration_->waiting_version()); | 1485 registration_->SetActiveVersion(registration_->waiting_version()); |
| 1484 storage()->UpdateToActiveState( | 1486 storage()->UpdateToActiveState( |
| 1485 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 1487 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
| 1486 std::unique_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( | 1488 std::unique_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( |
| 1487 33 /* dummy render process id */, MSG_ROUTING_NONE, | 1489 33 /* dummy render process id */, MSG_ROUTING_NONE, |
| 1488 1 /* dummy provider_id */, SERVICE_WORKER_PROVIDER_FOR_WINDOW, | 1490 1 /* dummy provider_id */, SERVICE_WORKER_PROVIDER_FOR_WINDOW, |
| 1491 ServiceWorkerProviderHost::FrameSecurityLevel::SECURE, |
| 1489 context()->AsWeakPtr(), NULL)); | 1492 context()->AsWeakPtr(), NULL)); |
| 1490 registration_->active_version()->AddControllee(host.get()); | 1493 registration_->active_version()->AddControllee(host.get()); |
| 1491 | 1494 |
| 1492 bool was_called = false; | 1495 bool was_called = false; |
| 1493 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; | 1496 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; |
| 1494 std::set<int64_t> verify_ids; | 1497 std::set<int64_t> verify_ids; |
| 1495 | 1498 |
| 1496 // Make an updated registration. | 1499 // Make an updated registration. |
| 1497 scoped_refptr<ServiceWorkerVersion> live_version = new ServiceWorkerVersion( | 1500 scoped_refptr<ServiceWorkerVersion> live_version = new ServiceWorkerVersion( |
| 1498 registration_.get(), script_, storage()->NewVersionId(), | 1501 registration_.get(), script_, storage()->NewVersionId(), |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1735 // Remove other registration at first origin. | 1738 // Remove other registration at first origin. |
| 1736 EXPECT_EQ(SERVICE_WORKER_OK, | 1739 EXPECT_EQ(SERVICE_WORKER_OK, |
| 1737 DeleteRegistration(kRegistrationId2, kScope2.GetOrigin())); | 1740 DeleteRegistration(kRegistrationId2, kScope2.GetOrigin())); |
| 1738 | 1741 |
| 1739 // No foreign fetch registrations remain. | 1742 // No foreign fetch registrations remain. |
| 1740 EXPECT_FALSE(storage()->OriginHasForeignFetchRegistrations(kOrigin1)); | 1743 EXPECT_FALSE(storage()->OriginHasForeignFetchRegistrations(kOrigin1)); |
| 1741 EXPECT_FALSE(storage()->OriginHasForeignFetchRegistrations(kOrigin2)); | 1744 EXPECT_FALSE(storage()->OriginHasForeignFetchRegistrations(kOrigin2)); |
| 1742 } | 1745 } |
| 1743 | 1746 |
| 1744 } // namespace content | 1747 } // namespace content |
| OLD | NEW |