Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/predictors/resource_prefetcher.h" | 5 #include "chrome/browser/predictors/resource_prefetcher.h" |
| 6 | 6 |
| 7 #include <iterator> | 7 #include <iterator> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 internal::kResourcePrefetchPredictorPrefetchedSizeHistogram, | 109 internal::kResourcePrefetchPredictorPrefetchedSizeHistogram, |
| 110 prefetched_bytes_ / 1024); | 110 prefetched_bytes_ / 1024); |
| 111 | 111 |
| 112 state_ = FINISHED; | 112 state_ = FINISHED; |
| 113 delegate_->ResourcePrefetcherFinished(this); | 113 delegate_->ResourcePrefetcherFinished(this); |
| 114 } | 114 } |
| 115 } | 115 } |
| 116 | 116 |
| 117 void ResourcePrefetcher::SendRequest(const GURL& url) { | 117 void ResourcePrefetcher::SendRequest(const GURL& url) { |
| 118 std::unique_ptr<net::URLRequest> url_request = | 118 std::unique_ptr<net::URLRequest> url_request = |
| 119 delegate_->GetURLRequestContext()->CreateRequest(url, net::LOW, this); | 119 delegate_->GetURLRequestContext()->CreateRequest( |
| 120 url, net::DEFAULT_PRIORITY, this); | |
|
pasko
2017/02/16 18:14:40
nit: net::LOWEST is slightly more readable
| |
| 120 host_inflight_counts_[url.host()] += 1; | 121 host_inflight_counts_[url.host()] += 1; |
| 121 | 122 |
| 122 url_request->set_method("GET"); | 123 url_request->set_method("GET"); |
| 123 url_request->set_first_party_for_cookies(main_frame_url_); | 124 url_request->set_first_party_for_cookies(main_frame_url_); |
| 124 url_request->set_initiator(url::Origin(main_frame_url_)); | 125 url_request->set_initiator(url::Origin(main_frame_url_)); |
| 125 url_request->SetReferrer(main_frame_url_.spec()); | 126 url_request->SetReferrer(main_frame_url_.spec()); |
| 126 url_request->SetLoadFlags(url_request->load_flags() | net::LOAD_PREFETCH); | 127 url_request->SetLoadFlags(url_request->load_flags() | net::LOAD_PREFETCH); |
| 127 StartURLRequest(url_request.get()); | 128 StartURLRequest(url_request.get()); |
| 128 inflight_requests_.insert( | 129 inflight_requests_.insert( |
| 129 std::make_pair(url_request.get(), std::move(url_request))); | 130 std::make_pair(url_request.get(), std::move(url_request))); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 222 if (bytes_read <= 0) { | 223 if (bytes_read <= 0) { |
| 223 FinishRequest(request); | 224 FinishRequest(request); |
| 224 return; | 225 return; |
| 225 } | 226 } |
| 226 | 227 |
| 227 if (bytes_read > 0) | 228 if (bytes_read > 0) |
| 228 ReadFullResponse(request); | 229 ReadFullResponse(request); |
| 229 } | 230 } |
| 230 | 231 |
| 231 } // namespace predictors | 232 } // namespace predictors |
| OLD | NEW |