| 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/safe_browsing/download_protection_service.h" | 5 #include "chrome/browser/safe_browsing/download_protection_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 if (zipped_executable_) | 774 if (zipped_executable_) |
| 775 request.mutable_archived_binary()->Swap(&archived_binary_); | 775 request.mutable_archived_binary()->Swap(&archived_binary_); |
| 776 if (!request.SerializeToString(&client_download_request_data_)) { | 776 if (!request.SerializeToString(&client_download_request_data_)) { |
| 777 FinishRequest(UNKNOWN, REASON_INVALID_REQUEST_PROTO); | 777 FinishRequest(UNKNOWN, REASON_INVALID_REQUEST_PROTO); |
| 778 return; | 778 return; |
| 779 } | 779 } |
| 780 service_->client_download_request_callbacks_.Notify(item_, &request); | 780 service_->client_download_request_callbacks_.Notify(item_, &request); |
| 781 | 781 |
| 782 DVLOG(2) << "Sending a request for URL: " | 782 DVLOG(2) << "Sending a request for URL: " |
| 783 << item_->GetUrlChain().back(); | 783 << item_->GetUrlChain().back(); |
| 784 fetcher_.reset(net::URLFetcher::Create(0 /* ID used for testing */, | 784 fetcher_ = net::URLFetcher::Create(0 /* ID used for testing */, |
| 785 GetDownloadRequestUrl(), | 785 GetDownloadRequestUrl(), |
| 786 net::URLFetcher::POST, | 786 net::URLFetcher::POST, this); |
| 787 this)); | |
| 788 fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE); | 787 fetcher_->SetLoadFlags(net::LOAD_DISABLE_CACHE); |
| 789 fetcher_->SetAutomaticallyRetryOn5xx(false); // Don't retry on error. | 788 fetcher_->SetAutomaticallyRetryOn5xx(false); // Don't retry on error. |
| 790 fetcher_->SetRequestContext(service_->request_context_getter_.get()); | 789 fetcher_->SetRequestContext(service_->request_context_getter_.get()); |
| 791 fetcher_->SetUploadData("application/octet-stream", | 790 fetcher_->SetUploadData("application/octet-stream", |
| 792 client_download_request_data_); | 791 client_download_request_data_); |
| 793 request_start_time_ = base::TimeTicks::Now(); | 792 request_start_time_ = base::TimeTicks::Now(); |
| 794 UMA_HISTOGRAM_COUNTS("SBClientDownload.DownloadRequestPayloadSize", | 793 UMA_HISTOGRAM_COUNTS("SBClientDownload.DownloadRequestPayloadSize", |
| 795 client_download_request_data_.size()); | 794 client_download_request_data_.size()); |
| 796 fetcher_->Start(); | 795 fetcher_->Start(); |
| 797 } | 796 } |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1141 GURL DownloadProtectionService::GetDownloadRequestUrl() { | 1140 GURL DownloadProtectionService::GetDownloadRequestUrl() { |
| 1142 GURL url(kDownloadRequestUrl); | 1141 GURL url(kDownloadRequestUrl); |
| 1143 std::string api_key = google_apis::GetAPIKey(); | 1142 std::string api_key = google_apis::GetAPIKey(); |
| 1144 if (!api_key.empty()) | 1143 if (!api_key.empty()) |
| 1145 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); | 1144 url = url.Resolve("?key=" + net::EscapeQueryParamValue(api_key, true)); |
| 1146 | 1145 |
| 1147 return url; | 1146 return url; |
| 1148 } | 1147 } |
| 1149 | 1148 |
| 1150 } // namespace safe_browsing | 1149 } // namespace safe_browsing |
| OLD | NEW |