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 | 8 |
| 9 #include "base/profiler/scoped_tracker.h" |
9 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
10 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
11 #include "net/base/io_buffer.h" | 12 #include "net/base/io_buffer.h" |
12 #include "net/base/request_priority.h" | 13 #include "net/base/request_priority.h" |
13 #include "net/url_request/url_request_context.h" | 14 #include "net/url_request/url_request_context.h" |
14 | 15 |
15 namespace { | 16 namespace { |
16 | 17 |
17 // The size of the buffer used to read the resource. | 18 // The size of the buffer used to read the resource. |
18 static const size_t kResourceBufferSizeBytes = 50000; | 19 static const size_t kResourceBufferSizeBytes = 50000; |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 FinishRequest(request, Request::PREFETCH_STATUS_CERT_REQUIRED); | 211 FinishRequest(request, Request::PREFETCH_STATUS_CERT_REQUIRED); |
211 } | 212 } |
212 | 213 |
213 void ResourcePrefetcher::OnSSLCertificateError(net::URLRequest* request, | 214 void ResourcePrefetcher::OnSSLCertificateError(net::URLRequest* request, |
214 const net::SSLInfo& ssl_info, | 215 const net::SSLInfo& ssl_info, |
215 bool fatal) { | 216 bool fatal) { |
216 FinishRequest(request, Request::PREFETCH_STATUS_CERT_ERROR); | 217 FinishRequest(request, Request::PREFETCH_STATUS_CERT_ERROR); |
217 } | 218 } |
218 | 219 |
219 void ResourcePrefetcher::OnResponseStarted(net::URLRequest* request) { | 220 void ResourcePrefetcher::OnResponseStarted(net::URLRequest* request) { |
| 221 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed. |
| 222 tracked_objects::ScopedTracker tracking_profile( |
| 223 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 224 "423948 ResourcePrefetcher::OnResponseStarted")); |
| 225 |
220 if (request->status().error()) { | 226 if (request->status().error()) { |
221 FinishRequest(request, Request::PREFETCH_STATUS_FAILED); | 227 FinishRequest(request, Request::PREFETCH_STATUS_FAILED); |
222 return; | 228 return; |
223 } | 229 } |
224 | 230 |
225 // TODO(shishir): Do not read cached entries, or ones that are not cacheable. | 231 // TODO(shishir): Do not read cached entries, or ones that are not cacheable. |
226 ReadFullResponse(request); | 232 ReadFullResponse(request); |
227 } | 233 } |
228 | 234 |
229 void ResourcePrefetcher::OnReadCompleted(net::URLRequest* request, | 235 void ResourcePrefetcher::OnReadCompleted(net::URLRequest* request, |
230 int bytes_read) { | 236 int bytes_read) { |
| 237 // TODO(vadimt): Remove ScopedTracker below once crbug.com/423948 is fixed. |
| 238 tracked_objects::ScopedTracker tracking_profile( |
| 239 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 240 "423948 ResourcePrefetcher::OnReadCompleted")); |
| 241 |
231 if (request->status().error()) { | 242 if (request->status().error()) { |
232 FinishRequest(request, Request::PREFETCH_STATUS_FAILED); | 243 FinishRequest(request, Request::PREFETCH_STATUS_FAILED); |
233 return; | 244 return; |
234 } | 245 } |
235 | 246 |
236 if (ShouldContinueReadingRequest(request, bytes_read)) | 247 if (ShouldContinueReadingRequest(request, bytes_read)) |
237 ReadFullResponse(request); | 248 ReadFullResponse(request); |
238 } | 249 } |
239 | 250 |
240 } // namespace predictors | 251 } // namespace predictors |
OLD | NEW |