Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(17)

Side by Side Diff: content/browser/service_worker/service_worker_storage.cc

Issue 950343006: [BackgroundSync] Initial land of the BackgroundSyncManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 984 matching lines...) Expand 10 before | Expand all | Expand 10 after
1777 // Give up the corruption recovery until the browser restarts. 1781 // Give up the corruption recovery until the browser restarts.
1778 LOG(ERROR) << "Failed to delete the diskcache."; 1782 LOG(ERROR) << "Failed to delete the diskcache.";
1779 callback.Run(SERVICE_WORKER_ERROR_FAILED); 1783 callback.Run(SERVICE_WORKER_ERROR_FAILED);
1780 return; 1784 return;
1781 } 1785 }
1782 DVLOG(1) << "Deleted ServiceWorkerDiskCache successfully."; 1786 DVLOG(1) << "Deleted ServiceWorkerDiskCache successfully.";
1783 callback.Run(SERVICE_WORKER_OK); 1787 callback.Run(SERVICE_WORKER_OK);
1784 } 1788 }
1785 1789
1786 } // namespace content 1790 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698