Chromium Code Reviews| 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 UMA_HISTOGRAM_ENUMERATION("SBClientDownload.CheckDownloadRequestStatus", | |
| 393 source->GetStatus().status(), | |
| 394 net::URLRequestStatus::STATUS_MAX); | |
|
mmenke
2013/07/24 14:26:50
I'm not sure this is needed - this seems pretty re
mattm
2013/07/24 22:39:27
Sounds good, I didn't realize CANCELED would have
| |
| 395 if (source->GetStatus().is_success()) { | |
|
mattm
2013/07/24 02:19:00
is "is_success()" right here, or should I check "s
mmenke
2013/07/24 14:26:50
I think is_success() is the way to go.
| |
| 396 UMA_HISTOGRAM_SPARSE_SLOWLY( | |
| 397 "SBClientDownload.CheckDownloadRequestResponseCode", | |
| 398 source->GetResponseCode()); | |
| 399 } else if (source->GetStatus().status() == net::URLRequestStatus::FAILED) { | |
| 400 UMA_HISTOGRAM_SPARSE_SLOWLY( | |
| 401 "SBClientDownload.CheckDownloadRequestNetError", | |
| 402 source->GetStatus().error()); | |
|
mmenke
2013/07/24 14:26:50
This should be "-source->GetStatus().error()". Ne
mattm
2013/07/24 22:39:27
Done.
| |
| 403 } | |
| 391 DownloadCheckResultReason reason = REASON_SERVER_PING_FAILED; | 404 DownloadCheckResultReason reason = REASON_SERVER_PING_FAILED; |
| 392 DownloadCheckResult result = SAFE; | 405 DownloadCheckResult result = SAFE; |
| 393 if (source->GetStatus().is_success() && | 406 if (source->GetStatus().is_success() && |
| 394 net::HTTP_OK == source->GetResponseCode()) { | 407 net::HTTP_OK == source->GetResponseCode()) { |
| 395 ClientDownloadResponse response; | 408 ClientDownloadResponse response; |
| 396 std::string data; | 409 std::string data; |
| 397 bool got_data = source->GetResponseAsString(&data); | 410 bool got_data = source->GetResponseAsString(&data); |
| 398 DCHECK(got_data); | 411 DCHECK(got_data); |
| 399 if (!response.ParseFromString(data)) { | 412 if (!response.ParseFromString(data)) { |
| 400 reason = REASON_INVALID_RESPONSE_PROTO; | 413 reason = REASON_INVALID_RESPONSE_PROTO; |
| (...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 952 std::string url = kDownloadRequestUrl; | 965 std::string url = kDownloadRequestUrl; |
| 953 std::string api_key = google_apis::GetAPIKey(); | 966 std::string api_key = google_apis::GetAPIKey(); |
| 954 if (!api_key.empty()) { | 967 if (!api_key.empty()) { |
| 955 base::StringAppendF(&url, "?key=%s", | 968 base::StringAppendF(&url, "?key=%s", |
| 956 net::EscapeQueryParamValue(api_key, true).c_str()); | 969 net::EscapeQueryParamValue(api_key, true).c_str()); |
| 957 } | 970 } |
| 958 return url; | 971 return url; |
| 959 } | 972 } |
| 960 | 973 |
| 961 } // namespace safe_browsing | 974 } // namespace safe_browsing |
| OLD | NEW |