Index: chrome/browser/chromeos/extensions/external_cache.cc |
diff --git a/chrome/browser/chromeos/extensions/external_cache.cc b/chrome/browser/chromeos/extensions/external_cache.cc |
index 1f8fcaab99dee624ff3868c1c849fb6a59d642f9..cfb6c3c295fbb0dec32a1ca85a975adf01feb4de 100644 |
--- a/chrome/browser/chromeos/extensions/external_cache.cc |
+++ b/chrome/browser/chromeos/extensions/external_cache.cc |
@@ -58,6 +58,7 @@ void ExternalCache::Shutdown(const base::Closure& callback) { |
void ExternalCache::UpdateExtensionsList( |
scoped_ptr<base::DictionaryValue> prefs) { |
extensions_ = prefs.Pass(); |
+ extensions_status_.clear(); |
if (extensions_->empty()) { |
// If list of know extensions is empty, don't init cache on disk. It is |
@@ -151,13 +152,17 @@ void ExternalCache::OnExtensionDownloadFailed( |
if (!cached_extensions_->HasKey(id)) { |
LOG(ERROR) << "ExternalCache extension " << id |
<< " not found on update server"; |
+ extensions_status_[id] = DOWNLOAD_FAILED; |
delegate_->OnExtensionDownloadFailed(id, error); |
} else { |
+ // No version update for an already cached extension. |
+ extensions_status_[id] = DOWNLOAD_SUCCEEDED; |
delegate_->OnExtensionLoadedInCache(id); |
} |
} else { |
LOG(ERROR) << "ExternalCache failed to download extension " << id |
<< ", error " << error; |
+ extensions_status_[id] = DOWNLOAD_FAILED; |
delegate_->OnExtensionDownloadFailed(id, error); |
} |
} |
@@ -179,7 +184,15 @@ void ExternalCache::OnExtensionDownloadFinished( |
bool ExternalCache::IsExtensionPending(const std::string& id) { |
// Pending means that there is no installed version yet. |
- return extensions_->HasKey(id) && !cached_extensions_->HasKey(id); |
+ return extensions_->HasKey(id) && !cached_extensions_->HasKey(id) && |
+ extensions_status_.find(id) != extensions_status_.end() && |
+ extensions_status_[id] != DOWNLOAD_FAILED; |
xiyuan
2014/05/29 19:49:01
Not sure if we should change this. Other call site
jennyz
2014/07/07 21:11:12
removed the change from this function.
|
+} |
+ |
+bool ExternalCache::IsExtensionPendingForUpdateCheck(const std::string& id) { |
+ return extensions_->HasKey(id) && cached_extensions_->HasKey(id) && |
+ extensions_status_.find(id) != extensions_status_.end() && |
+ extensions_status_[id] == DOWNLOAD_PENDING; |
} |
bool ExternalCache::GetExtensionExistingVersion(const std::string& id, |
@@ -213,6 +226,7 @@ void ExternalCache::CheckCache() { |
} |
cached_extensions_->Clear(); |
+ extensions_status_.clear(); |
for (base::DictionaryValue::Iterator it(*extensions_.get()); |
!it.IsAtEnd(); it.Advance()) { |
const base::DictionaryValue* entry = NULL; |
@@ -234,8 +248,10 @@ void ExternalCache::CheckCache() { |
else if (always_check_updates_) |
update_url = extension_urls::GetWebstoreUpdateUrl(); |
- if (update_url.is_valid()) |
+ if (update_url.is_valid()) { |
downloader_->AddPendingExtension(it.key(), update_url, 0); |
+ extensions_status_[it.key()] = DOWNLOAD_PENDING; |
+ } |
} |
base::FilePath file_path; |
@@ -315,6 +331,7 @@ void ExternalCache::OnPutExtension(const std::string& id, |
file_path.value()); |
cached_extensions_->Set(id, entry); |
+ extensions_status_[id] = DOWNLOAD_SUCCEEDED; |
if (delegate_) |
delegate_->OnExtensionLoadedInCache(id); |
UpdateExtensionLoader(); |