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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
(...skipping 1083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1094 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id1_, false)); | 1094 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id1_, false)); |
1095 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id2_, false)); | 1095 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id2_, false)); |
1096 } | 1096 } |
1097 | 1097 |
1098 TEST_F(ServiceWorkerResourceStorageTest, DeleteRegistration_ActiveVersion) { | 1098 TEST_F(ServiceWorkerResourceStorageTest, DeleteRegistration_ActiveVersion) { |
1099 // Promote the worker to active and add a controllee. | 1099 // Promote the worker to active and add a controllee. |
1100 registration_->SetActiveVersion(registration_->waiting_version()); | 1100 registration_->SetActiveVersion(registration_->waiting_version()); |
1101 storage()->UpdateToActiveState( | 1101 storage()->UpdateToActiveState( |
1102 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 1102 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
1103 scoped_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( | 1103 scoped_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( |
1104 33 /* dummy render process id */, MSG_ROUTING_NONE, | 1104 33 /* dummy render process id */, 1 /* dummy render_frame_id*/, |
1105 1 /* dummy provider_id */, SERVICE_WORKER_PROVIDER_FOR_WINDOW, | 1105 MSG_ROUTING_NONE, 1 /* dummy provider_id */, context_->AsWeakPtr(), |
1106 context_->AsWeakPtr(), NULL)); | 1106 NULL)); |
1107 registration_->active_version()->AddControllee(host.get()); | 1107 registration_->active_version()->AddControllee(host.get()); |
1108 | 1108 |
1109 bool was_called = false; | 1109 bool was_called = false; |
1110 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; | 1110 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; |
1111 std::set<int64> verify_ids; | 1111 std::set<int64> verify_ids; |
1112 | 1112 |
1113 // Deleting the registration should move the resources to the purgeable list | 1113 // Deleting the registration should move the resources to the purgeable list |
1114 // but keep them available. | 1114 // but keep them available. |
1115 storage()->DeleteRegistration( | 1115 storage()->DeleteRegistration( |
1116 registration_->id(), | 1116 registration_->id(), |
(...skipping 28 matching lines...) Expand all Loading... |
1145 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id2_, false)); | 1145 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id2_, false)); |
1146 } | 1146 } |
1147 | 1147 |
1148 TEST_F(ServiceWorkerResourceStorageDiskTest, CleanupOnRestart) { | 1148 TEST_F(ServiceWorkerResourceStorageDiskTest, CleanupOnRestart) { |
1149 // Promote the worker to active and add a controllee. | 1149 // Promote the worker to active and add a controllee. |
1150 registration_->SetActiveVersion(registration_->waiting_version()); | 1150 registration_->SetActiveVersion(registration_->waiting_version()); |
1151 registration_->SetWaitingVersion(NULL); | 1151 registration_->SetWaitingVersion(NULL); |
1152 storage()->UpdateToActiveState( | 1152 storage()->UpdateToActiveState( |
1153 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 1153 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
1154 scoped_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( | 1154 scoped_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( |
1155 33 /* dummy render process id */, MSG_ROUTING_NONE, | 1155 33 /* dummy render process id */, 1 /* dummy render_frame_id */, |
1156 1 /* dummy provider_id */, SERVICE_WORKER_PROVIDER_FOR_WINDOW, | 1156 MSG_ROUTING_NONE, 1 /* dummy provider_id */, context_->AsWeakPtr(), |
1157 context_->AsWeakPtr(), NULL)); | 1157 NULL)); |
1158 registration_->active_version()->AddControllee(host.get()); | 1158 registration_->active_version()->AddControllee(host.get()); |
1159 | 1159 |
1160 bool was_called = false; | 1160 bool was_called = false; |
1161 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; | 1161 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; |
1162 std::set<int64> verify_ids; | 1162 std::set<int64> verify_ids; |
1163 | 1163 |
1164 // Deleting the registration should move the resources to the purgeable list | 1164 // Deleting the registration should move the resources to the purgeable list |
1165 // but keep them available. | 1165 // but keep them available. |
1166 storage()->DeleteRegistration( | 1166 storage()->DeleteRegistration( |
1167 registration_->id(), | 1167 registration_->id(), |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1240 VerifyBasicResponse(storage(), kStaleUncommittedResourceId, false)); | 1240 VerifyBasicResponse(storage(), kStaleUncommittedResourceId, false)); |
1241 EXPECT_TRUE(VerifyBasicResponse(storage(), kNewResourceId, true)); | 1241 EXPECT_TRUE(VerifyBasicResponse(storage(), kNewResourceId, true)); |
1242 } | 1242 } |
1243 | 1243 |
1244 TEST_F(ServiceWorkerResourceStorageTest, UpdateRegistration) { | 1244 TEST_F(ServiceWorkerResourceStorageTest, UpdateRegistration) { |
1245 // Promote the worker to active worker and add a controllee. | 1245 // Promote the worker to active worker and add a controllee. |
1246 registration_->SetActiveVersion(registration_->waiting_version()); | 1246 registration_->SetActiveVersion(registration_->waiting_version()); |
1247 storage()->UpdateToActiveState( | 1247 storage()->UpdateToActiveState( |
1248 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 1248 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
1249 scoped_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( | 1249 scoped_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( |
1250 33 /* dummy render process id */, MSG_ROUTING_NONE, | 1250 33 /* dummy render process id */, 1 /* dummy render_frame_id */, |
1251 1 /* dummy provider_id */, SERVICE_WORKER_PROVIDER_FOR_WINDOW, | 1251 MSG_ROUTING_NONE, 1 /* dummy provider_id */, context_->AsWeakPtr(), |
1252 context_->AsWeakPtr(), NULL)); | 1252 NULL)); |
1253 registration_->active_version()->AddControllee(host.get()); | 1253 registration_->active_version()->AddControllee(host.get()); |
1254 | 1254 |
1255 bool was_called = false; | 1255 bool was_called = false; |
1256 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; | 1256 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; |
1257 std::set<int64> verify_ids; | 1257 std::set<int64> verify_ids; |
1258 | 1258 |
1259 // Make an updated registration. | 1259 // Make an updated registration. |
1260 scoped_refptr<ServiceWorkerVersion> live_version = new ServiceWorkerVersion( | 1260 scoped_refptr<ServiceWorkerVersion> live_version = new ServiceWorkerVersion( |
1261 registration_.get(), script_, storage()->NewVersionId(), context_ptr_); | 1261 registration_.get(), script_, storage()->NewVersionId(), context_ptr_); |
1262 live_version->SetStatus(ServiceWorkerVersion::NEW); | 1262 live_version->SetStatus(ServiceWorkerVersion::NEW); |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1449 are_equal = true; | 1449 are_equal = true; |
1450 storage()->CompareScriptResources( | 1450 storage()->CompareScriptResources( |
1451 5, 6, | 1451 5, 6, |
1452 base::Bind(&OnCompareComplete, &status, &are_equal)); | 1452 base::Bind(&OnCompareComplete, &status, &are_equal)); |
1453 base::RunLoop().RunUntilIdle(); | 1453 base::RunLoop().RunUntilIdle(); |
1454 EXPECT_EQ(SERVICE_WORKER_OK, status); | 1454 EXPECT_EQ(SERVICE_WORKER_OK, status); |
1455 EXPECT_FALSE(are_equal); | 1455 EXPECT_FALSE(are_equal); |
1456 } | 1456 } |
1457 | 1457 |
1458 } // namespace content | 1458 } // namespace content |
OLD | NEW |