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

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

Issue 109673004: Revert "Update all users of base::Version to explicitly specify the namespace, and clean up the hea… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
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 "chrome/browser/extensions/updater/extension_downloader.h" 5 #include "chrome/browser/extensions/updater/extension_downloader.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 bool ShouldRetryRequest(const net::URLRequestStatus& status, 89 bool ShouldRetryRequest(const net::URLRequestStatus& status,
90 int response_code) { 90 int response_code) {
91 // Retry if the response code is a server error, or the request failed because 91 // Retry if the response code is a server error, or the request failed because
92 // of network errors as opposed to file errors. 92 // of network errors as opposed to file errors.
93 return (response_code >= 500 && status.is_success()) || 93 return (response_code >= 500 && status.is_success()) ||
94 status.status() == net::URLRequestStatus::FAILED; 94 status.status() == net::URLRequestStatus::FAILED;
95 } 95 }
96 96
97 } // namespace 97 } // namespace
98 98
99 UpdateDetails::UpdateDetails(const std::string& id, 99 UpdateDetails::UpdateDetails(const std::string& id, const Version& version)
100 const base::Version& version)
101 : id(id), version(version) {} 100 : id(id), version(version) {}
102 101
103 UpdateDetails::~UpdateDetails() {} 102 UpdateDetails::~UpdateDetails() {}
104 103
105 ExtensionDownloader::ExtensionFetch::ExtensionFetch() : url() {} 104 ExtensionDownloader::ExtensionFetch::ExtensionFetch() : url() {}
106 105
107 ExtensionDownloader::ExtensionFetch::ExtensionFetch( 106 ExtensionDownloader::ExtensionFetch::ExtensionFetch(
108 const std::string& id, 107 const std::string& id,
109 const GURL& url, 108 const GURL& url,
110 const std::string& package_hash, 109 const std::string& package_hash,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 ManifestURL::GetUpdateURL(&extension), 153 ManifestURL::GetUpdateURL(&extension),
155 update_url_data, request_id); 154 update_url_data, request_id);
156 } 155 }
157 156
158 bool ExtensionDownloader::AddPendingExtension(const std::string& id, 157 bool ExtensionDownloader::AddPendingExtension(const std::string& id,
159 const GURL& update_url, 158 const GURL& update_url,
160 int request_id) { 159 int request_id) {
161 // Use a zero version to ensure that a pending extension will always 160 // Use a zero version to ensure that a pending extension will always
162 // be updated, and thus installed (assuming all extensions have 161 // be updated, and thus installed (assuming all extensions have
163 // non-zero versions). 162 // non-zero versions).
164 base::Version version("0.0.0.0"); 163 Version version("0.0.0.0");
165 DCHECK(version.IsValid()); 164 DCHECK(version.IsValid());
166 165
167 return AddExtensionData(id, 166 return AddExtensionData(id,
168 version, 167 version,
169 Manifest::TYPE_UNKNOWN, 168 Manifest::TYPE_UNKNOWN,
170 update_url, 169 update_url,
171 std::string(), 170 std::string(),
172 request_id); 171 request_id);
173 } 172 }
174 173
(...skipping 24 matching lines...) Expand all
199 DCHECK(blacklist_fetch->base_url().SchemeIsSecure()); 198 DCHECK(blacklist_fetch->base_url().SchemeIsSecure());
200 blacklist_fetch->AddExtension(kBlacklistAppID, 199 blacklist_fetch->AddExtension(kBlacklistAppID,
201 version, 200 version,
202 &ping_data, 201 &ping_data,
203 std::string(), 202 std::string(),
204 kDefaultInstallSource); 203 kDefaultInstallSource);
205 StartUpdateCheck(blacklist_fetch.Pass()); 204 StartUpdateCheck(blacklist_fetch.Pass());
206 } 205 }
207 206
208 bool ExtensionDownloader::AddExtensionData(const std::string& id, 207 bool ExtensionDownloader::AddExtensionData(const std::string& id,
209 const base::Version& version, 208 const Version& version,
210 Manifest::Type extension_type, 209 Manifest::Type extension_type,
211 const GURL& extension_update_url, 210 const GURL& extension_update_url,
212 const std::string& update_url_data, 211 const std::string& update_url_data,
213 int request_id) { 212 int request_id) {
214 GURL update_url(extension_update_url); 213 GURL update_url(extension_update_url);
215 // Skip extensions with non-empty invalid update URLs. 214 // Skip extensions with non-empty invalid update URLs.
216 if (!update_url.is_empty() && !update_url.is_valid()) { 215 if (!update_url.is_empty() && !update_url.is_valid()) {
217 LOG(WARNING) << "Extension " << id << " has invalid update url " 216 LOG(WARNING) << "Extension " << id << " has invalid update url "
218 << update_url; 217 << update_url;
219 return false; 218 return false;
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 fetch_data.request_ids(), 523 fetch_data.request_ids(),
525 ExtensionDownloaderDelegate::NO_UPDATE_AVAILABLE); 524 ExtensionDownloaderDelegate::NO_UPDATE_AVAILABLE);
526 } 525 }
527 526
528 void ExtensionDownloader::DetermineUpdates( 527 void ExtensionDownloader::DetermineUpdates(
529 const ManifestFetchData& fetch_data, 528 const ManifestFetchData& fetch_data,
530 const UpdateManifest::Results& possible_updates, 529 const UpdateManifest::Results& possible_updates,
531 std::vector<int>* result) { 530 std::vector<int>* result) {
532 // This will only be valid if one of possible_updates specifies 531 // This will only be valid if one of possible_updates specifies
533 // browser_min_version. 532 // browser_min_version.
534 base::Version browser_version; 533 Version browser_version;
535 534
536 for (size_t i = 0; i < possible_updates.list.size(); i++) { 535 for (size_t i = 0; i < possible_updates.list.size(); i++) {
537 const UpdateManifest::Result* update = &possible_updates.list[i]; 536 const UpdateManifest::Result* update = &possible_updates.list[i];
538 const std::string& id = update->extension_id; 537 const std::string& id = update->extension_id;
539 538
540 if (!fetch_data.Includes(id)) { 539 if (!fetch_data.Includes(id)) {
541 VLOG(2) << "Ignoring " << id << " from this manifest"; 540 VLOG(2) << "Ignoring " << id << " from this manifest";
542 continue; 541 continue;
543 } 542 }
544 543
(...skipping 10 matching lines...) Expand all
555 // version is the same or older than what's already installed, 554 // version is the same or older than what's already installed,
556 // we don't want it. 555 // we don't want it.
557 std::string version; 556 std::string version;
558 if (!delegate_->GetExtensionExistingVersion(id, &version)) { 557 if (!delegate_->GetExtensionExistingVersion(id, &version)) {
559 VLOG(2) << id << " is not installed"; 558 VLOG(2) << id << " is not installed";
560 continue; 559 continue;
561 } 560 }
562 561
563 VLOG(2) << id << " is at '" << version << "'"; 562 VLOG(2) << id << " is at '" << version << "'";
564 563
565 base::Version existing_version(version); 564 Version existing_version(version);
566 base::Version update_version(update->version); 565 Version update_version(update->version);
567 566
568 if (!update_version.IsValid() || 567 if (!update_version.IsValid() ||
569 update_version.CompareTo(existing_version) <= 0) { 568 update_version.CompareTo(existing_version) <= 0) {
570 continue; 569 continue;
571 } 570 }
572 } 571 }
573 572
574 // If the update specifies a browser minimum version, do we qualify? 573 // If the update specifies a browser minimum version, do we qualify?
575 if (update->browser_min_version.length() > 0) { 574 if (update->browser_min_version.length() > 0) {
576 // First determine the browser version if we haven't already. 575 // First determine the browser version if we haven't already.
577 if (!browser_version.IsValid()) { 576 if (!browser_version.IsValid()) {
578 chrome::VersionInfo version_info; 577 chrome::VersionInfo version_info;
579 if (version_info.is_valid()) 578 if (version_info.is_valid())
580 browser_version = base::Version(version_info.Version()); 579 browser_version = Version(version_info.Version());
581 } 580 }
582 base::Version browser_min_version(update->browser_min_version); 581 Version browser_min_version(update->browser_min_version);
583 if (browser_version.IsValid() && browser_min_version.IsValid() && 582 if (browser_version.IsValid() && browser_min_version.IsValid() &&
584 browser_min_version.CompareTo(browser_version) > 0) { 583 browser_min_version.CompareTo(browser_version) > 0) {
585 // TODO(asargent) - We may want this to show up in the extensions UI 584 // TODO(asargent) - We may want this to show up in the extensions UI
586 // eventually. (http://crbug.com/12547). 585 // eventually. (http://crbug.com/12547).
587 LOG(WARNING) << "Updated version of extension " << id 586 LOG(WARNING) << "Updated version of extension " << id
588 << " available, but requires chrome version " 587 << " available, but requires chrome version "
589 << update->browser_min_version; 588 << update->browser_min_version;
590 continue; 589 continue;
591 } 590 }
592 } 591 }
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 for (std::set<std::string>::const_iterator it = extension_ids.begin(); 698 for (std::set<std::string>::const_iterator it = extension_ids.begin();
700 it != extension_ids.end(); ++it) { 699 it != extension_ids.end(); ++it) {
701 const ExtensionDownloaderDelegate::PingResult& ping = ping_results_[*it]; 700 const ExtensionDownloaderDelegate::PingResult& ping = ping_results_[*it];
702 delegate_->OnExtensionDownloadFailed(*it, error, ping, request_ids); 701 delegate_->OnExtensionDownloadFailed(*it, error, ping, request_ids);
703 ping_results_.erase(*it); 702 ping_results_.erase(*it);
704 } 703 }
705 } 704 }
706 705
707 void ExtensionDownloader::NotifyUpdateFound(const std::string& id, 706 void ExtensionDownloader::NotifyUpdateFound(const std::string& id,
708 const std::string& version) { 707 const std::string& version) {
709 UpdateDetails updateInfo(id, base::Version(version)); 708 UpdateDetails updateInfo(id, Version(version));
710 content::NotificationService::current()->Notify( 709 content::NotificationService::current()->Notify(
711 chrome::NOTIFICATION_EXTENSION_UPDATE_FOUND, 710 chrome::NOTIFICATION_EXTENSION_UPDATE_FOUND,
712 content::NotificationService::AllBrowserContextsAndSources(), 711 content::NotificationService::AllBrowserContextsAndSources(),
713 content::Details<UpdateDetails>(&updateInfo)); 712 content::Details<UpdateDetails>(&updateInfo));
714 } 713 }
715 714
716 } // namespace extensions 715 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698