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 "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
(...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 registration_id, key), | 766 registration_id, key), |
767 base::Bind(&ServiceWorkerStorage::DidDeleteUserData, | 767 base::Bind(&ServiceWorkerStorage::DidDeleteUserData, |
768 weak_factory_.GetWeakPtr(), | 768 weak_factory_.GetWeakPtr(), |
769 callback)); | 769 callback)); |
770 } | 770 } |
771 | 771 |
772 void ServiceWorkerStorage::GetUserDataForAllRegistrations( | 772 void ServiceWorkerStorage::GetUserDataForAllRegistrations( |
773 const std::string& key, | 773 const std::string& key, |
774 const ServiceWorkerStorage::GetUserDataForAllRegistrationsCallback& | 774 const ServiceWorkerStorage::GetUserDataForAllRegistrationsCallback& |
775 callback) { | 775 callback) { |
776 DCHECK(state_ == INITIALIZED || state_ == DISABLED) << state_; | 776 if (!LazyInitialize( |
777 if (IsDisabled() || !context_) { | 777 base::Bind(&ServiceWorkerStorage::GetUserDataForAllRegistrations, |
778 RunSoon(FROM_HERE, | 778 weak_factory_.GetWeakPtr(), key, callback))) { |
779 base::Bind(callback, std::vector<std::pair<int64, std::string>>(), | 779 if (state_ != INITIALIZING || !context_) { |
780 SERVICE_WORKER_ERROR_FAILED)); | 780 RunSoon(FROM_HERE, |
| 781 base::Bind(callback, std::vector<std::pair<int64, std::string>>(), |
| 782 SERVICE_WORKER_ERROR_FAILED)); |
| 783 } |
781 return; | 784 return; |
782 } | 785 } |
| 786 DCHECK_EQ(INITIALIZED, state_); |
783 | 787 |
784 if (key.empty()) { | 788 if (key.empty()) { |
785 RunSoon(FROM_HERE, | 789 RunSoon(FROM_HERE, |
786 base::Bind(callback, std::vector<std::pair<int64, std::string>>(), | 790 base::Bind(callback, std::vector<std::pair<int64, std::string>>(), |
787 SERVICE_WORKER_ERROR_FAILED)); | 791 SERVICE_WORKER_ERROR_FAILED)); |
788 return; | 792 return; |
789 } | 793 } |
790 | 794 |
791 database_task_manager_->GetTaskRunner()->PostTask( | 795 database_task_manager_->GetTaskRunner()->PostTask( |
792 FROM_HERE, | 796 FROM_HERE, |
(...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1779 // Give up the corruption recovery until the browser restarts. | 1783 // Give up the corruption recovery until the browser restarts. |
1780 LOG(ERROR) << "Failed to delete the diskcache."; | 1784 LOG(ERROR) << "Failed to delete the diskcache."; |
1781 callback.Run(SERVICE_WORKER_ERROR_FAILED); | 1785 callback.Run(SERVICE_WORKER_ERROR_FAILED); |
1782 return; | 1786 return; |
1783 } | 1787 } |
1784 DVLOG(1) << "Deleted ServiceWorkerDiskCache successfully."; | 1788 DVLOG(1) << "Deleted ServiceWorkerDiskCache successfully."; |
1785 callback.Run(SERVICE_WORKER_OK); | 1789 callback.Run(SERVICE_WORKER_OK); |
1786 } | 1790 } |
1787 | 1791 |
1788 } // namespace content | 1792 } // namespace content |
OLD | NEW |