| OLD | NEW |
| 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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 request_context_(request_context), | 182 request_context_(request_context), |
| 183 weak_ptr_factory_(this), | 183 weak_ptr_factory_(this), |
| 184 manifests_queue_(&kDefaultBackoffPolicy, | 184 manifests_queue_(&kDefaultBackoffPolicy, |
| 185 base::Bind(&ExtensionDownloader::CreateManifestFetcher, | 185 base::Bind(&ExtensionDownloader::CreateManifestFetcher, |
| 186 base::Unretained(this))), | 186 base::Unretained(this))), |
| 187 extensions_queue_(&kDefaultBackoffPolicy, | 187 extensions_queue_(&kDefaultBackoffPolicy, |
| 188 base::Bind(&ExtensionDownloader::CreateExtensionFetcher, | 188 base::Bind(&ExtensionDownloader::CreateExtensionFetcher, |
| 189 base::Unretained(this))), | 189 base::Unretained(this))), |
| 190 extension_cache_(NULL) { | 190 extension_cache_(NULL) { |
| 191 DCHECK(delegate_); | 191 DCHECK(delegate_); |
| 192 DCHECK(request_context_); | 192 DCHECK(request_context_.get()); |
| 193 } | 193 } |
| 194 | 194 |
| 195 ExtensionDownloader::~ExtensionDownloader() {} | 195 ExtensionDownloader::~ExtensionDownloader() {} |
| 196 | 196 |
| 197 bool ExtensionDownloader::AddExtension(const Extension& extension, | 197 bool ExtensionDownloader::AddExtension(const Extension& extension, |
| 198 int request_id) { | 198 int request_id) { |
| 199 // Skip extensions with empty update URLs converted from user | 199 // Skip extensions with empty update URLs converted from user |
| 200 // scripts. | 200 // scripts. |
| 201 if (extension.converted_from_user_script() && | 201 if (extension.converted_from_user_script() && |
| 202 ManifestURL::GetUpdateURL(&extension).is_empty()) { | 202 ManifestURL::GetUpdateURL(&extension).is_empty()) { |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 manifests_queue_.active_request()->extension_ids().begin(), | 448 manifests_queue_.active_request()->extension_ids().begin(), |
| 449 manifests_queue_.active_request()->extension_ids().end()); | 449 manifests_queue_.active_request()->extension_ids().end()); |
| 450 std::string id_list = JoinString(id_vector, ','); | 450 std::string id_list = JoinString(id_vector, ','); |
| 451 VLOG(2) << "Fetching " << manifests_queue_.active_request()->full_url() | 451 VLOG(2) << "Fetching " << manifests_queue_.active_request()->full_url() |
| 452 << " for " << id_list; | 452 << " for " << id_list; |
| 453 } | 453 } |
| 454 | 454 |
| 455 manifest_fetcher_.reset(net::URLFetcher::Create( | 455 manifest_fetcher_.reset(net::URLFetcher::Create( |
| 456 kManifestFetcherId, manifests_queue_.active_request()->full_url(), | 456 kManifestFetcherId, manifests_queue_.active_request()->full_url(), |
| 457 net::URLFetcher::GET, this)); | 457 net::URLFetcher::GET, this)); |
| 458 manifest_fetcher_->SetRequestContext(request_context_); | 458 manifest_fetcher_->SetRequestContext(request_context_.get()); |
| 459 manifest_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | | 459 manifest_fetcher_->SetLoadFlags(net::LOAD_DO_NOT_SEND_COOKIES | |
| 460 net::LOAD_DO_NOT_SAVE_COOKIES | | 460 net::LOAD_DO_NOT_SAVE_COOKIES | |
| 461 net::LOAD_DISABLE_CACHE); | 461 net::LOAD_DISABLE_CACHE); |
| 462 // Update checks can be interrupted if a network change is detected; this is | 462 // Update checks can be interrupted if a network change is detected; this is |
| 463 // common for the retail mode AppPack on ChromeOS. Retrying once should be | 463 // common for the retail mode AppPack on ChromeOS. Retrying once should be |
| 464 // enough to recover in those cases; let the fetcher retry up to 3 times | 464 // enough to recover in those cases; let the fetcher retry up to 3 times |
| 465 // just in case. http://crosbug.com/130602 | 465 // just in case. http://crosbug.com/130602 |
| 466 manifest_fetcher_->SetAutomaticallyRetryOnNetworkChanges(3); | 466 manifest_fetcher_->SetAutomaticallyRetryOnNetworkChanges(3); |
| 467 manifest_fetcher_->Start(); | 467 manifest_fetcher_->Start(); |
| 468 } | 468 } |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 delegate_->OnExtensionDownloadFinished(fetch_data->id, crx_path, | 718 delegate_->OnExtensionDownloadFinished(fetch_data->id, crx_path, |
| 719 file_ownership_passed, fetch_data->url, fetch_data->version, | 719 file_ownership_passed, fetch_data->url, fetch_data->version, |
| 720 ping_results_[fetch_data->id], fetch_data->request_ids); | 720 ping_results_[fetch_data->id], fetch_data->request_ids); |
| 721 ping_results_.erase(fetch_data->id); | 721 ping_results_.erase(fetch_data->id); |
| 722 } | 722 } |
| 723 | 723 |
| 724 void ExtensionDownloader::CreateExtensionFetcher() { | 724 void ExtensionDownloader::CreateExtensionFetcher() { |
| 725 const ExtensionFetch* fetch = extensions_queue_.active_request(); | 725 const ExtensionFetch* fetch = extensions_queue_.active_request(); |
| 726 extension_fetcher_.reset(net::URLFetcher::Create( | 726 extension_fetcher_.reset(net::URLFetcher::Create( |
| 727 kExtensionFetcherId, fetch->url, net::URLFetcher::GET, this)); | 727 kExtensionFetcherId, fetch->url, net::URLFetcher::GET, this)); |
| 728 extension_fetcher_->SetRequestContext(request_context_); | 728 extension_fetcher_->SetRequestContext(request_context_.get()); |
| 729 extension_fetcher_->SetAutomaticallyRetryOnNetworkChanges(3); | 729 extension_fetcher_->SetAutomaticallyRetryOnNetworkChanges(3); |
| 730 | 730 |
| 731 int load_flags = net::LOAD_DISABLE_CACHE; | 731 int load_flags = net::LOAD_DISABLE_CACHE; |
| 732 bool is_secure = fetch->url.SchemeIsSecure(); | 732 bool is_secure = fetch->url.SchemeIsSecure(); |
| 733 if (fetch->credentials != ExtensionFetch::CREDENTIALS_COOKIES || !is_secure) { | 733 if (fetch->credentials != ExtensionFetch::CREDENTIALS_COOKIES || !is_secure) { |
| 734 load_flags |= net::LOAD_DO_NOT_SEND_COOKIES | | 734 load_flags |= net::LOAD_DO_NOT_SEND_COOKIES | |
| 735 net::LOAD_DO_NOT_SAVE_COOKIES; | 735 net::LOAD_DO_NOT_SAVE_COOKIES; |
| 736 } | 736 } |
| 737 extension_fetcher_->SetLoadFlags(load_flags); | 737 extension_fetcher_->SetLoadFlags(load_flags); |
| 738 | 738 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 | 922 |
| 923 void ExtensionDownloader::OnGetTokenFailure( | 923 void ExtensionDownloader::OnGetTokenFailure( |
| 924 const OAuth2TokenService::Request* request, | 924 const OAuth2TokenService::Request* request, |
| 925 const GoogleServiceAuthError& error) { | 925 const GoogleServiceAuthError& error) { |
| 926 // If we fail to get an access token, kick the pending fetch and let it fall | 926 // If we fail to get an access token, kick the pending fetch and let it fall |
| 927 // back on cookies. | 927 // back on cookies. |
| 928 extension_fetcher_->Start(); | 928 extension_fetcher_->Start(); |
| 929 } | 929 } |
| 930 | 930 |
| 931 } // namespace extensions | 931 } // namespace extensions |
| OLD | NEW |