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

Unified Diff: chrome/browser/chromeos/drive/drive_app_registry.cc

Issue 22297004: drive: Stop making multiple GetAppList() requests from DriveAppRegistry (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: simplify Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/drive/drive_app_registry.cc
diff --git a/chrome/browser/chromeos/drive/drive_app_registry.cc b/chrome/browser/chromeos/drive/drive_app_registry.cc
index 75b0418321cd7181f2e9f0acf31e70be4b545406..9e4bae6b3d56113f03bffc8a89c2e81ec8bcee82 100644
--- a/chrome/browser/chromeos/drive/drive_app_registry.cc
+++ b/chrome/browser/chromeos/drive/drive_app_registry.cc
@@ -95,6 +95,7 @@ DriveAppRegistry::DriveAppFileSelector::~DriveAppFileSelector() {
DriveAppRegistry::DriveAppRegistry(JobScheduler* scheduler)
: scheduler_(scheduler),
+ is_updating_(false),
weak_ptr_factory_(this) {
}
@@ -137,6 +138,11 @@ void DriveAppRegistry::GetAppsForFile(
void DriveAppRegistry::Update() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ if (is_updating_) // There is already an update in progress.
+ return;
+
+ is_updating_ = true;
+
scheduler_->GetAppList(
base::Bind(&DriveAppRegistry::UpdateAfterGetAppList,
weak_ptr_factory_.GetWeakPtr()));
@@ -147,6 +153,9 @@ void DriveAppRegistry::UpdateAfterGetAppList(
scoped_ptr<google_apis::AppList> app_list) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ DCHECK(is_updating_);
+ is_updating_ = false;
+
FileError error = GDataToFileError(gdata_error);
if (error != FILE_ERROR_OK) {
// Failed to fetch the data from the server. We can do nothing here.
« no previous file with comments | « chrome/browser/chromeos/drive/drive_app_registry.h ('k') | chrome/browser/chromeos/drive/drive_app_registry_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698