| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/renderer/prefetch_helper.h" | 5 #include "chrome/renderer/prefetch_helper.h" |
| 6 | 6 |
| 7 #include "chrome/common/prefetch_messages.h" | 7 #include "chrome/common/prefetch_messages.h" |
| 8 #include "content/public/renderer/render_frame.h" | 8 #include "content/public/renderer/render_frame.h" |
| 9 #include "third_party/WebKit/public/web/WebFrame.h" | 9 #include "third_party/WebKit/public/web/WebFrame.h" |
| 10 #include "third_party/WebKit/public/web/WebURLLoaderOptions.h" | 10 #include "third_party/WebKit/public/web/WebURLLoaderOptions.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 IPC_MESSAGE_HANDLER(PrefetchMsg_Prefetch, OnPrefetch) | 26 IPC_MESSAGE_HANDLER(PrefetchMsg_Prefetch, OnPrefetch) |
| 27 IPC_MESSAGE_UNHANDLED(handled = false) | 27 IPC_MESSAGE_UNHANDLED(handled = false) |
| 28 IPC_END_MESSAGE_MAP() | 28 IPC_END_MESSAGE_MAP() |
| 29 | 29 |
| 30 return handled; | 30 return handled; |
| 31 } | 31 } |
| 32 | 32 |
| 33 void PrefetchHelper::OnPrefetch(const GURL& url) { | 33 void PrefetchHelper::OnPrefetch(const GURL& url) { |
| 34 blink::WebFrame* frame = render_frame()->GetWebFrame(); | 34 blink::WebFrame* frame = render_frame()->GetWebFrame(); |
| 35 blink::WebURLRequest request(url); | 35 blink::WebURLRequest request(url); |
| 36 request.setTargetType(blink::WebURLRequest::TargetIsPrefetch); | 36 request.setRequestContext(blink::WebURLRequest::RequestContextPrefetch); |
| 37 request.setPriority(blink::WebURLRequest::PriorityVeryLow); | 37 request.setPriority(blink::WebURLRequest::PriorityVeryLow); |
| 38 blink::WebURLLoaderOptions options; | 38 blink::WebURLLoaderOptions options; |
| 39 options.allowCredentials = true; | 39 options.allowCredentials = true; |
| 40 options.crossOriginRequestPolicy = | 40 options.crossOriginRequestPolicy = |
| 41 blink::WebURLLoaderOptions::CrossOriginRequestPolicyAllow; | 41 blink::WebURLLoaderOptions::CrossOriginRequestPolicyAllow; |
| 42 blink::WebURLLoader* loader = frame->createAssociatedURLLoader(options); | 42 blink::WebURLLoader* loader = frame->createAssociatedURLLoader(options); |
| 43 loader->loadAsynchronously(request, this); | 43 loader->loadAsynchronously(request, this); |
| 44 loader_set_.insert(loader); | 44 loader_set_.insert(loader); |
| 45 } | 45 } |
| 46 | 46 |
| 47 void PrefetchHelper::didFinishLoading(blink::WebURLLoader* loader, | 47 void PrefetchHelper::didFinishLoading(blink::WebURLLoader* loader, |
| 48 double finishTime, | 48 double finishTime, |
| 49 int64_t totalEncodedDataLength) { | 49 int64_t totalEncodedDataLength) { |
| 50 loader_set_.erase(loader); | 50 loader_set_.erase(loader); |
| 51 } | 51 } |
| 52 | 52 |
| 53 void PrefetchHelper::didFail(blink::WebURLLoader* loader, | 53 void PrefetchHelper::didFail(blink::WebURLLoader* loader, |
| 54 const blink::WebURLError& error) { | 54 const blink::WebURLError& error) { |
| 55 loader_set_.erase(loader); | 55 loader_set_.erase(loader); |
| 56 } | 56 } |
| 57 | 57 |
| 58 } // namespace prefetch | 58 } // namespace prefetch |
| OLD | NEW |