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