OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/renderer/media/android/media_info_loader.h" | 5 #include "content/renderer/media/android/media_info_loader.h" |
6 | 6 |
| 7 #include <utility> |
| 8 |
7 #include "base/bits.h" | 9 #include "base/bits.h" |
8 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
9 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
10 #include "third_party/WebKit/public/platform/WebURLError.h" | 12 #include "third_party/WebKit/public/platform/WebURLError.h" |
11 #include "third_party/WebKit/public/platform/WebURLLoader.h" | 13 #include "third_party/WebKit/public/platform/WebURLLoader.h" |
12 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 14 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
13 #include "third_party/WebKit/public/web/WebFrame.h" | 15 #include "third_party/WebKit/public/web/WebFrame.h" |
14 | 16 |
15 using blink::WebFrame; | 17 using blink::WebFrame; |
16 using blink::WebURLError; | 18 using blink::WebURLError; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 frame->setReferrerForRequest(request, blink::WebURL()); | 54 frame->setReferrerForRequest(request, blink::WebURL()); |
53 | 55 |
54 // Since we don't actually care about the media data at this time, use a two | 56 // Since we don't actually care about the media data at this time, use a two |
55 // byte range request to avoid unnecessarily downloading resources. Not all | 57 // byte range request to avoid unnecessarily downloading resources. Not all |
56 // servers support HEAD unfortunately, so use a range request; which is no | 58 // servers support HEAD unfortunately, so use a range request; which is no |
57 // worse than the previous request+cancel code. See http://crbug.com/400788 | 59 // worse than the previous request+cancel code. See http://crbug.com/400788 |
58 request.addHTTPHeaderField("Range", "bytes=0-1"); | 60 request.addHTTPHeaderField("Range", "bytes=0-1"); |
59 | 61 |
60 scoped_ptr<WebURLLoader> loader; | 62 scoped_ptr<WebURLLoader> loader; |
61 if (test_loader_) { | 63 if (test_loader_) { |
62 loader = test_loader_.Pass(); | 64 loader = std::move(test_loader_); |
63 } else { | 65 } else { |
64 WebURLLoaderOptions options; | 66 WebURLLoaderOptions options; |
65 if (cors_mode_ == blink::WebMediaPlayer::CORSModeUnspecified) { | 67 if (cors_mode_ == blink::WebMediaPlayer::CORSModeUnspecified) { |
66 options.allowCredentials = true; | 68 options.allowCredentials = true; |
67 options.crossOriginRequestPolicy = | 69 options.crossOriginRequestPolicy = |
68 WebURLLoaderOptions::CrossOriginRequestPolicyAllow; | 70 WebURLLoaderOptions::CrossOriginRequestPolicyAllow; |
69 allow_stored_credentials_ = true; | 71 allow_stored_credentials_ = true; |
70 } else { | 72 } else { |
71 options.exposeAllResponseHeaders = true; | 73 options.exposeAllResponseHeaders = true; |
72 // The author header set is empty, no preflight should go ahead. | 74 // The author header set is empty, no preflight should go ahead. |
73 options.preflightPolicy = WebURLLoaderOptions::PreventPreflight; | 75 options.preflightPolicy = WebURLLoaderOptions::PreventPreflight; |
74 options.crossOriginRequestPolicy = | 76 options.crossOriginRequestPolicy = |
75 WebURLLoaderOptions::CrossOriginRequestPolicyUseAccessControl; | 77 WebURLLoaderOptions::CrossOriginRequestPolicyUseAccessControl; |
76 if (cors_mode_ == blink::WebMediaPlayer::CORSModeUseCredentials) { | 78 if (cors_mode_ == blink::WebMediaPlayer::CORSModeUseCredentials) { |
77 options.allowCredentials = true; | 79 options.allowCredentials = true; |
78 allow_stored_credentials_ = true; | 80 allow_stored_credentials_ = true; |
79 } | 81 } |
80 } | 82 } |
81 loader.reset(frame->createAssociatedURLLoader(options)); | 83 loader.reset(frame->createAssociatedURLLoader(options)); |
82 } | 84 } |
83 | 85 |
84 // Start the resource loading. | 86 // Start the resource loading. |
85 loader->loadAsynchronously(request, this); | 87 loader->loadAsynchronously(request, this); |
86 active_loader_.reset(new media::ActiveLoader(loader.Pass())); | 88 active_loader_.reset(new media::ActiveLoader(std::move(loader))); |
87 } | 89 } |
88 | 90 |
89 ///////////////////////////////////////////////////////////////////////////// | 91 ///////////////////////////////////////////////////////////////////////////// |
90 // blink::WebURLLoaderClient implementation. | 92 // blink::WebURLLoaderClient implementation. |
91 void MediaInfoLoader::willFollowRedirect( | 93 void MediaInfoLoader::willFollowRedirect( |
92 WebURLLoader* loader, | 94 WebURLLoader* loader, |
93 WebURLRequest& newRequest, | 95 WebURLRequest& newRequest, |
94 const WebURLResponse& redirectResponse) { | 96 const WebURLResponse& redirectResponse) { |
95 // The load may have been stopped and |ready_cb| is destroyed. | 97 // The load may have been stopped and |ready_cb| is destroyed. |
96 // In this case we shouldn't do anything. | 98 // In this case we shouldn't do anything. |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 void MediaInfoLoader::DidBecomeReady(Status status) { | 207 void MediaInfoLoader::DidBecomeReady(Status status) { |
206 UMA_HISTOGRAM_TIMES("Media.InfoLoadDelay", | 208 UMA_HISTOGRAM_TIMES("Media.InfoLoadDelay", |
207 base::TimeTicks::Now() - start_time_); | 209 base::TimeTicks::Now() - start_time_); |
208 active_loader_.reset(); | 210 active_loader_.reset(); |
209 if (!ready_cb_.is_null()) | 211 if (!ready_cb_.is_null()) |
210 base::ResetAndReturn(&ready_cb_).Run(status, url_, first_party_url_, | 212 base::ResetAndReturn(&ready_cb_).Run(status, url_, first_party_url_, |
211 allow_stored_credentials_); | 213 allow_stored_credentials_); |
212 } | 214 } |
213 | 215 |
214 } // namespace content | 216 } // namespace content |
OLD | NEW |