| 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" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "base/metrics/sparse_histogram.h" |
| 13 #include "base/sequenced_task_runner_helpers.h" | 14 #include "base/sequenced_task_runner_helpers.h" |
| 14 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
| 15 #include "base/strings/string_number_conversions.h" | 16 #include "base/strings/string_number_conversions.h" |
| 16 #include "base/strings/string_util.h" | 17 #include "base/strings/string_util.h" |
| 17 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
| 18 #include "base/threading/sequenced_worker_pool.h" | 19 #include "base/threading/sequenced_worker_pool.h" |
| 19 #include "base/time/time.h" | 20 #include "base/time/time.h" |
| 20 #include "chrome/browser/safe_browsing/download_feedback_service.h" | 21 #include "chrome/browser/safe_browsing/download_feedback_service.h" |
| 21 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 22 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
| 22 #include "chrome/browser/safe_browsing/sandboxed_zip_analyzer.h" | 23 #include "chrome/browser/safe_browsing/sandboxed_zip_analyzer.h" |
| (...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 } | 382 } |
| 382 | 383 |
| 383 // From the net::URLFetcherDelegate interface. | 384 // From the net::URLFetcherDelegate interface. |
| 384 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE { | 385 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE { |
| 385 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 386 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 386 DCHECK_EQ(source, fetcher_.get()); | 387 DCHECK_EQ(source, fetcher_.get()); |
| 387 VLOG(2) << "Received a response for URL: " | 388 VLOG(2) << "Received a response for URL: " |
| 388 << item_->GetUrlChain().back() << ": success=" | 389 << item_->GetUrlChain().back() << ": success=" |
| 389 << source->GetStatus().is_success() << " response_code=" | 390 << source->GetStatus().is_success() << " response_code=" |
| 390 << source->GetResponseCode(); | 391 << source->GetResponseCode(); |
| 392 if (source->GetStatus().is_success()) { |
| 393 UMA_HISTOGRAM_SPARSE_SLOWLY( |
| 394 "SBClientDownload.DownloadRequestResponseCode", |
| 395 source->GetResponseCode()); |
| 396 } |
| 397 UMA_HISTOGRAM_SPARSE_SLOWLY( |
| 398 "SBClientDownload.DownloadRequestNetError", |
| 399 -source->GetStatus().error()); |
| 391 DownloadCheckResultReason reason = REASON_SERVER_PING_FAILED; | 400 DownloadCheckResultReason reason = REASON_SERVER_PING_FAILED; |
| 392 DownloadCheckResult result = SAFE; | 401 DownloadCheckResult result = SAFE; |
| 393 if (source->GetStatus().is_success() && | 402 if (source->GetStatus().is_success() && |
| 394 net::HTTP_OK == source->GetResponseCode()) { | 403 net::HTTP_OK == source->GetResponseCode()) { |
| 395 ClientDownloadResponse response; | 404 ClientDownloadResponse response; |
| 396 std::string data; | 405 std::string data; |
| 397 bool got_data = source->GetResponseAsString(&data); | 406 bool got_data = source->GetResponseAsString(&data); |
| 398 DCHECK(got_data); | 407 DCHECK(got_data); |
| 399 if (!response.ParseFromString(data)) { | 408 if (!response.ParseFromString(data)) { |
| 400 reason = REASON_INVALID_RESPONSE_PROTO; | 409 reason = REASON_INVALID_RESPONSE_PROTO; |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 952 std::string url = kDownloadRequestUrl; | 961 std::string url = kDownloadRequestUrl; |
| 953 std::string api_key = google_apis::GetAPIKey(); | 962 std::string api_key = google_apis::GetAPIKey(); |
| 954 if (!api_key.empty()) { | 963 if (!api_key.empty()) { |
| 955 base::StringAppendF(&url, "?key=%s", | 964 base::StringAppendF(&url, "?key=%s", |
| 956 net::EscapeQueryParamValue(api_key, true).c_str()); | 965 net::EscapeQueryParamValue(api_key, true).c_str()); |
| 957 } | 966 } |
| 958 return url; | 967 return url; |
| 959 } | 968 } |
| 960 | 969 |
| 961 } // namespace safe_browsing | 970 } // namespace safe_browsing |
| OLD | NEW |