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 <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
331 | 331 |
332 void ServiceWorkerStorage::GetRegistrationsForOrigin( | 332 void ServiceWorkerStorage::GetRegistrationsForOrigin( |
333 const GURL& origin, | 333 const GURL& origin, |
334 const GetRegistrationsCallback& callback) { | 334 const GetRegistrationsCallback& callback) { |
335 if (!LazyInitialize(base::Bind( | 335 if (!LazyInitialize(base::Bind( |
336 &ServiceWorkerStorage::GetRegistrationsForOrigin, | 336 &ServiceWorkerStorage::GetRegistrationsForOrigin, |
337 weak_factory_.GetWeakPtr(), origin, callback))) { | 337 weak_factory_.GetWeakPtr(), origin, callback))) { |
338 if (state_ != INITIALIZING) { | 338 if (state_ != INITIALIZING) { |
339 RunSoon( | 339 RunSoon( |
340 FROM_HERE, | 340 FROM_HERE, |
341 base::Bind(callback, | 341 base::Bind(callback, SERVICE_WORKER_ERROR_ABORT, |
342 std::vector<scoped_refptr<ServiceWorkerRegistration>>())); | 342 std::vector<scoped_refptr<ServiceWorkerRegistration>>())); |
343 } | 343 } |
344 return; | 344 return; |
345 } | 345 } |
346 DCHECK_EQ(INITIALIZED, state_); | 346 DCHECK_EQ(INITIALIZED, state_); |
347 | 347 |
348 RegistrationList* registrations = new RegistrationList; | 348 RegistrationList* registrations = new RegistrationList; |
349 std::vector<ResourceList>* resource_lists = new std::vector<ResourceList>; | 349 std::vector<ResourceList>* resource_lists = new std::vector<ResourceList>; |
350 PostTaskAndReplyWithResult( | 350 PostTaskAndReplyWithResult( |
351 database_task_manager_->GetTaskRunner(), FROM_HERE, | 351 database_task_manager_->GetTaskRunner(), FROM_HERE, |
352 base::Bind(&ServiceWorkerDatabase::GetRegistrationsForOrigin, | 352 base::Bind(&ServiceWorkerDatabase::GetRegistrationsForOrigin, |
353 base::Unretained(database_.get()), origin, registrations, | 353 base::Unretained(database_.get()), origin, registrations, |
354 resource_lists), | 354 resource_lists), |
355 base::Bind(&ServiceWorkerStorage::DidGetRegistrations, | 355 base::Bind(&ServiceWorkerStorage::DidGetRegistrations, |
356 weak_factory_.GetWeakPtr(), callback, | 356 weak_factory_.GetWeakPtr(), callback, |
357 base::Owned(registrations), base::Owned(resource_lists), | 357 base::Owned(registrations), base::Owned(resource_lists), |
358 origin)); | 358 origin)); |
359 } | 359 } |
360 | 360 |
361 void ServiceWorkerStorage::GetAllRegistrationsInfos( | 361 void ServiceWorkerStorage::GetAllRegistrationsInfos( |
362 const GetRegistrationsInfosCallback& callback) { | 362 const GetRegistrationsInfosCallback& callback) { |
363 if (!LazyInitialize( | 363 if (!LazyInitialize( |
364 base::Bind(&ServiceWorkerStorage::GetAllRegistrationsInfos, | 364 base::Bind(&ServiceWorkerStorage::GetAllRegistrationsInfos, |
365 weak_factory_.GetWeakPtr(), callback))) { | 365 weak_factory_.GetWeakPtr(), callback))) { |
366 if (state_ != INITIALIZING) { | 366 if (state_ != INITIALIZING) { |
367 RunSoon(FROM_HERE, base::Bind( | 367 RunSoon(FROM_HERE, |
368 callback, std::vector<ServiceWorkerRegistrationInfo>())); | 368 base::Bind(callback, SERVICE_WORKER_ERROR_ABORT, |
369 std::vector<ServiceWorkerRegistrationInfo>())); | |
369 } | 370 } |
370 return; | 371 return; |
371 } | 372 } |
372 DCHECK_EQ(INITIALIZED, state_); | 373 DCHECK_EQ(INITIALIZED, state_); |
373 | 374 |
374 RegistrationList* registrations = new RegistrationList; | 375 RegistrationList* registrations = new RegistrationList; |
375 PostTaskAndReplyWithResult( | 376 PostTaskAndReplyWithResult( |
376 database_task_manager_->GetTaskRunner(), FROM_HERE, | 377 database_task_manager_->GetTaskRunner(), FROM_HERE, |
377 base::Bind(&ServiceWorkerDatabase::GetAllRegistrations, | 378 base::Bind(&ServiceWorkerDatabase::GetAllRegistrations, |
378 base::Unretained(database_.get()), registrations), | 379 base::Unretained(database_.get()), registrations), |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
455 registration->id(), | 456 registration->id(), |
456 registration->pattern().GetOrigin()), | 457 registration->pattern().GetOrigin()), |
457 base::Bind(&ServiceWorkerStorage::DidUpdateToActiveState, | 458 base::Bind(&ServiceWorkerStorage::DidUpdateToActiveState, |
458 weak_factory_.GetWeakPtr(), | 459 weak_factory_.GetWeakPtr(), |
459 callback)); | 460 callback)); |
460 } | 461 } |
461 | 462 |
462 void ServiceWorkerStorage::UpdateLastUpdateCheckTime( | 463 void ServiceWorkerStorage::UpdateLastUpdateCheckTime( |
463 ServiceWorkerRegistration* registration) { | 464 ServiceWorkerRegistration* registration) { |
464 DCHECK(registration); | 465 DCHECK(registration); |
465 | |
466 DCHECK(state_ == INITIALIZED || state_ == DISABLED) << state_; | 466 DCHECK(state_ == INITIALIZED || state_ == DISABLED) << state_; |
467 if (IsDisabled()) | 467 if (IsDisabled()) |
468 return; | 468 return; |
469 | 469 |
470 database_task_manager_->GetTaskRunner()->PostTask( | 470 database_task_manager_->GetTaskRunner()->PostTask( |
471 FROM_HERE, | 471 FROM_HERE, |
472 base::Bind( | 472 base::Bind( |
473 base::IgnoreResult(&ServiceWorkerDatabase::UpdateLastCheckTime), | 473 base::IgnoreResult(&ServiceWorkerDatabase::UpdateLastCheckTime), |
474 base::Unretained(database_.get()), | 474 base::Unretained(database_.get()), |
475 registration->id(), | 475 registration->id(), |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
526 } | 526 } |
527 | 527 |
528 scoped_ptr<ServiceWorkerResponseMetadataWriter> | 528 scoped_ptr<ServiceWorkerResponseMetadataWriter> |
529 ServiceWorkerStorage::CreateResponseMetadataWriter(int64_t resource_id) { | 529 ServiceWorkerStorage::CreateResponseMetadataWriter(int64_t resource_id) { |
530 return make_scoped_ptr( | 530 return make_scoped_ptr( |
531 new ServiceWorkerResponseMetadataWriter(resource_id, disk_cache())); | 531 new ServiceWorkerResponseMetadataWriter(resource_id, disk_cache())); |
532 } | 532 } |
533 | 533 |
534 void ServiceWorkerStorage::StoreUncommittedResourceId(int64_t resource_id) { | 534 void ServiceWorkerStorage::StoreUncommittedResourceId(int64_t resource_id) { |
535 DCHECK_NE(kInvalidServiceWorkerResourceId, resource_id); | 535 DCHECK_NE(kInvalidServiceWorkerResourceId, resource_id); |
536 DCHECK_EQ(INITIALIZED, state_); | 536 DCHECK(INITIALIZED == state_ || DISABLED == state_) << state_; |
537 if (IsDisabled()) | |
538 return; | |
537 | 539 |
538 if (!has_checked_for_stale_resources_) | 540 if (!has_checked_for_stale_resources_) |
539 DeleteStaleResources(); | 541 DeleteStaleResources(); |
540 | 542 |
541 PostTaskAndReplyWithResult( | 543 PostTaskAndReplyWithResult( |
542 database_task_manager_->GetTaskRunner(), FROM_HERE, | 544 database_task_manager_->GetTaskRunner(), FROM_HERE, |
543 base::Bind(&ServiceWorkerDatabase::WriteUncommittedResourceIds, | 545 base::Bind(&ServiceWorkerDatabase::WriteUncommittedResourceIds, |
544 base::Unretained(database_.get()), | 546 base::Unretained(database_.get()), |
545 std::set<int64_t>(&resource_id, &resource_id + 1)), | 547 std::set<int64_t>(&resource_id, &resource_id + 1)), |
546 base::Bind(&ServiceWorkerStorage::DidWriteUncommittedResourceIds, | 548 base::Bind(&ServiceWorkerStorage::DidWriteUncommittedResourceIds, |
547 weak_factory_.GetWeakPtr())); | 549 weak_factory_.GetWeakPtr())); |
548 } | 550 } |
549 | 551 |
550 void ServiceWorkerStorage::DoomUncommittedResource(int64_t resource_id) { | 552 void ServiceWorkerStorage::DoomUncommittedResource(int64_t resource_id) { |
551 DCHECK_NE(kInvalidServiceWorkerResourceId, resource_id); | 553 DCHECK_NE(kInvalidServiceWorkerResourceId, resource_id); |
554 DCHECK(INITIALIZED == state_ || DISABLED == state_) << state_; | |
555 if (IsDisabled()) | |
556 return; | |
552 DoomUncommittedResources(std::set<int64_t>(&resource_id, &resource_id + 1)); | 557 DoomUncommittedResources(std::set<int64_t>(&resource_id, &resource_id + 1)); |
553 } | 558 } |
554 | 559 |
555 void ServiceWorkerStorage::DoomUncommittedResources( | 560 void ServiceWorkerStorage::DoomUncommittedResources( |
556 const std::set<int64_t>& resource_ids) { | 561 const std::set<int64_t>& resource_ids) { |
562 DCHECK(INITIALIZED == state_ || DISABLED == state_) << state_; | |
563 if (IsDisabled()) | |
564 return; | |
565 | |
557 PostTaskAndReplyWithResult( | 566 PostTaskAndReplyWithResult( |
558 database_task_manager_->GetTaskRunner(), FROM_HERE, | 567 database_task_manager_->GetTaskRunner(), FROM_HERE, |
559 base::Bind(&ServiceWorkerDatabase::PurgeUncommittedResourceIds, | 568 base::Bind(&ServiceWorkerDatabase::PurgeUncommittedResourceIds, |
560 base::Unretained(database_.get()), resource_ids), | 569 base::Unretained(database_.get()), resource_ids), |
561 base::Bind(&ServiceWorkerStorage::DidPurgeUncommittedResourceIds, | 570 base::Bind(&ServiceWorkerStorage::DidPurgeUncommittedResourceIds, |
562 weak_factory_.GetWeakPtr(), resource_ids)); | 571 weak_factory_.GetWeakPtr(), resource_ids)); |
563 } | 572 } |
564 | 573 |
565 void ServiceWorkerStorage::StoreUserData(int64_t registration_id, | 574 void ServiceWorkerStorage::StoreUserData(int64_t registration_id, |
566 const GURL& origin, | 575 const GURL& origin, |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
751 ServiceWorkerRegistration* registration) { | 760 ServiceWorkerRegistration* registration) { |
752 uninstalling_registrations_.erase(registration->id()); | 761 uninstalling_registrations_.erase(registration->id()); |
753 } | 762 } |
754 | 763 |
755 void ServiceWorkerStorage::Disable() { | 764 void ServiceWorkerStorage::Disable() { |
756 state_ = DISABLED; | 765 state_ = DISABLED; |
757 if (disk_cache_) | 766 if (disk_cache_) |
758 disk_cache_->Disable(); | 767 disk_cache_->Disable(); |
759 } | 768 } |
760 | 769 |
761 bool ServiceWorkerStorage::IsDisabled() const { | |
762 return state_ == DISABLED; | |
763 } | |
764 | |
765 void ServiceWorkerStorage::PurgeResources(const ResourceList& resources) { | 770 void ServiceWorkerStorage::PurgeResources(const ResourceList& resources) { |
766 if (!has_checked_for_stale_resources_) | 771 if (!has_checked_for_stale_resources_) |
767 DeleteStaleResources(); | 772 DeleteStaleResources(); |
768 StartPurgingResources(resources); | 773 StartPurgingResources(resources); |
769 } | 774 } |
770 | 775 |
771 ServiceWorkerStorage::ServiceWorkerStorage( | 776 ServiceWorkerStorage::ServiceWorkerStorage( |
772 const base::FilePath& path, | 777 const base::FilePath& path, |
773 base::WeakPtr<ServiceWorkerContextCore> context, | 778 base::WeakPtr<ServiceWorkerContextCore> context, |
774 scoped_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager, | 779 scoped_ptr<ServiceWorkerDatabaseTaskManager> database_task_manager, |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
964 RegistrationList* registration_data_list, | 969 RegistrationList* registration_data_list, |
965 std::vector<ResourceList>* resources_list, | 970 std::vector<ResourceList>* resources_list, |
966 const GURL& origin_filter, | 971 const GURL& origin_filter, |
967 ServiceWorkerDatabase::Status status) { | 972 ServiceWorkerDatabase::Status status) { |
968 DCHECK(registration_data_list); | 973 DCHECK(registration_data_list); |
969 DCHECK(resources_list); | 974 DCHECK(resources_list); |
970 | 975 |
971 if (status != ServiceWorkerDatabase::STATUS_OK && | 976 if (status != ServiceWorkerDatabase::STATUS_OK && |
972 status != ServiceWorkerDatabase::STATUS_ERROR_NOT_FOUND) { | 977 status != ServiceWorkerDatabase::STATUS_ERROR_NOT_FOUND) { |
973 ScheduleDeleteAndStartOver(); | 978 ScheduleDeleteAndStartOver(); |
974 callback.Run(std::vector<scoped_refptr<ServiceWorkerRegistration>>()); | 979 callback.Run(DatabaseStatusToStatusCode(status), |
980 std::vector<scoped_refptr<ServiceWorkerRegistration>>()); | |
975 return; | 981 return; |
976 } | 982 } |
977 | 983 |
978 // Add all stored registrations. | 984 // Add all stored registrations. |
979 std::set<int64_t> registration_ids; | 985 std::set<int64_t> registration_ids; |
980 std::vector<scoped_refptr<ServiceWorkerRegistration>> registrations; | 986 std::vector<scoped_refptr<ServiceWorkerRegistration>> registrations; |
981 size_t index = 0; | 987 size_t index = 0; |
982 for (const auto& registration_data : *registration_data_list) { | 988 for (const auto& registration_data : *registration_data_list) { |
983 registration_ids.insert(registration_data.registration_id); | 989 registration_ids.insert(registration_data.registration_id); |
984 registrations.push_back(GetOrCreateRegistration( | 990 registrations.push_back(GetOrCreateRegistration( |
985 registration_data, resources_list->at(index++))); | 991 registration_data, resources_list->at(index++))); |
986 } | 992 } |
987 | 993 |
988 // Add unstored registrations that are being installed. | 994 // Add unstored registrations that are being installed. |
989 for (const auto& registration : installing_registrations_) { | 995 for (const auto& registration : installing_registrations_) { |
990 if ((!origin_filter.is_valid() || | 996 if ((!origin_filter.is_valid() || |
991 registration.second->pattern().GetOrigin() == origin_filter) && | 997 registration.second->pattern().GetOrigin() == origin_filter) && |
992 registration_ids.insert(registration.first).second) { | 998 registration_ids.insert(registration.first).second) { |
993 registrations.push_back(registration.second); | 999 registrations.push_back(registration.second); |
994 } | 1000 } |
995 } | 1001 } |
996 | 1002 |
997 callback.Run(registrations); | 1003 callback.Run(SERVICE_WORKER_OK, registrations); |
998 } | 1004 } |
999 | 1005 |
1000 void ServiceWorkerStorage::DidGetRegistrationsInfos( | 1006 void ServiceWorkerStorage::DidGetRegistrationsInfos( |
1001 const GetRegistrationsInfosCallback& callback, | 1007 const GetRegistrationsInfosCallback& callback, |
1002 RegistrationList* registration_data_list, | 1008 RegistrationList* registration_data_list, |
1003 const GURL& origin_filter, | 1009 const GURL& origin_filter, |
1004 ServiceWorkerDatabase::Status status) { | 1010 ServiceWorkerDatabase::Status status) { |
1005 DCHECK(registration_data_list); | 1011 DCHECK(registration_data_list); |
1006 if (status != ServiceWorkerDatabase::STATUS_OK && | 1012 if (status != ServiceWorkerDatabase::STATUS_OK && |
1007 status != ServiceWorkerDatabase::STATUS_ERROR_NOT_FOUND) { | 1013 status != ServiceWorkerDatabase::STATUS_ERROR_NOT_FOUND) { |
1008 ScheduleDeleteAndStartOver(); | 1014 ScheduleDeleteAndStartOver(); |
1009 callback.Run(std::vector<ServiceWorkerRegistrationInfo>()); | 1015 callback.Run(DatabaseStatusToStatusCode(status), |
1016 std::vector<ServiceWorkerRegistrationInfo>()); | |
1010 return; | 1017 return; |
1011 } | 1018 } |
1012 | 1019 |
1013 // Add all stored registrations. | 1020 // Add all stored registrations. |
1014 std::set<int64_t> pushed_registrations; | 1021 std::set<int64_t> pushed_registrations; |
1015 std::vector<ServiceWorkerRegistrationInfo> infos; | 1022 std::vector<ServiceWorkerRegistrationInfo> infos; |
1016 for (const auto& registration_data : *registration_data_list) { | 1023 for (const auto& registration_data : *registration_data_list) { |
1017 const bool inserted = | 1024 const bool inserted = |
1018 pushed_registrations.insert(registration_data.registration_id).second; | 1025 pushed_registrations.insert(registration_data.registration_id).second; |
1019 DCHECK(inserted); | 1026 DCHECK(inserted); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1056 | 1063 |
1057 // Add unstored registrations that are being installed. | 1064 // Add unstored registrations that are being installed. |
1058 for (const auto& registration : installing_registrations_) { | 1065 for (const auto& registration : installing_registrations_) { |
1059 if ((!origin_filter.is_valid() || | 1066 if ((!origin_filter.is_valid() || |
1060 registration.second->pattern().GetOrigin() == origin_filter) && | 1067 registration.second->pattern().GetOrigin() == origin_filter) && |
1061 pushed_registrations.insert(registration.first).second) { | 1068 pushed_registrations.insert(registration.first).second) { |
1062 infos.push_back(registration.second->GetInfo()); | 1069 infos.push_back(registration.second->GetInfo()); |
1063 } | 1070 } |
1064 } | 1071 } |
1065 | 1072 |
1066 callback.Run(infos); | 1073 callback.Run(SERVICE_WORKER_OK, infos); |
1067 } | 1074 } |
1068 | 1075 |
1069 void ServiceWorkerStorage::DidStoreRegistration( | 1076 void ServiceWorkerStorage::DidStoreRegistration( |
1070 const StatusCallback& callback, | 1077 const StatusCallback& callback, |
1071 const ServiceWorkerDatabase::RegistrationData& new_version, | 1078 const ServiceWorkerDatabase::RegistrationData& new_version, |
1072 const GURL& origin, | 1079 const GURL& origin, |
1073 const ServiceWorkerDatabase::RegistrationData& deleted_version, | 1080 const ServiceWorkerDatabase::RegistrationData& deleted_version, |
1074 const std::vector<int64_t>& newly_purgeable_resources, | 1081 const std::vector<int64_t>& newly_purgeable_resources, |
1075 ServiceWorkerDatabase::Status status) { | 1082 ServiceWorkerDatabase::Status status) { |
1076 if (status != ServiceWorkerDatabase::STATUS_OK) { | 1083 if (status != ServiceWorkerDatabase::STATUS_OK) { |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1267 ServiceWorkerRegistration* | 1274 ServiceWorkerRegistration* |
1268 ServiceWorkerStorage::FindInstallingRegistrationForId(int64_t registration_id) { | 1275 ServiceWorkerStorage::FindInstallingRegistrationForId(int64_t registration_id) { |
1269 RegistrationRefsById::const_iterator found = | 1276 RegistrationRefsById::const_iterator found = |
1270 installing_registrations_.find(registration_id); | 1277 installing_registrations_.find(registration_id); |
1271 if (found == installing_registrations_.end()) | 1278 if (found == installing_registrations_.end()) |
1272 return nullptr; | 1279 return nullptr; |
1273 return found->second.get(); | 1280 return found->second.get(); |
1274 } | 1281 } |
1275 | 1282 |
1276 ServiceWorkerDiskCache* ServiceWorkerStorage::disk_cache() { | 1283 ServiceWorkerDiskCache* ServiceWorkerStorage::disk_cache() { |
1277 DCHECK_EQ(INITIALIZED, state_); | 1284 DCHECK(INITIALIZED == state_ || DISABLED == state_) << state_; |
1278 if (disk_cache_) | 1285 if (disk_cache_) |
1279 return disk_cache_.get(); | 1286 return disk_cache_.get(); |
1287 disk_cache_.reset(new ServiceWorkerDiskCache); | |
1280 | 1288 |
1281 disk_cache_.reset(new ServiceWorkerDiskCache); | 1289 if (IsDisabled()) { |
1290 disk_cache_->Disable(); | |
falken
2016/02/16 09:16:50
Ah, nice bug.
| |
1291 return disk_cache_.get(); | |
1292 } | |
1282 | 1293 |
1283 base::FilePath path = GetDiskCachePath(); | 1294 base::FilePath path = GetDiskCachePath(); |
1284 if (path.empty()) { | 1295 if (path.empty()) { |
1285 int rv = disk_cache_->InitWithMemBackend(kMaxMemDiskCacheSize, | 1296 int rv = disk_cache_->InitWithMemBackend(kMaxMemDiskCacheSize, |
1286 net::CompletionCallback()); | 1297 net::CompletionCallback()); |
1287 DCHECK_EQ(net::OK, rv); | 1298 DCHECK_EQ(net::OK, rv); |
1288 return disk_cache_.get(); | 1299 return disk_cache_.get(); |
1289 } | 1300 } |
1290 | 1301 |
1291 InitializeDiskCache(); | 1302 InitializeDiskCache(); |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1680 | 1691 |
1681 void ServiceWorkerStorage::DeleteAllDataForOriginsFromDB( | 1692 void ServiceWorkerStorage::DeleteAllDataForOriginsFromDB( |
1682 ServiceWorkerDatabase* database, | 1693 ServiceWorkerDatabase* database, |
1683 const std::set<GURL>& origins) { | 1694 const std::set<GURL>& origins) { |
1684 DCHECK(database); | 1695 DCHECK(database); |
1685 | 1696 |
1686 std::vector<int64_t> newly_purgeable_resources; | 1697 std::vector<int64_t> newly_purgeable_resources; |
1687 database->DeleteAllDataForOrigins(origins, &newly_purgeable_resources); | 1698 database->DeleteAllDataForOrigins(origins, &newly_purgeable_resources); |
1688 } | 1699 } |
1689 | 1700 |
1701 bool ServiceWorkerStorage::IsDisabled() const { | |
1702 return state_ == DISABLED; | |
1703 } | |
1704 | |
1690 // TODO(nhiroki): The corruption recovery should not be scheduled if the error | 1705 // TODO(nhiroki): The corruption recovery should not be scheduled if the error |
1691 // is transient and it can get healed soon (e.g. IO error). To do that, the | 1706 // is transient and it can get healed soon (e.g. IO error). To do that, the |
1692 // database should not disable itself when an error occurs and the storage | 1707 // database should not disable itself when an error occurs and the storage |
1693 // controls it instead. | 1708 // controls it instead. |
1694 void ServiceWorkerStorage::ScheduleDeleteAndStartOver() { | 1709 void ServiceWorkerStorage::ScheduleDeleteAndStartOver() { |
1695 // TODO(dmurph): Notify the quota manager somehow that all of our data is now | 1710 // TODO(dmurph): Notify the quota manager somehow that all of our data is now |
1696 // removed. | 1711 // removed. |
1697 if (state_ == DISABLED) { | 1712 if (state_ == DISABLED) { |
1698 // Recovery process has already been scheduled. | 1713 // Recovery process has already been scheduled. |
1699 return; | 1714 return; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1741 callback.Run(SERVICE_WORKER_ERROR_FAILED); | 1756 callback.Run(SERVICE_WORKER_ERROR_FAILED); |
1742 return; | 1757 return; |
1743 } | 1758 } |
1744 DVLOG(1) << "Deleted ServiceWorkerDiskCache successfully."; | 1759 DVLOG(1) << "Deleted ServiceWorkerDiskCache successfully."; |
1745 ServiceWorkerMetrics::RecordDeleteAndStartOverResult( | 1760 ServiceWorkerMetrics::RecordDeleteAndStartOverResult( |
1746 ServiceWorkerMetrics::DELETE_OK); | 1761 ServiceWorkerMetrics::DELETE_OK); |
1747 callback.Run(SERVICE_WORKER_OK); | 1762 callback.Run(SERVICE_WORKER_OK); |
1748 } | 1763 } |
1749 | 1764 |
1750 } // namespace content | 1765 } // namespace content |
OLD | NEW |