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