| Index: components/safe_browsing_db/v4_get_hash_protocol_manager.cc
|
| diff --git a/components/safe_browsing_db/v4_get_hash_protocol_manager.cc b/components/safe_browsing_db/v4_get_hash_protocol_manager.cc
|
| index aebbfe9ba0dbce3750cd86e90c491715cd0b578e..90b9caef626bdd39a3f3d4c2347bd934406c40bd 100644
|
| --- a/components/safe_browsing_db/v4_get_hash_protocol_manager.cc
|
| +++ b/components/safe_browsing_db/v4_get_hash_protocol_manager.cc
|
| @@ -116,8 +116,7 @@ V4GetHashProtocolManager::V4GetHashProtocolManager(
|
| config_(config),
|
| request_context_getter_(request_context_getter),
|
| url_fetcher_id_(0),
|
| - clock_(new base::DefaultClock()) {
|
| -}
|
| + clock_(new base::DefaultClock()) {}
|
|
|
| V4GetHashProtocolManager::~V4GetHashProtocolManager() {
|
| // Delete in-progress SafeBrowsing requests.
|
| @@ -174,14 +173,15 @@ bool V4GetHashProtocolManager::ParseHashResponse(
|
| // negative_cache_duration should always be set.
|
| DCHECK(response.has_negative_cache_duration());
|
| // Seconds resolution is good enough so we ignore the nanos field.
|
| - *negative_cache_expire = clock_->Now() + base::TimeDelta::FromSeconds(
|
| - response.negative_cache_duration().seconds());
|
| + *negative_cache_expire =
|
| + clock_->Now() + base::TimeDelta::FromSeconds(
|
| + response.negative_cache_duration().seconds());
|
|
|
| if (response.has_minimum_wait_duration()) {
|
| // Seconds resolution is good enough so we ignore the nanos field.
|
| next_gethash_time_ =
|
| clock_->Now() + base::TimeDelta::FromSeconds(
|
| - response.minimum_wait_duration().seconds());
|
| + response.minimum_wait_duration().seconds());
|
| }
|
|
|
| // We only expect one threat type per request, so we make sure
|
| @@ -191,8 +191,8 @@ bool V4GetHashProtocolManager::ParseHashResponse(
|
| // Loop over the threat matches and fill in full_hashes.
|
| for (const ThreatMatch& match : response.matches()) {
|
| // Make sure the platform and threat entry type match.
|
| - if (!(match.has_threat_entry_type() &&
|
| - match.threat_entry_type() == URL && match.has_threat())) {
|
| + if (!(match.has_threat_entry_type() && match.threat_entry_type() == URL &&
|
| + match.has_threat())) {
|
| RecordParseGetHashResult(UNEXPECTED_THREAT_ENTRY_TYPE_ERROR);
|
| return false;
|
| }
|
| @@ -215,7 +215,8 @@ bool V4GetHashProtocolManager::ParseHashResponse(
|
|
|
| if (match.has_cache_duration()) {
|
| // Seconds resolution is good enough so we ignore the nanos field.
|
| - result.cache_expire_after = clock_->Now() +
|
| + result.cache_expire_after =
|
| + clock_->Now() +
|
| base::TimeDelta::FromSeconds(match.cache_duration().seconds());
|
| } else {
|
| result.cache_expire_after = clock_->Now();
|
| @@ -318,12 +319,15 @@ void V4GetHashProtocolManager::GetFullHashes(
|
| }
|
|
|
| std::string req_base64 = GetHashRequest(prefixes, platforms, threat_type);
|
| - GURL gethash_url = GetHashUrl(req_base64);
|
| + GURL gethash_url;
|
| + net::HttpRequestHeaders headers;
|
| + GetHashUrlAndHeaders(req_base64, &gethash_url, &headers);
|
|
|
| net::URLFetcher* fetcher =
|
| net::URLFetcher::Create(url_fetcher_id_++, gethash_url,
|
| net::URLFetcher::GET, this)
|
| .release();
|
| + fetcher->SetExtraRequestHeaders(headers.ToString());
|
| hash_requests_[fetcher] = callback;
|
|
|
| fetcher->SetLoadFlags(net::LOAD_DISABLE_CACHE);
|
| @@ -403,10 +407,12 @@ void V4GetHashProtocolManager::HandleGetHashError(const Time& now) {
|
| next_gethash_time_ = now + next;
|
| }
|
|
|
| -GURL V4GetHashProtocolManager::GetHashUrl(const std::string& req_base64) const {
|
| - return V4ProtocolManagerUtil::GetRequestUrl(req_base64, "encodedFullHashes",
|
| - config_);
|
| +void V4GetHashProtocolManager::GetHashUrlAndHeaders(
|
| + const std::string& req_base64,
|
| + GURL* gurl,
|
| + net::HttpRequestHeaders* headers) const {
|
| + V4ProtocolManagerUtil::GetRequestUrlAndHeaders(req_base64, "fullHashes:find",
|
| + config_, gurl, headers);
|
| }
|
|
|
| -
|
| } // namespace safe_browsing
|
|
|