| 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/base64url.h" | 9 #include "base/base64url.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| 11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
| 12 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
| 13 #include "base/rand_util.h" | 13 #include "base/rand_util.h" |
| 14 #include "base/timer/timer.h" | 14 #include "base/timer/timer.h" |
| 15 #include "components/data_use_measurement/core/data_use_user_data.h" |
| 15 #include "components/safe_browsing_db/safebrowsing.pb.h" | 16 #include "components/safe_browsing_db/safebrowsing.pb.h" |
| 16 #include "net/base/load_flags.h" | 17 #include "net/base/load_flags.h" |
| 17 #include "net/http/http_response_headers.h" | 18 #include "net/http/http_response_headers.h" |
| 18 #include "net/http/http_status_code.h" | 19 #include "net/http/http_status_code.h" |
| 19 #include "net/url_request/url_fetcher.h" | 20 #include "net/url_request/url_fetcher.h" |
| 20 #include "net/url_request/url_request_context_getter.h" | 21 #include "net/url_request/url_request_context_getter.h" |
| 21 | 22 |
| 22 using base::Time; | 23 using base::Time; |
| 23 using base::TimeDelta; | 24 using base::TimeDelta; |
| 24 | 25 |
| (...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 } | 280 } |
| 280 | 281 |
| 281 std::string req_base64 = GetBase64SerializedUpdateRequestProto(); | 282 std::string req_base64 = GetBase64SerializedUpdateRequestProto(); |
| 282 GURL update_url; | 283 GURL update_url; |
| 283 net::HttpRequestHeaders headers; | 284 net::HttpRequestHeaders headers; |
| 284 GetUpdateUrlAndHeaders(req_base64, &update_url, &headers); | 285 GetUpdateUrlAndHeaders(req_base64, &update_url, &headers); |
| 285 | 286 |
| 286 std::unique_ptr<net::URLFetcher> fetcher = net::URLFetcher::Create( | 287 std::unique_ptr<net::URLFetcher> fetcher = net::URLFetcher::Create( |
| 287 url_fetcher_id_++, update_url, net::URLFetcher::GET, this); | 288 url_fetcher_id_++, update_url, net::URLFetcher::GET, this); |
| 288 fetcher->SetExtraRequestHeaders(headers.ToString()); | 289 fetcher->SetExtraRequestHeaders(headers.ToString()); |
| 290 data_use_measurement::DataUseUserData::AttachToFetcher( |
| 291 fetcher.get(), data_use_measurement::DataUseUserData::SAFE_BROWSING); |
| 289 | 292 |
| 290 request_.reset(fetcher.release()); | 293 request_.reset(fetcher.release()); |
| 291 | 294 |
| 292 request_->SetLoadFlags(net::LOAD_DISABLE_CACHE); | 295 request_->SetLoadFlags(net::LOAD_DISABLE_CACHE); |
| 293 request_->SetRequestContext(request_context_getter_.get()); | 296 request_->SetRequestContext(request_context_getter_.get()); |
| 294 request_->Start(); | 297 request_->Start(); |
| 295 // TODO(vakh): Handle request timeout. | 298 // TODO(vakh): Handle request timeout. |
| 296 } | 299 } |
| 297 | 300 |
| 298 // net::URLFetcherDelegate implementation ---------------------------------- | 301 // net::URLFetcherDelegate implementation ---------------------------------- |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 | 352 |
| 350 void V4UpdateProtocolManager::GetUpdateUrlAndHeaders( | 353 void V4UpdateProtocolManager::GetUpdateUrlAndHeaders( |
| 351 const std::string& req_base64, | 354 const std::string& req_base64, |
| 352 GURL* gurl, | 355 GURL* gurl, |
| 353 net::HttpRequestHeaders* headers) const { | 356 net::HttpRequestHeaders* headers) const { |
| 354 V4ProtocolManagerUtil::GetRequestUrlAndHeaders( | 357 V4ProtocolManagerUtil::GetRequestUrlAndHeaders( |
| 355 req_base64, "threatListUpdates:fetch", config_, gurl, headers); | 358 req_base64, "threatListUpdates:fetch", config_, gurl, headers); |
| 356 } | 359 } |
| 357 | 360 |
| 358 } // namespace safe_browsing | 361 } // namespace safe_browsing |
| OLD | NEW |