Chromium Code Reviews| 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_get_hash_protocol_manager.h" | 5 #include "components/safe_browsing_db/v4_get_hash_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" |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 310 if (gethash_error_count_) { | 310 if (gethash_error_count_) { |
| 311 RecordGetHashResult(V4OperationResult::BACKOFF_ERROR); | 311 RecordGetHashResult(V4OperationResult::BACKOFF_ERROR); |
| 312 } else { | 312 } else { |
| 313 RecordGetHashResult(V4OperationResult::MIN_WAIT_DURATION_ERROR); | 313 RecordGetHashResult(V4OperationResult::MIN_WAIT_DURATION_ERROR); |
| 314 } | 314 } |
| 315 std::vector<SBFullHashResult> full_hashes; | 315 std::vector<SBFullHashResult> full_hashes; |
| 316 callback.Run(full_hashes, base::Time()); | 316 callback.Run(full_hashes, base::Time()); |
| 317 return; | 317 return; |
| 318 } | 318 } |
| 319 | 319 |
| 320 net::HttpRequestHeaders headers; | |
| 320 std::string req_base64 = GetHashRequest(prefixes, platforms, threat_type); | 321 std::string req_base64 = GetHashRequest(prefixes, platforms, threat_type); |
| 321 GURL gethash_url = GetHashUrl(req_base64); | 322 GURL gethash_url = GetHashUrlAndUpdateHeaders(req_base64, &headers); |
| 322 | 323 |
| 323 net::URLFetcher* fetcher = | 324 net::URLFetcher* fetcher = |
| 324 net::URLFetcher::Create(url_fetcher_id_++, gethash_url, | 325 net::URLFetcher::Create(url_fetcher_id_++, gethash_url, |
| 325 net::URLFetcher::GET, this) | 326 net::URLFetcher::GET, this) |
| 326 .release(); | 327 .release(); |
| 328 fetcher->SetExtraRequestHeaders(headers.ToString()); | |
| 327 hash_requests_[fetcher] = callback; | 329 hash_requests_[fetcher] = callback; |
| 328 | 330 |
| 329 fetcher->SetLoadFlags(net::LOAD_DISABLE_CACHE); | 331 fetcher->SetLoadFlags(net::LOAD_DISABLE_CACHE); |
| 330 fetcher->SetRequestContext(request_context_getter_.get()); | 332 fetcher->SetRequestContext(request_context_getter_.get()); |
| 331 fetcher->Start(); | 333 fetcher->Start(); |
| 332 } | 334 } |
| 333 | 335 |
| 334 void V4GetHashProtocolManager::GetFullHashesWithApis( | 336 void V4GetHashProtocolManager::GetFullHashesWithApis( |
| 335 const std::vector<SBPrefix>& prefixes, | 337 const std::vector<SBPrefix>& prefixes, |
| 336 FullHashCallback callback) { | 338 FullHashCallback callback) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 396 hash_requests_.erase(it); | 398 hash_requests_.erase(it); |
| 397 } | 399 } |
| 398 | 400 |
| 399 void V4GetHashProtocolManager::HandleGetHashError(const Time& now) { | 401 void V4GetHashProtocolManager::HandleGetHashError(const Time& now) { |
| 400 DCHECK(CalledOnValidThread()); | 402 DCHECK(CalledOnValidThread()); |
| 401 base::TimeDelta next = V4ProtocolManagerUtil::GetNextBackOffInterval( | 403 base::TimeDelta next = V4ProtocolManagerUtil::GetNextBackOffInterval( |
| 402 &gethash_error_count_, &gethash_back_off_mult_); | 404 &gethash_error_count_, &gethash_back_off_mult_); |
| 403 next_gethash_time_ = now + next; | 405 next_gethash_time_ = now + next; |
| 404 } | 406 } |
| 405 | 407 |
| 406 GURL V4GetHashProtocolManager::GetHashUrl(const std::string& req_base64) const { | 408 GURL V4GetHashProtocolManager::GetHashUrlAndUpdateHeaders( |
|
Nathan Parker
2016/06/09 20:22:18
nit: What is the "update" mean here? How about Ge
vakh (use Gerrit instead)
2016/06/09 21:02:15
Done.
| |
| 407 return V4ProtocolManagerUtil::GetRequestUrl(req_base64, "encodedFullHashes", | 409 const std::string& req_base64, |
| 408 config_); | 410 net::HttpRequestHeaders* headers) const { |
| 411 return V4ProtocolManagerUtil::GetRequestUrlAndUpdateHeaders( | |
| 412 req_base64, "fullHashes:find", config_, headers); | |
| 409 } | 413 } |
| 410 | 414 |
| 411 | 415 |
| 412 } // namespace safe_browsing | 416 } // namespace safe_browsing |
| OLD | NEW |