| 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/protocol_manager.h" | 5 #include "chrome/browser/safe_browsing/protocol_manager.h" |
| 6 | 6 |
| 7 #include "base/environment.h" | 7 #include "base/environment.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| 11 #include "base/profiler/scoped_profile.h" |
| 11 #include "base/rand_util.h" | 12 #include "base/rand_util.h" |
| 12 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
| 13 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
| 14 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 15 #include "base/timer/timer.h" | 16 #include "base/timer/timer.h" |
| 16 #include "chrome/browser/safe_browsing/protocol_parser.h" | 17 #include "chrome/browser/safe_browsing/protocol_parser.h" |
| 17 #include "chrome/common/chrome_version_info.h" | 18 #include "chrome/common/chrome_version_info.h" |
| 18 #include "chrome/common/env_vars.h" | 19 #include "chrome/common/env_vars.h" |
| 19 #include "google_apis/google_api_keys.h" | 20 #include "google_apis/google_api_keys.h" |
| 20 #include "net/base/escape.h" | 21 #include "net/base/escape.h" |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 // All SafeBrowsing request responses are handled here. | 220 // All SafeBrowsing request responses are handled here. |
| 220 // TODO(paulg): Clarify with the SafeBrowsing team whether a failed parse of a | 221 // TODO(paulg): Clarify with the SafeBrowsing team whether a failed parse of a |
| 221 // chunk should retry the download and parse of that chunk (and | 222 // chunk should retry the download and parse of that chunk (and |
| 222 // what back off / how many times to try), and if that effects the | 223 // what back off / how many times to try), and if that effects the |
| 223 // update back off. For now, a failed parse of the chunk means we | 224 // update back off. For now, a failed parse of the chunk means we |
| 224 // drop it. This isn't so bad because the next UPDATE_REQUEST we | 225 // drop it. This isn't so bad because the next UPDATE_REQUEST we |
| 225 // do will report all the chunks we have. If that chunk is still | 226 // do will report all the chunks we have. If that chunk is still |
| 226 // required, the SafeBrowsing servers will tell us to get it again. | 227 // required, the SafeBrowsing servers will tell us to get it again. |
| 227 void SafeBrowsingProtocolManager::OnURLFetchComplete( | 228 void SafeBrowsingProtocolManager::OnURLFetchComplete( |
| 228 const net::URLFetcher* source) { | 229 const net::URLFetcher* source) { |
| 230 // TODO(vadimt): Remove ScopedProfile below once crbug.com/422577 is fixed. |
| 231 tracked_objects::ScopedProfile tracking_profile( |
| 232 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 233 "422577 SafeBrowsingProtocolManager::OnURLFetchComplete")); |
| 234 |
| 229 DCHECK(CalledOnValidThread()); | 235 DCHECK(CalledOnValidThread()); |
| 230 scoped_ptr<const net::URLFetcher> fetcher; | 236 scoped_ptr<const net::URLFetcher> fetcher; |
| 231 | 237 |
| 232 HashRequests::iterator it = hash_requests_.find(source); | 238 HashRequests::iterator it = hash_requests_.find(source); |
| 233 if (it != hash_requests_.end()) { | 239 if (it != hash_requests_.end()) { |
| 234 // GetHash response. | 240 // GetHash response. |
| 235 fetcher.reset(it->first); | 241 fetcher.reset(it->first); |
| 236 const FullHashDetails& details = it->second; | 242 const FullHashDetails& details = it->second; |
| 237 std::vector<SBFullHashResult> full_hashes; | 243 std::vector<SBFullHashResult> full_hashes; |
| 238 base::TimeDelta cache_lifetime; | 244 base::TimeDelta cache_lifetime; |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 770 FullHashCallback callback, bool is_download) | 776 FullHashCallback callback, bool is_download) |
| 771 : callback(callback), | 777 : callback(callback), |
| 772 is_download(is_download) { | 778 is_download(is_download) { |
| 773 } | 779 } |
| 774 | 780 |
| 775 SafeBrowsingProtocolManager::FullHashDetails::~FullHashDetails() { | 781 SafeBrowsingProtocolManager::FullHashDetails::~FullHashDetails() { |
| 776 } | 782 } |
| 777 | 783 |
| 778 SafeBrowsingProtocolManagerDelegate::~SafeBrowsingProtocolManagerDelegate() { | 784 SafeBrowsingProtocolManagerDelegate::~SafeBrowsingProtocolManagerDelegate() { |
| 779 } | 785 } |
| OLD | NEW |