| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extension_updater.h" | 5 #include "chrome/browser/extensions/extension_updater.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 if (ShouldPing(days)) { | 114 if (ShouldPing(days)) { |
| 115 parts.push_back("ping=" + | 115 parts.push_back("ping=" + |
| 116 EscapeQueryParamValue("r=" + base::IntToString(days), true)); | 116 EscapeQueryParamValue("r=" + base::IntToString(days), true)); |
| 117 } | 117 } |
| 118 | 118 |
| 119 std::string extra = full_url_.has_query() ? "&" : "?"; | 119 std::string extra = full_url_.has_query() ? "&" : "?"; |
| 120 extra += "x=" + EscapeQueryParamValue(JoinString(parts, '&'), true); | 120 extra += "x=" + EscapeQueryParamValue(JoinString(parts, '&'), true); |
| 121 | 121 |
| 122 // Check against our max url size, exempting the first extension added. | 122 // Check against our max url size, exempting the first extension added. |
| 123 int new_size = full_url_.possibly_invalid_spec().size() + extra.size(); | 123 int new_size = full_url_.possibly_invalid_spec().size() + extra.size(); |
| 124 if (extension_ids_.size() > 0 && new_size > kExtensionsManifestMaxURLSize) { | 124 if (!extension_ids_.empty() && new_size > kExtensionsManifestMaxURLSize) { |
| 125 UMA_HISTOGRAM_PERCENTAGE("Extensions.UpdateCheckHitUrlSizeLimit", 1); | 125 UMA_HISTOGRAM_PERCENTAGE("Extensions.UpdateCheckHitUrlSizeLimit", 1); |
| 126 return false; | 126 return false; |
| 127 } | 127 } |
| 128 UMA_HISTOGRAM_PERCENTAGE("Extensions.UpdateCheckHitUrlSizeLimit", 0); | 128 UMA_HISTOGRAM_PERCENTAGE("Extensions.UpdateCheckHitUrlSizeLimit", 0); |
| 129 | 129 |
| 130 // We have room so go ahead and add the extension. | 130 // We have room so go ahead and add the extension. |
| 131 extension_ids_.insert(id); | 131 extension_ids_.insert(id); |
| 132 ping_days_[id] = days; | 132 ping_days_[id] = days; |
| 133 full_url_ = GURL(full_url_.possibly_invalid_spec() + extra); | 133 full_url_ = GURL(full_url_.possibly_invalid_spec() + extra); |
| 134 return true; | 134 return true; |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 // TODO(asargent) do things like exponential backoff, handling | 683 // TODO(asargent) do things like exponential backoff, handling |
| 684 // 503 Service Unavailable / Retry-After headers, etc. here. | 684 // 503 Service Unavailable / Retry-After headers, etc. here. |
| 685 // (http://crbug.com/12546). | 685 // (http://crbug.com/12546). |
| 686 VLOG(1) << "Failed to fetch extension '" << url.possibly_invalid_spec() | 686 VLOG(1) << "Failed to fetch extension '" << url.possibly_invalid_spec() |
| 687 << "' response code:" << response_code; | 687 << "' response code:" << response_code; |
| 688 } | 688 } |
| 689 extension_fetcher_.reset(); | 689 extension_fetcher_.reset(); |
| 690 current_extension_fetch_ = ExtensionFetch(); | 690 current_extension_fetch_ = ExtensionFetch(); |
| 691 | 691 |
| 692 // If there are any pending downloads left, start one. | 692 // If there are any pending downloads left, start one. |
| 693 if (extensions_pending_.size() > 0) { | 693 if (!extensions_pending_.empty()) { |
| 694 ExtensionFetch next = extensions_pending_.front(); | 694 ExtensionFetch next = extensions_pending_.front(); |
| 695 extensions_pending_.pop_front(); | 695 extensions_pending_.pop_front(); |
| 696 FetchUpdatedExtension(next.id, next.url, next.package_hash, next.version); | 696 FetchUpdatedExtension(next.id, next.url, next.package_hash, next.version); |
| 697 } | 697 } |
| 698 } | 698 } |
| 699 | 699 |
| 700 void ExtensionUpdater::OnCRXFileWritten(const std::string& id, | 700 void ExtensionUpdater::OnCRXFileWritten(const std::string& id, |
| 701 const FilePath& path, | 701 const FilePath& path, |
| 702 const GURL& download_url) { | 702 const GURL& download_url) { |
| 703 // This can be called after we've been stopped. | 703 // This can be called after we've been stopped. |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 URLFetcher::Create(kExtensionFetcherId, url, URLFetcher::GET, this)); | 940 URLFetcher::Create(kExtensionFetcherId, url, URLFetcher::GET, this)); |
| 941 extension_fetcher_->set_request_context( | 941 extension_fetcher_->set_request_context( |
| 942 service_->profile()->GetRequestContext()); | 942 service_->profile()->GetRequestContext()); |
| 943 extension_fetcher_->set_load_flags(net::LOAD_DO_NOT_SEND_COOKIES | | 943 extension_fetcher_->set_load_flags(net::LOAD_DO_NOT_SEND_COOKIES | |
| 944 net::LOAD_DO_NOT_SAVE_COOKIES | | 944 net::LOAD_DO_NOT_SAVE_COOKIES | |
| 945 net::LOAD_DISABLE_CACHE); | 945 net::LOAD_DISABLE_CACHE); |
| 946 extension_fetcher_->Start(); | 946 extension_fetcher_->Start(); |
| 947 current_extension_fetch_ = ExtensionFetch(id, url, hash, version); | 947 current_extension_fetch_ = ExtensionFetch(id, url, hash, version); |
| 948 } | 948 } |
| 949 } | 949 } |
| OLD | NEW |