Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: content/renderer/media/android/media_info_loader.cc

Issue 485023003: Use range request for CORS access check on Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use range request. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/bits.h" 7 #include "base/bits.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "third_party/WebKit/public/platform/WebURLError.h" 10 #include "third_party/WebKit/public/platform/WebURLError.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 start_time_ = base::TimeTicks::Now(); 44 start_time_ = base::TimeTicks::Now();
45 first_party_url_ = frame->document().firstPartyForCookies(); 45 first_party_url_ = frame->document().firstPartyForCookies();
46 46
47 // Prepare the request. 47 // Prepare the request.
48 WebURLRequest request(url_); 48 WebURLRequest request(url_);
49 // TODO(mkwst): Split this into video/audio. 49 // TODO(mkwst): Split this into video/audio.
50 request.setRequestContext(WebURLRequest::RequestContextVideo); 50 request.setRequestContext(WebURLRequest::RequestContextVideo);
51 frame->setReferrerForRequest(request, blink::WebURL()); 51 frame->setReferrerForRequest(request, blink::WebURL());
52 52
53 // Since we don't actually care about the media data at this time, use a one
54 // byte range request to avoid unnecessarily downloading resources. Not all
55 // servers support HEAD unfortunately, so use a range request; which is no
56 // worse than the previous request+cancel code. See http://crbug.com/400788
57 request.addHTTPHeaderField("Range", "bytes=0-1");
acolwell GONE FROM CHROMIUM 2014/08/25 19:40:08 nit: This is a 2 byte range request. Please update
DaleCurtis 2014/08/25 19:43:18 Done.
58
53 scoped_ptr<WebURLLoader> loader; 59 scoped_ptr<WebURLLoader> loader;
54 if (test_loader_) { 60 if (test_loader_) {
55 loader = test_loader_.Pass(); 61 loader = test_loader_.Pass();
56 } else { 62 } else {
57 WebURLLoaderOptions options; 63 WebURLLoaderOptions options;
58 if (cors_mode_ == blink::WebMediaPlayer::CORSModeUnspecified) { 64 if (cors_mode_ == blink::WebMediaPlayer::CORSModeUnspecified) {
59 options.allowCredentials = true; 65 options.allowCredentials = true;
60 options.crossOriginRequestPolicy = 66 options.crossOriginRequestPolicy =
61 WebURLLoaderOptions::CrossOriginRequestPolicyAllow; 67 WebURLLoaderOptions::CrossOriginRequestPolicyAllow;
62 allow_stored_credentials_ = true; 68 allow_stored_credentials_ = true;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 << (response.httpVersion() == WebURLResponse::HTTP_0_9 ? "0.9" : 122 << (response.httpVersion() == WebURLResponse::HTTP_0_9 ? "0.9" :
117 response.httpVersion() == WebURLResponse::HTTP_1_0 ? "1.0" : 123 response.httpVersion() == WebURLResponse::HTTP_1_0 ? "1.0" :
118 response.httpVersion() == WebURLResponse::HTTP_1_1 ? "1.1" : 124 response.httpVersion() == WebURLResponse::HTTP_1_1 ? "1.1" :
119 "Unknown") 125 "Unknown")
120 << " " << response.httpStatusCode(); 126 << " " << response.httpStatusCode();
121 DCHECK(active_loader_.get()); 127 DCHECK(active_loader_.get());
122 if (!url_.SchemeIs("http") && !url_.SchemeIs("https")) { 128 if (!url_.SchemeIs("http") && !url_.SchemeIs("https")) {
123 DidBecomeReady(kOk); 129 DidBecomeReady(kOk);
124 return; 130 return;
125 } 131 }
126 if (response.httpStatusCode() == kHttpOK) { 132 if (response.httpStatusCode() == kHttpOK) {
acolwell GONE FROM CHROMIUM 2014/08/25 19:40:08 Range requests result in a 206 response so you'll
DaleCurtis 2014/08/25 19:43:19 Done.
127 DidBecomeReady(kOk); 133 DidBecomeReady(kOk);
128 return; 134 return;
129 } 135 }
130 loader_failed_ = true; 136 loader_failed_ = true;
131 DidBecomeReady(kFailed); 137 DidBecomeReady(kFailed);
132 } 138 }
133 139
134 void MediaInfoLoader::didReceiveData( 140 void MediaInfoLoader::didReceiveData(
135 WebURLLoader* loader, 141 WebURLLoader* loader,
136 const char* data, 142 const char* data,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 void MediaInfoLoader::DidBecomeReady(Status status) { 199 void MediaInfoLoader::DidBecomeReady(Status status) {
194 UMA_HISTOGRAM_TIMES("Media.InfoLoadDelay", 200 UMA_HISTOGRAM_TIMES("Media.InfoLoadDelay",
195 base::TimeTicks::Now() - start_time_); 201 base::TimeTicks::Now() - start_time_);
196 active_loader_.reset(); 202 active_loader_.reset();
197 if (!ready_cb_.is_null()) 203 if (!ready_cb_.is_null())
198 base::ResetAndReturn(&ready_cb_).Run(status, url_, first_party_url_, 204 base::ResetAndReturn(&ready_cb_).Run(status, url_, first_party_url_,
199 allow_stored_credentials_); 205 allow_stored_credentials_);
200 } 206 }
201 207
202 } // namespace content 208 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698