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

Side by Side Diff: extensions/browser/updater/extension_downloader.cc

Issue 1956893004: Don't send extension info for non-webstore extensions during update check (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix unittests Created 4 years, 7 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
« no previous file with comments | « extensions/browser/updater/extension_downloader.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "extensions/browser/updater/extension_downloader.h" 5 #include "extensions/browser/updater/extension_downloader.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 : OAuth2TokenService::Consumer(kTokenServiceConsumerId), 186 : OAuth2TokenService::Consumer(kTokenServiceConsumerId),
187 delegate_(delegate), 187 delegate_(delegate),
188 request_context_(request_context), 188 request_context_(request_context),
189 manifests_queue_(&kDefaultBackoffPolicy, 189 manifests_queue_(&kDefaultBackoffPolicy,
190 base::Bind(&ExtensionDownloader::CreateManifestFetcher, 190 base::Bind(&ExtensionDownloader::CreateManifestFetcher,
191 base::Unretained(this))), 191 base::Unretained(this))),
192 extensions_queue_(&kDefaultBackoffPolicy, 192 extensions_queue_(&kDefaultBackoffPolicy,
193 base::Bind(&ExtensionDownloader::CreateExtensionFetcher, 193 base::Bind(&ExtensionDownloader::CreateExtensionFetcher,
194 base::Unretained(this))), 194 base::Unretained(this))),
195 extension_cache_(NULL), 195 extension_cache_(NULL),
196 enable_extra_update_metrics_(false),
197 weak_ptr_factory_(this) { 196 weak_ptr_factory_(this) {
198 DCHECK(delegate_); 197 DCHECK(delegate_);
199 DCHECK(request_context_.get()); 198 DCHECK(request_context_.get());
200 } 199 }
201 200
202 ExtensionDownloader::~ExtensionDownloader() { 201 ExtensionDownloader::~ExtensionDownloader() {
203 } 202 }
204 203
205 bool ExtensionDownloader::AddExtension(const Extension& extension, 204 bool ExtensionDownloader::AddExtension(const Extension& extension,
206 int request_id) { 205 int request_id) {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 break; 335 break;
337 case Manifest::TYPE_PLATFORM_APP: 336 case Manifest::TYPE_PLATFORM_APP:
338 ++url_stats_.platform_app_count; 337 ++url_stats_.platform_app_count;
339 break; 338 break;
340 case Manifest::TYPE_UNKNOWN: 339 case Manifest::TYPE_UNKNOWN:
341 default: 340 default:
342 ++url_stats_.pending_count; 341 ++url_stats_.pending_count;
343 break; 342 break;
344 } 343 }
345 344
346 std::vector<GURL> update_urls; 345 DCHECK(!update_url.is_empty());
347 update_urls.push_back(update_url); 346 DCHECK(update_url.is_valid());
348 // If metrics are enabled, also add to ManifestFetchData for the 347
349 // webstore update URL. 348 std::string install_source = extension_urls::IsWebstoreUpdateUrl(update_url)
350 if (!extension_urls::IsWebstoreUpdateUrl(update_url) && 349 ? kDefaultInstallSource
351 enable_extra_update_metrics_) { 350 : kNotFromWebstoreInstallSource;
352 update_urls.push_back(extension_urls::GetWebstoreUpdateUrl()); 351
352 ManifestFetchData::PingData ping_data;
353 ManifestFetchData::PingData* optional_ping_data = NULL;
354 if (delegate_->GetPingDataForExtension(id, &ping_data))
355 optional_ping_data = &ping_data;
356
357 // Find or create a ManifestFetchData to add this extension to.
358 bool added = false;
359 FetchMap::iterator existing_iter =
360 fetches_preparing_.find(std::make_pair(request_id, update_url));
361 if (existing_iter != fetches_preparing_.end() &&
362 !existing_iter->second.empty()) {
363 // Try to add to the ManifestFetchData at the end of the list.
364 ManifestFetchData* existing_fetch = existing_iter->second.back().get();
365 if (existing_fetch->AddExtension(id, version.GetString(),
366 optional_ping_data, update_url_data,
367 install_source)) {
368 added = true;
369 }
353 } 370 }
354 371 if (!added) {
355 for (size_t i = 0; i < update_urls.size(); ++i) { 372 // Otherwise add a new element to the list, if the list doesn't exist or
356 DCHECK(!update_urls[i].is_empty()); 373 // if its last element is already full.
357 DCHECK(update_urls[i].is_valid()); 374 linked_ptr<ManifestFetchData> fetch(
358 375 CreateManifestFetchData(update_url, request_id));
359 std::string install_source = 376 fetches_preparing_[std::make_pair(request_id, update_url)].push_back(fetch);
360 i == 0 ? kDefaultInstallSource : kNotFromWebstoreInstallSource; 377 added = fetch->AddExtension(id, version.GetString(), optional_ping_data,
361 378 update_url_data, install_source);
362 ManifestFetchData::PingData ping_data; 379 DCHECK(added);
363 ManifestFetchData::PingData* optional_ping_data = NULL;
364 if (delegate_->GetPingDataForExtension(id, &ping_data))
365 optional_ping_data = &ping_data;
366
367 // Find or create a ManifestFetchData to add this extension to.
368 bool added = false;
369 FetchMap::iterator existing_iter =
370 fetches_preparing_.find(std::make_pair(request_id, update_urls[i]));
371 if (existing_iter != fetches_preparing_.end() &&
372 !existing_iter->second.empty()) {
373 // Try to add to the ManifestFetchData at the end of the list.
374 ManifestFetchData* existing_fetch = existing_iter->second.back().get();
375 if (existing_fetch->AddExtension(id, version.GetString(),
376 optional_ping_data, update_url_data,
377 install_source)) {
378 added = true;
379 }
380 }
381 if (!added) {
382 // Otherwise add a new element to the list, if the list doesn't exist or
383 // if its last element is already full.
384 linked_ptr<ManifestFetchData> fetch(
385 CreateManifestFetchData(update_urls[i], request_id));
386 fetches_preparing_[std::make_pair(request_id, update_urls[i])].push_back(
387 fetch);
388 added = fetch->AddExtension(id, version.GetString(), optional_ping_data,
389 update_url_data, install_source);
390 DCHECK(added);
391 }
392 } 380 }
393 381
394 return true; 382 return true;
395 } 383 }
396 384
397 void ExtensionDownloader::ReportStats() const { 385 void ExtensionDownloader::ReportStats() const {
398 UMA_HISTOGRAM_COUNTS_100("Extensions.UpdateCheckExtension", 386 UMA_HISTOGRAM_COUNTS_100("Extensions.UpdateCheckExtension",
399 url_stats_.extension_count); 387 url_stats_.extension_count);
400 UMA_HISTOGRAM_COUNTS_100("Extensions.UpdateCheckTheme", 388 UMA_HISTOGRAM_COUNTS_100("Extensions.UpdateCheckTheme",
401 url_stats_.theme_count); 389 url_stats_.theme_count);
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 const GURL& update_url, 940 const GURL& update_url,
953 int request_id) { 941 int request_id) {
954 ManifestFetchData::PingMode ping_mode = ManifestFetchData::NO_PING; 942 ManifestFetchData::PingMode ping_mode = ManifestFetchData::NO_PING;
955 if (update_url.DomainIs(ping_enabled_domain_.c_str())) 943 if (update_url.DomainIs(ping_enabled_domain_.c_str()))
956 ping_mode = ManifestFetchData::PING_WITH_ENABLED_STATE; 944 ping_mode = ManifestFetchData::PING_WITH_ENABLED_STATE;
957 return new ManifestFetchData( 945 return new ManifestFetchData(
958 update_url, request_id, brand_code_, manifest_query_params_, ping_mode); 946 update_url, request_id, brand_code_, manifest_query_params_, ping_mode);
959 } 947 }
960 948
961 } // namespace extensions 949 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/updater/extension_downloader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698