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

Side by Side Diff: webkit/media/webmediaplayer_impl.cc

Issue 10543007: Add CORS-awareness to HTML5 media elements. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 6 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 | « webkit/media/webmediaplayer_impl.h ('k') | 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "webkit/media/webmediaplayer_impl.h" 5 #include "webkit/media/webmediaplayer_impl.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 // Also our timers are not very accurate (especially for ogg), which becomes 74 // Also our timers are not very accurate (especially for ogg), which becomes
75 // evident at low speeds and on Vista. Since other speeds are risky and outside 75 // evident at low speeds and on Vista. Since other speeds are risky and outside
76 // the norms, we think 1/16x to 16x is a safe and useful range for now. 76 // the norms, we think 1/16x to 16x is a safe and useful range for now.
77 const float kMinRate = 0.0625f; 77 const float kMinRate = 0.0625f;
78 const float kMaxRate = 16.0f; 78 const float kMaxRate = 16.0f;
79 79
80 } // namespace 80 } // namespace
81 81
82 namespace webkit_media { 82 namespace webkit_media {
83 83
84 #define COMPILE_ASSERT_MATCHING_ENUM(name) \
85 COMPILE_ASSERT(static_cast<int>(WebKit::WebMediaPlayer::CORSMode ## name) == \
86 static_cast<int>(BufferedResourceLoader::k ## name), \
87 mismatching_enums)
88 COMPILE_ASSERT_MATCHING_ENUM(Unspecified);
89 COMPILE_ASSERT_MATCHING_ENUM(Anonymous);
90 COMPILE_ASSERT_MATCHING_ENUM(UseCredentials);
91 #undef COMPILE_ASSERT_MATCHING_ENUM
92
84 WebMediaPlayerImpl::WebMediaPlayerImpl( 93 WebMediaPlayerImpl::WebMediaPlayerImpl(
85 WebKit::WebFrame* frame, 94 WebKit::WebFrame* frame,
86 WebKit::WebMediaPlayerClient* client, 95 WebKit::WebMediaPlayerClient* client,
87 base::WeakPtr<WebMediaPlayerDelegate> delegate, 96 base::WeakPtr<WebMediaPlayerDelegate> delegate,
88 media::FilterCollection* collection, 97 media::FilterCollection* collection,
89 WebKit::WebAudioSourceProvider* audio_source_provider, 98 WebKit::WebAudioSourceProvider* audio_source_provider,
90 media::MessageLoopFactory* message_loop_factory, 99 media::MessageLoopFactory* message_loop_factory,
91 MediaStreamClient* media_stream_client, 100 MediaStreamClient* media_stream_client,
92 media::MediaLog* media_log) 101 media::MediaLog* media_log)
93 : frame_(frame), 102 : frame_(frame),
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 if (url.SchemeIs("file")) return kFileURLScheme; 200 if (url.SchemeIs("file")) return kFileURLScheme;
192 if (url.SchemeIs("blob")) return kBlobURLScheme; 201 if (url.SchemeIs("blob")) return kBlobURLScheme;
193 if (url.SchemeIs("data")) return kDataURLScheme; 202 if (url.SchemeIs("data")) return kDataURLScheme;
194 if (url.SchemeIs("filesystem")) return kFileSystemScheme; 203 if (url.SchemeIs("filesystem")) return kFileSystemScheme;
195 return kUnknownURLScheme; 204 return kUnknownURLScheme;
196 } 205 }
197 206
198 } // anonymous namespace 207 } // anonymous namespace
199 208
200 void WebMediaPlayerImpl::load(const WebKit::WebURL& url) { 209 void WebMediaPlayerImpl::load(const WebKit::WebURL& url) {
210 load(url, CORSModeUnspecified);
211 }
212
213 void WebMediaPlayerImpl::load(const WebKit::WebURL& url, CORSMode cors_mode) {
201 DCHECK_EQ(main_loop_, MessageLoop::current()); 214 DCHECK_EQ(main_loop_, MessageLoop::current());
202 215
203 GURL gurl(url); 216 GURL gurl(url);
204 UMA_HISTOGRAM_ENUMERATION("Media.URLScheme", URLScheme(gurl), kMaxURLScheme); 217 UMA_HISTOGRAM_ENUMERATION("Media.URLScheme", URLScheme(gurl), kMaxURLScheme);
205 218
206 // Handle any volume/preload changes that occured before load(). 219 // Handle any volume/preload changes that occured before load().
207 setVolume(GetClient()->volume()); 220 setVolume(GetClient()->volume());
208 setPreload(GetClient()->preload()); 221 setPreload(GetClient()->preload());
209 222
210 SetNetworkState(WebMediaPlayer::NetworkStateLoading); 223 SetNetworkState(WebMediaPlayer::NetworkStateLoading);
(...skipping 15 matching lines...) Expand all
226 filter_collection_.get(), 239 filter_collection_.get(),
227 &video_decoder)) { 240 &video_decoder)) {
228 proxy_->set_video_decoder(video_decoder); 241 proxy_->set_video_decoder(video_decoder);
229 StartPipeline(); 242 StartPipeline();
230 return; 243 return;
231 } 244 }
232 245
233 // Otherwise it's a regular request which requires resolving the URL first. 246 // Otherwise it's a regular request which requires resolving the URL first.
234 proxy_->set_data_source( 247 proxy_->set_data_source(
235 new BufferedDataSource(main_loop_, frame_, media_log_)); 248 new BufferedDataSource(main_loop_, frame_, media_log_));
236 proxy_->data_source()->Initialize(url, base::Bind( 249 proxy_->data_source()->Initialize(
237 &WebMediaPlayerImpl::DataSourceInitialized, 250 url, static_cast<BufferedResourceLoader::CORSMode>(cors_mode),
238 base::Unretained(this), gurl)); 251 base::Bind(
252 &WebMediaPlayerImpl::DataSourceInitialized,
253 base::Unretained(this), gurl));
239 254
240 is_local_source_ = !gurl.SchemeIs("http") && !gurl.SchemeIs("https"); 255 is_local_source_ = !gurl.SchemeIs("http") && !gurl.SchemeIs("https");
241 256
242 BuildDefaultCollection(proxy_->data_source(), 257 BuildDefaultCollection(proxy_->data_source(),
243 message_loop_factory_.get(), 258 message_loop_factory_.get(),
244 filter_collection_.get(), 259 filter_collection_.get(),
245 &video_decoder); 260 &video_decoder);
246 proxy_->set_video_decoder(video_decoder); 261 proxy_->set_video_decoder(video_decoder);
247 } 262 }
248 263
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 return; 370 return;
356 } 371 }
357 372
358 #define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, chromium_name) \ 373 #define COMPILE_ASSERT_MATCHING_ENUM(webkit_name, chromium_name) \
359 COMPILE_ASSERT(static_cast<int>(WebMediaPlayer::webkit_name) == \ 374 COMPILE_ASSERT(static_cast<int>(WebMediaPlayer::webkit_name) == \
360 static_cast<int>(webkit_media::chromium_name), \ 375 static_cast<int>(webkit_media::chromium_name), \
361 mismatching_enums) 376 mismatching_enums)
362 COMPILE_ASSERT_MATCHING_ENUM(PreloadNone, NONE); 377 COMPILE_ASSERT_MATCHING_ENUM(PreloadNone, NONE);
363 COMPILE_ASSERT_MATCHING_ENUM(PreloadMetaData, METADATA); 378 COMPILE_ASSERT_MATCHING_ENUM(PreloadMetaData, METADATA);
364 COMPILE_ASSERT_MATCHING_ENUM(PreloadAuto, AUTO); 379 COMPILE_ASSERT_MATCHING_ENUM(PreloadAuto, AUTO);
380 #undef COMPILE_ASSERT_MATCHING_ENUM
365 381
366 void WebMediaPlayerImpl::setPreload(WebMediaPlayer::Preload preload) { 382 void WebMediaPlayerImpl::setPreload(WebMediaPlayer::Preload preload) {
367 DCHECK_EQ(main_loop_, MessageLoop::current()); 383 DCHECK_EQ(main_loop_, MessageLoop::current());
368 384
369 if (proxy_ && proxy_->data_source()) { 385 if (proxy_ && proxy_->data_source()) {
370 // XXX: Why do I need to use webkit_media:: prefix? clang complains! 386 // XXX: Why do I need to use webkit_media:: prefix? clang complains!
371 proxy_->data_source()->SetPreload( 387 proxy_->data_source()->SetPreload(
372 static_cast<webkit_media::Preload>(preload)); 388 static_cast<webkit_media::Preload>(preload));
373 } 389 }
374 } 390 }
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
1032 return audio_source_provider_; 1048 return audio_source_provider_;
1033 } 1049 }
1034 1050
1035 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { 1051 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() {
1036 DCHECK_EQ(main_loop_, MessageLoop::current()); 1052 DCHECK_EQ(main_loop_, MessageLoop::current());
1037 incremented_externally_allocated_memory_ = true; 1053 incremented_externally_allocated_memory_ = true;
1038 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); 1054 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory);
1039 } 1055 }
1040 1056
1041 } // namespace webkit_media 1057 } // namespace webkit_media
OLDNEW
« no previous file with comments | « webkit/media/webmediaplayer_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698