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

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

Issue 2259383002: Consistently use namespaced base::Version in extensions code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 unified diff | Download patch
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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 std::string new_query_string = base::JoinString(new_query_parts, "&"); 144 std::string new_query_string = base::JoinString(new_query_parts, "&");
145 url::Component new_query(0, new_query_string.size()); 145 url::Component new_query(0, new_query_string.size());
146 url::Replacements<char> replacements; 146 url::Replacements<char> replacements;
147 replacements.SetQuery(new_query_string.c_str(), new_query); 147 replacements.SetQuery(new_query_string.c_str(), new_query);
148 *url = url->ReplaceComponents(replacements); 148 *url = url->ReplaceComponents(replacements);
149 return true; 149 return true;
150 } 150 }
151 151
152 } // namespace 152 } // namespace
153 153
154 UpdateDetails::UpdateDetails(const std::string& id, const Version& version) 154 UpdateDetails::UpdateDetails(const std::string& id,
155 : id(id), version(version) { 155 const base::Version& version)
156 } 156 : id(id), version(version) {}
157 157
158 UpdateDetails::~UpdateDetails() { 158 UpdateDetails::~UpdateDetails() {
159 } 159 }
160 160
161 ExtensionDownloader::ExtensionFetch::ExtensionFetch() 161 ExtensionDownloader::ExtensionFetch::ExtensionFetch()
162 : url(), credentials(CREDENTIALS_NONE) { 162 : url(), credentials(CREDENTIALS_NONE) {
163 } 163 }
164 164
165 ExtensionDownloader::ExtensionFetch::ExtensionFetch( 165 ExtensionDownloader::ExtensionFetch::ExtensionFetch(
166 const std::string& id, 166 const std::string& id,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 extension.id(), *extension.version(), extension.GetType(), 221 extension.id(), *extension.version(), extension.GetType(),
222 ManifestURL::GetUpdateURL(&extension), update_url_data, request_id); 222 ManifestURL::GetUpdateURL(&extension), update_url_data, request_id);
223 } 223 }
224 224
225 bool ExtensionDownloader::AddPendingExtension(const std::string& id, 225 bool ExtensionDownloader::AddPendingExtension(const std::string& id,
226 const GURL& update_url, 226 const GURL& update_url,
227 int request_id) { 227 int request_id) {
228 // Use a zero version to ensure that a pending extension will always 228 // Use a zero version to ensure that a pending extension will always
229 // be updated, and thus installed (assuming all extensions have 229 // be updated, and thus installed (assuming all extensions have
230 // non-zero versions). 230 // non-zero versions).
231 Version version("0.0.0.0"); 231 base::Version version("0.0.0.0");
232 DCHECK(version.IsValid()); 232 DCHECK(version.IsValid());
233 233
234 return AddExtensionData(id, version, Manifest::TYPE_UNKNOWN, update_url, 234 return AddExtensionData(id, version, Manifest::TYPE_UNKNOWN, update_url,
235 std::string(), request_id); 235 std::string(), request_id);
236 } 236 }
237 237
238 void ExtensionDownloader::StartAllPending(ExtensionCache* cache) { 238 void ExtensionDownloader::StartAllPending(ExtensionCache* cache) {
239 if (cache) { 239 if (cache) {
240 extension_cache_ = cache; 240 extension_cache_ = cache;
241 extension_cache_->Start(base::Bind(&ExtensionDownloader::DoStartAllPending, 241 extension_cache_->Start(base::Bind(&ExtensionDownloader::DoStartAllPending,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 identity_provider_.swap(identity_provider); 280 identity_provider_.swap(identity_provider);
281 } 281 }
282 282
283 // static 283 // static
284 void ExtensionDownloader::set_test_delegate( 284 void ExtensionDownloader::set_test_delegate(
285 ExtensionDownloaderTestDelegate* delegate) { 285 ExtensionDownloaderTestDelegate* delegate) {
286 g_test_delegate = delegate; 286 g_test_delegate = delegate;
287 } 287 }
288 288
289 bool ExtensionDownloader::AddExtensionData(const std::string& id, 289 bool ExtensionDownloader::AddExtensionData(const std::string& id,
290 const Version& version, 290 const base::Version& version,
291 Manifest::Type extension_type, 291 Manifest::Type extension_type,
292 const GURL& extension_update_url, 292 const GURL& extension_update_url,
293 const std::string& update_url_data, 293 const std::string& update_url_data,
294 int request_id) { 294 int request_id) {
295 GURL update_url(extension_update_url); 295 GURL update_url(extension_update_url);
296 // Skip extensions with non-empty invalid update URLs. 296 // Skip extensions with non-empty invalid update URLs.
297 if (!update_url.is_empty() && !update_url.is_valid()) { 297 if (!update_url.is_empty() && !update_url.is_valid()) {
298 DLOG(WARNING) << "Extension " << id << " has invalid update url " 298 DLOG(WARNING) << "Extension " << id << " has invalid update url "
299 << update_url; 299 << update_url;
300 return false; 300 return false;
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 // version is the same or older than what's already installed, 625 // version is the same or older than what's already installed,
626 // we don't want it. 626 // we don't want it.
627 std::string version; 627 std::string version;
628 if (!delegate_->GetExtensionExistingVersion(id, &version)) { 628 if (!delegate_->GetExtensionExistingVersion(id, &version)) {
629 VLOG(2) << id << " is not installed"; 629 VLOG(2) << id << " is not installed";
630 continue; 630 continue;
631 } 631 }
632 632
633 VLOG(2) << id << " is at '" << version << "'"; 633 VLOG(2) << id << " is at '" << version << "'";
634 634
635 Version existing_version(version); 635 base::Version existing_version(version);
636 Version update_version(update->version); 636 base::Version update_version(update->version);
637 if (!update_version.IsValid() || 637 if (!update_version.IsValid() ||
638 update_version.CompareTo(existing_version) <= 0) { 638 update_version.CompareTo(existing_version) <= 0) {
639 continue; 639 continue;
640 } 640 }
641 } 641 }
642 642
643 // If the update specifies a browser minimum version, do we qualify? 643 // If the update specifies a browser minimum version, do we qualify?
644 if (update->browser_min_version.length() > 0 && 644 if (update->browser_min_version.length() > 0 &&
645 !ExtensionsBrowserClient::Get()->IsMinBrowserVersionSupported( 645 !ExtensionsBrowserClient::Get()->IsMinBrowserVersionSupported(
646 update->browser_min_version)) { 646 update->browser_min_version)) {
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 it != extension_ids.end(); 843 it != extension_ids.end();
844 ++it) { 844 ++it) {
845 const ExtensionDownloaderDelegate::PingResult& ping = ping_results_[*it]; 845 const ExtensionDownloaderDelegate::PingResult& ping = ping_results_[*it];
846 delegate_->OnExtensionDownloadFailed(*it, error, ping, request_ids); 846 delegate_->OnExtensionDownloadFailed(*it, error, ping, request_ids);
847 ping_results_.erase(*it); 847 ping_results_.erase(*it);
848 } 848 }
849 } 849 }
850 850
851 void ExtensionDownloader::NotifyUpdateFound(const std::string& id, 851 void ExtensionDownloader::NotifyUpdateFound(const std::string& id,
852 const std::string& version) { 852 const std::string& version) {
853 UpdateDetails updateInfo(id, Version(version)); 853 UpdateDetails updateInfo(id, base::Version(version));
854 content::NotificationService::current()->Notify( 854 content::NotificationService::current()->Notify(
855 extensions::NOTIFICATION_EXTENSION_UPDATE_FOUND, 855 extensions::NOTIFICATION_EXTENSION_UPDATE_FOUND,
856 content::NotificationService::AllBrowserContextsAndSources(), 856 content::NotificationService::AllBrowserContextsAndSources(),
857 content::Details<UpdateDetails>(&updateInfo)); 857 content::Details<UpdateDetails>(&updateInfo));
858 } 858 }
859 859
860 bool ExtensionDownloader::IterateFetchCredentialsAfterFailure( 860 bool ExtensionDownloader::IterateFetchCredentialsAfterFailure(
861 ExtensionFetch* fetch, 861 ExtensionFetch* fetch,
862 const net::URLRequestStatus& status, 862 const net::URLRequestStatus& status,
863 int response_code) { 863 int response_code) {
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
940 const GURL& update_url, 940 const GURL& update_url,
941 int request_id) { 941 int request_id) {
942 ManifestFetchData::PingMode ping_mode = ManifestFetchData::NO_PING; 942 ManifestFetchData::PingMode ping_mode = ManifestFetchData::NO_PING;
943 if (update_url.DomainIs(ping_enabled_domain_.c_str())) 943 if (update_url.DomainIs(ping_enabled_domain_.c_str()))
944 ping_mode = ManifestFetchData::PING_WITH_ENABLED_STATE; 944 ping_mode = ManifestFetchData::PING_WITH_ENABLED_STATE;
945 return new ManifestFetchData( 945 return new ManifestFetchData(
946 update_url, request_id, brand_code_, manifest_query_params_, ping_mode); 946 update_url, request_id, brand_code_, manifest_query_params_, ping_mode);
947 } 947 }
948 948
949 } // namespace extensions 949 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/runtime/runtime_api.cc ('k') | extensions/browser/updater/update_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698