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

Unified Diff: chrome/browser/extensions/updater/extension_downloader.cc

Issue 465543004: Factor Chrome details out of update manifest fetching. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: clean up forward decls in CMSA Created 6 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/extensions/updater/extension_downloader.cc
diff --git a/chrome/browser/extensions/updater/extension_downloader.cc b/chrome/browser/extensions/updater/extension_downloader.cc
index 58463804bf8bb59cd53896c90f08f51b61e769b3..1296662e225b9766d9fc1082bc65d892751b5655 100644
--- a/chrome/browser/extensions/updater/extension_downloader.cc
+++ b/chrome/browser/extensions/updater/extension_downloader.cc
@@ -187,7 +187,8 @@ ExtensionDownloader::ExtensionDownloader(
extensions_queue_(&kDefaultBackoffPolicy,
base::Bind(&ExtensionDownloader::CreateExtensionFetcher,
base::Unretained(this))),
- extension_cache_(NULL) {
+ extension_cache_(NULL),
+ enable_extra_update_metrics_(false) {
DCHECK(delegate_);
DCHECK(request_context_);
}
@@ -265,9 +266,8 @@ void ExtensionDownloader::StartBlacklistUpdate(
// Note: it is very important that we use the https version of the update
// url here to avoid DNS hijacking of the blacklist, which is not validated
// by a public key signature like .crx files are.
- scoped_ptr<ManifestFetchData> blacklist_fetch(
- new ManifestFetchData(extension_urls::GetWebstoreUpdateUrl(),
- request_id));
+ scoped_ptr<ManifestFetchData> blacklist_fetch(CreateManifestFetchData(
+ extension_urls::GetWebstoreUpdateUrl(), request_id));
DCHECK(blacklist_fetch->base_url().SchemeIsSecure());
blacklist_fetch->AddExtension(kBlacklistAppID,
version,
@@ -340,10 +340,10 @@ bool ExtensionDownloader::AddExtensionData(const std::string& id,
std::vector<GURL> update_urls;
update_urls.push_back(update_url);
- // If UMA is enabled, also add to ManifestFetchData for the
+ // If metrics are enabled, also add to ManifestFetchData for the
// webstore update URL.
if (!extension_urls::IsWebstoreUpdateUrl(update_url) &&
- ChromeMetricsServiceAccessor::IsMetricsReportingEnabled()) {
+ enable_extra_update_metrics_) {
update_urls.push_back(extension_urls::GetWebstoreUpdateUrl());
}
@@ -377,7 +377,7 @@ bool ExtensionDownloader::AddExtensionData(const std::string& id,
// Otherwise add a new element to the list, if the list doesn't exist or
// if its last element is already full.
linked_ptr<ManifestFetchData> fetch(
- new ManifestFetchData(update_urls[i], request_id));
+ CreateManifestFetchData(update_urls[i], request_id));
fetches_preparing_[std::make_pair(request_id, update_urls[i])].
push_back(fetch);
added = fetch->AddExtension(id, version.GetString(),
@@ -928,4 +928,19 @@ void ExtensionDownloader::OnGetTokenFailure(
extension_fetcher_->Start();
}
+ManifestFetchData* ExtensionDownloader::CreateManifestFetchData(
+ const GURL& update_url,
+ int request_id) {
+ ManifestFetchData::PingMode ping_mode = ManifestFetchData::NO_PING;
+ if (update_url.DomainIs(ping_enabled_domain_.c_str())) {
+ if (enable_extra_update_metrics_) {
+ ping_mode = ManifestFetchData::PING_WITH_METRICS;
+ } else {
+ ping_mode = ManifestFetchData::PING;
+ }
+ }
+ return new ManifestFetchData(
+ update_url, request_id, brand_code_, manifest_query_params_, ping_mode);
+}
+
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698