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 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1089 | 1089 |
1090 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id1_, false)); | 1090 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id1_, false)); |
1091 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id2_, false)); | 1091 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id2_, false)); |
1092 } | 1092 } |
1093 | 1093 |
1094 TEST_F(ServiceWorkerResourceStorageTest, DeleteRegistration_ActiveVersion) { | 1094 TEST_F(ServiceWorkerResourceStorageTest, DeleteRegistration_ActiveVersion) { |
1095 // Promote the worker to active and add a controllee. | 1095 // Promote the worker to active and add a controllee. |
1096 registration_->SetActiveVersion(registration_->waiting_version()); | 1096 registration_->SetActiveVersion(registration_->waiting_version()); |
1097 storage()->UpdateToActiveState( | 1097 storage()->UpdateToActiveState( |
1098 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 1098 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
1099 scoped_ptr<ServiceWorkerProviderHost> host( | 1099 scoped_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( |
1100 new ServiceWorkerProviderHost(33 /* dummy render process id */, | 1100 33 /* dummy render process id */, MSG_ROUTING_NONE, |
1101 MSG_ROUTING_NONE, | 1101 1 /* dummy provider_id */, SERVICE_WORKER_PROVIDER_FOR_WINDOW, |
1102 1 /* dummy provider_id */, | 1102 context_->AsWeakPtr(), NULL)); |
1103 SERVICE_WORKER_PROVIDER_FOR_CONTROLLEE, | |
1104 context_->AsWeakPtr(), | |
1105 NULL)); | |
1106 registration_->active_version()->AddControllee(host.get()); | 1103 registration_->active_version()->AddControllee(host.get()); |
1107 | 1104 |
1108 bool was_called = false; | 1105 bool was_called = false; |
1109 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; | 1106 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; |
1110 std::set<int64> verify_ids; | 1107 std::set<int64> verify_ids; |
1111 | 1108 |
1112 // Deleting the registration should move the resources to the purgeable list | 1109 // Deleting the registration should move the resources to the purgeable list |
1113 // but keep them available. | 1110 // but keep them available. |
1114 storage()->DeleteRegistration( | 1111 storage()->DeleteRegistration( |
1115 registration_->id(), | 1112 registration_->id(), |
(...skipping 27 matching lines...) Expand all Loading... |
1143 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id1_, false)); | 1140 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id1_, false)); |
1144 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id2_, false)); | 1141 EXPECT_FALSE(VerifyBasicResponse(storage(), resource_id2_, false)); |
1145 } | 1142 } |
1146 | 1143 |
1147 TEST_F(ServiceWorkerResourceStorageDiskTest, CleanupOnRestart) { | 1144 TEST_F(ServiceWorkerResourceStorageDiskTest, CleanupOnRestart) { |
1148 // Promote the worker to active and add a controllee. | 1145 // Promote the worker to active and add a controllee. |
1149 registration_->SetActiveVersion(registration_->waiting_version()); | 1146 registration_->SetActiveVersion(registration_->waiting_version()); |
1150 registration_->SetWaitingVersion(NULL); | 1147 registration_->SetWaitingVersion(NULL); |
1151 storage()->UpdateToActiveState( | 1148 storage()->UpdateToActiveState( |
1152 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 1149 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
1153 scoped_ptr<ServiceWorkerProviderHost> host( | 1150 scoped_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( |
1154 new ServiceWorkerProviderHost(33 /* dummy render process id */, | 1151 33 /* dummy render process id */, MSG_ROUTING_NONE, |
1155 MSG_ROUTING_NONE, | 1152 1 /* dummy provider_id */, SERVICE_WORKER_PROVIDER_FOR_WINDOW, |
1156 1 /* dummy provider_id */, | 1153 context_->AsWeakPtr(), NULL)); |
1157 SERVICE_WORKER_PROVIDER_FOR_CONTROLLEE, | |
1158 context_->AsWeakPtr(), | |
1159 NULL)); | |
1160 registration_->active_version()->AddControllee(host.get()); | 1154 registration_->active_version()->AddControllee(host.get()); |
1161 | 1155 |
1162 bool was_called = false; | 1156 bool was_called = false; |
1163 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; | 1157 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; |
1164 std::set<int64> verify_ids; | 1158 std::set<int64> verify_ids; |
1165 | 1159 |
1166 // Deleting the registration should move the resources to the purgeable list | 1160 // Deleting the registration should move the resources to the purgeable list |
1167 // but keep them available. | 1161 // but keep them available. |
1168 storage()->DeleteRegistration( | 1162 storage()->DeleteRegistration( |
1169 registration_->id(), | 1163 registration_->id(), |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1241 EXPECT_FALSE( | 1235 EXPECT_FALSE( |
1242 VerifyBasicResponse(storage(), kStaleUncommittedResourceId, false)); | 1236 VerifyBasicResponse(storage(), kStaleUncommittedResourceId, false)); |
1243 EXPECT_TRUE(VerifyBasicResponse(storage(), kNewResourceId, true)); | 1237 EXPECT_TRUE(VerifyBasicResponse(storage(), kNewResourceId, true)); |
1244 } | 1238 } |
1245 | 1239 |
1246 TEST_F(ServiceWorkerResourceStorageTest, UpdateRegistration) { | 1240 TEST_F(ServiceWorkerResourceStorageTest, UpdateRegistration) { |
1247 // Promote the worker to active worker and add a controllee. | 1241 // Promote the worker to active worker and add a controllee. |
1248 registration_->SetActiveVersion(registration_->waiting_version()); | 1242 registration_->SetActiveVersion(registration_->waiting_version()); |
1249 storage()->UpdateToActiveState( | 1243 storage()->UpdateToActiveState( |
1250 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); | 1244 registration_.get(), base::Bind(&ServiceWorkerUtils::NoOpStatusCallback)); |
1251 scoped_ptr<ServiceWorkerProviderHost> host( | 1245 scoped_ptr<ServiceWorkerProviderHost> host(new ServiceWorkerProviderHost( |
1252 new ServiceWorkerProviderHost(33 /* dummy render process id */, | 1246 33 /* dummy render process id */, MSG_ROUTING_NONE, |
1253 MSG_ROUTING_NONE, | 1247 1 /* dummy provider_id */, SERVICE_WORKER_PROVIDER_FOR_WINDOW, |
1254 1 /* dummy provider_id */, | 1248 context_->AsWeakPtr(), NULL)); |
1255 SERVICE_WORKER_PROVIDER_FOR_CONTROLLEE, | |
1256 context_->AsWeakPtr(), | |
1257 NULL)); | |
1258 registration_->active_version()->AddControllee(host.get()); | 1249 registration_->active_version()->AddControllee(host.get()); |
1259 | 1250 |
1260 bool was_called = false; | 1251 bool was_called = false; |
1261 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; | 1252 ServiceWorkerStatusCode result = SERVICE_WORKER_ERROR_FAILED; |
1262 std::set<int64> verify_ids; | 1253 std::set<int64> verify_ids; |
1263 | 1254 |
1264 // Make an updated registration. | 1255 // Make an updated registration. |
1265 scoped_refptr<ServiceWorkerVersion> live_version = new ServiceWorkerVersion( | 1256 scoped_refptr<ServiceWorkerVersion> live_version = new ServiceWorkerVersion( |
1266 registration_.get(), script_, storage()->NewVersionId(), context_ptr_); | 1257 registration_.get(), script_, storage()->NewVersionId(), context_ptr_); |
1267 live_version->SetStatus(ServiceWorkerVersion::NEW); | 1258 live_version->SetStatus(ServiceWorkerVersion::NEW); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1438 are_equal = true; | 1429 are_equal = true; |
1439 storage()->CompareScriptResources( | 1430 storage()->CompareScriptResources( |
1440 5, 6, | 1431 5, 6, |
1441 base::Bind(&OnCompareComplete, &status, &are_equal)); | 1432 base::Bind(&OnCompareComplete, &status, &are_equal)); |
1442 base::RunLoop().RunUntilIdle(); | 1433 base::RunLoop().RunUntilIdle(); |
1443 EXPECT_EQ(SERVICE_WORKER_OK, status); | 1434 EXPECT_EQ(SERVICE_WORKER_OK, status); |
1444 EXPECT_FALSE(are_equal); | 1435 EXPECT_FALSE(are_equal); |
1445 } | 1436 } |
1446 | 1437 |
1447 } // namespace content | 1438 } // namespace content |
OLD | NEW |