| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 internal::kResourcePrefetchPredictorPrefetchedSizeHistogram, | 133 internal::kResourcePrefetchPredictorPrefetchedSizeHistogram, |
| 134 prefetched_bytes_ / 1024); | 134 prefetched_bytes_ / 1024); |
| 135 | 135 |
| 136 state_ = FINISHED; | 136 state_ = FINISHED; |
| 137 delegate_->ResourcePrefetcherFinished(this, std::move(stats_)); | 137 delegate_->ResourcePrefetcherFinished(this, std::move(stats_)); |
| 138 } | 138 } |
| 139 } | 139 } |
| 140 | 140 |
| 141 void ResourcePrefetcher::SendRequest(const GURL& url) { | 141 void ResourcePrefetcher::SendRequest(const GURL& url) { |
| 142 std::unique_ptr<net::URLRequest> url_request = | 142 std::unique_ptr<net::URLRequest> url_request = |
| 143 delegate_->GetURLRequestContext()->CreateRequest(url, net::LOW, this); | 143 delegate_->GetURLRequestContext()->CreateRequest(url, net::IDLE, this); |
| 144 host_inflight_counts_[url.host()] += 1; | 144 host_inflight_counts_[url.host()] += 1; |
| 145 | 145 |
| 146 url_request->set_method("GET"); | 146 url_request->set_method("GET"); |
| 147 url_request->set_first_party_for_cookies(main_frame_url_); | 147 url_request->set_first_party_for_cookies(main_frame_url_); |
| 148 url_request->set_initiator(url::Origin(main_frame_url_)); | 148 url_request->set_initiator(url::Origin(main_frame_url_)); |
| 149 url_request->SetReferrer(main_frame_url_.spec()); | 149 url_request->SetReferrer(main_frame_url_.spec()); |
| 150 url_request->SetLoadFlags(url_request->load_flags() | net::LOAD_PREFETCH); | 150 url_request->SetLoadFlags(url_request->load_flags() | net::LOAD_PREFETCH); |
| 151 StartURLRequest(url_request.get()); | 151 StartURLRequest(url_request.get()); |
| 152 inflight_requests_.insert( | 152 inflight_requests_.insert( |
| 153 std::make_pair(url_request.get(), std::move(url_request))); | 153 std::make_pair(url_request.get(), std::move(url_request))); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 if (bytes_read <= 0) { | 249 if (bytes_read <= 0) { |
| 250 FinishRequest(request); | 250 FinishRequest(request); |
| 251 return; | 251 return; |
| 252 } | 252 } |
| 253 | 253 |
| 254 if (bytes_read > 0) | 254 if (bytes_read > 0) |
| 255 ReadFullResponse(request); | 255 ReadFullResponse(request); |
| 256 } | 256 } |
| 257 | 257 |
| 258 } // namespace predictors | 258 } // namespace predictors |
| OLD | NEW |