OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/safe_browsing_db/v4_update_protocol_manager.h" | 5 #include "components/safe_browsing_db/v4_update_protocol_manager.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/metrics/histogram_macros.h" | 11 #include "base/metrics/histogram_macros.h" |
12 #include "base/metrics/sparse_histogram.h" | |
12 #include "base/rand_util.h" | 13 #include "base/rand_util.h" |
13 #include "base/timer/timer.h" | 14 #include "base/timer/timer.h" |
14 #include "components/safe_browsing_db/safebrowsing.pb.h" | 15 #include "components/safe_browsing_db/safebrowsing.pb.h" |
15 #include "net/base/load_flags.h" | 16 #include "net/base/load_flags.h" |
16 #include "net/http/http_response_headers.h" | 17 #include "net/http/http_response_headers.h" |
17 #include "net/http/http_status_code.h" | 18 #include "net/http/http_status_code.h" |
18 #include "net/url_request/url_fetcher.h" | 19 #include "net/url_request/url_fetcher.h" |
19 #include "net/url_request/url_request_context_getter.h" | 20 #include "net/url_request/url_request_context_getter.h" |
20 | 21 |
21 using base::Time; | 22 using base::Time; |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
321 // The callback must call ScheduleNextUpdate() at the end to resume | 322 // The callback must call ScheduleNextUpdate() at the end to resume |
322 // downloading updates. | 323 // downloading updates. |
323 update_callback_.Run(list_update_responses); | 324 update_callback_.Run(list_update_responses); |
324 } else { | 325 } else { |
325 DVLOG(1) << "SafeBrowsing GetEncodedUpdates request for: " | 326 DVLOG(1) << "SafeBrowsing GetEncodedUpdates request for: " |
326 << source->GetURL() << " failed with error: " << status.error() | 327 << source->GetURL() << " failed with error: " << status.error() |
327 << " and response code: " << response_code; | 328 << " and response code: " << response_code; |
328 | 329 |
329 if (status.status() == net::URLRequestStatus::FAILED) { | 330 if (status.status() == net::URLRequestStatus::FAILED) { |
330 RecordUpdateResult(V4OperationResult::NETWORK_ERROR); | 331 RecordUpdateResult(V4OperationResult::NETWORK_ERROR); |
332 // Negate the error value since it is negative, see: | |
333 // net/base/net_error_list.h | |
334 UMA_HISTOGRAM_SPARSE_SLOWLY("SafeBrowsing.V4UpdateNetworkError", | |
Nathan Parker
2016/06/02 20:56:31
How about recording both the network error or stat
vakh (use Gerrit instead)
2016/06/02 21:43:27
Done.
| |
335 -status.error()); | |
331 } else { | 336 } else { |
332 RecordUpdateResult(V4OperationResult::HTTP_ERROR); | 337 RecordUpdateResult(V4OperationResult::HTTP_ERROR); |
333 } | 338 } |
334 // TODO(vakh): Figure out whether it is just a network error vs backoff vs | 339 // TODO(vakh): Figure out whether it is just a network error vs backoff vs |
335 // another condition and RecordUpdateResult more accurately. | 340 // another condition and RecordUpdateResult more accurately. |
336 | 341 |
337 request_.reset(); | 342 request_.reset(); |
338 ScheduleNextUpdateWithBackoff(true); | 343 ScheduleNextUpdateWithBackoff(true); |
339 } | 344 } |
340 } | 345 } |
341 | 346 |
342 GURL V4UpdateProtocolManager::GetUpdateUrl( | 347 GURL V4UpdateProtocolManager::GetUpdateUrl( |
343 const std::string& req_base64) const { | 348 const std::string& req_base64) const { |
344 GURL url = V4ProtocolManagerUtil::GetRequestUrl(req_base64, "encodedUpdates", | 349 GURL url = V4ProtocolManagerUtil::GetRequestUrl(req_base64, "encodedUpdates", |
345 config_); | 350 config_); |
346 DVLOG(1) << "V4UpdateProtocolManager::GetUpdateUrl: " | 351 DVLOG(1) << "V4UpdateProtocolManager::GetUpdateUrl: " |
347 << "url: " << url; | 352 << "url: " << url; |
348 return url; | 353 return url; |
349 } | 354 } |
350 | 355 |
351 } // namespace safe_browsing | 356 } // namespace safe_browsing |
OLD | NEW |