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

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

Issue 11092054: Teach BindToLoop to create callbacks that accept scoped parameters. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Another applicable site Created 8 years, 2 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
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 #include <vector> 9 #include <vector>
10 10
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 mismatching_enums) 89 mismatching_enums)
90 COMPILE_ASSERT_MATCHING_ENUM(Unspecified); 90 COMPILE_ASSERT_MATCHING_ENUM(Unspecified);
91 COMPILE_ASSERT_MATCHING_ENUM(Anonymous); 91 COMPILE_ASSERT_MATCHING_ENUM(Anonymous);
92 COMPILE_ASSERT_MATCHING_ENUM(UseCredentials); 92 COMPILE_ASSERT_MATCHING_ENUM(UseCredentials);
93 #undef COMPILE_ASSERT_MATCHING_ENUM 93 #undef COMPILE_ASSERT_MATCHING_ENUM
94 94
95 #define BIND_TO_RENDER_LOOP(function) \ 95 #define BIND_TO_RENDER_LOOP(function) \
96 media::BindToLoop(main_loop_->message_loop_proxy(), base::Bind( \ 96 media::BindToLoop(main_loop_->message_loop_proxy(), base::Bind( \
97 function, AsWeakPtr())) 97 function, AsWeakPtr()))
98 98
99 #define BIND_TO_RENDER_LOOP_2(function, arg1, arg2) \
xhwang 2012/10/23 21:37:03 remove extra spaces?
Ami GONE FROM CHROMIUM 2012/10/23 21:58:07 Done.
100 media::BindToLoop(main_loop_->message_loop_proxy(), base::Bind( \
101 function, AsWeakPtr(), arg1, arg2))
102
99 static WebKit::WebTimeRanges ConvertToWebTimeRanges( 103 static WebKit::WebTimeRanges ConvertToWebTimeRanges(
100 const media::Ranges<base::TimeDelta>& ranges) { 104 const media::Ranges<base::TimeDelta>& ranges) {
101 WebKit::WebTimeRanges result(ranges.size()); 105 WebKit::WebTimeRanges result(ranges.size());
102 for (size_t i = 0; i < ranges.size(); i++) { 106 for (size_t i = 0; i < ranges.size(); i++) {
103 result[i].start = ranges.start(i).InSecondsF(); 107 result[i].start = ranges.start(i).InSecondsF();
104 result[i].end = ranges.end(i).InSecondsF(); 108 result[i].end = ranges.end(i).InSecondsF();
105 } 109 }
106 return result; 110 return result;
107 } 111 }
108 112
109 // TODO(acolwell): Investigate whether the key_system & session_id parameters 113 // TODO(acolwell): Investigate whether the key_system & session_id parameters
110 // are really necessary. 114 // are really necessary.
111 typedef base::Callback<void(const std::string&, 115 typedef base::Callback<void(const std::string&,
112 const std::string&, 116 const std::string&,
113 scoped_array<uint8>, 117 scoped_array<uint8>,
114 int)> OnNeedKeyCB; 118 int)> OnNeedKeyCB;
115 119
116 static void OnDemuxerNeedKeyTrampoline(
117 const scoped_refptr<base::MessageLoopProxy>& message_loop,
118 const OnNeedKeyCB& need_key_cb,
119 scoped_array<uint8> init_data,
120 int init_data_size) {
121 message_loop->PostTask(FROM_HERE, base::Bind(
122 need_key_cb, "", "", base::Passed(&init_data), init_data_size));
123 }
124
125 WebMediaPlayerImpl::WebMediaPlayerImpl( 120 WebMediaPlayerImpl::WebMediaPlayerImpl(
126 WebKit::WebFrame* frame, 121 WebKit::WebFrame* frame,
127 WebKit::WebMediaPlayerClient* client, 122 WebKit::WebMediaPlayerClient* client,
128 base::WeakPtr<WebMediaPlayerDelegate> delegate, 123 base::WeakPtr<WebMediaPlayerDelegate> delegate,
129 media::FilterCollection* collection, 124 media::FilterCollection* collection,
130 WebKit::WebAudioSourceProvider* audio_source_provider, 125 WebKit::WebAudioSourceProvider* audio_source_provider,
131 media::AudioRendererSink* audio_renderer_sink, 126 media::AudioRendererSink* audio_renderer_sink,
132 media::MessageLoopFactory* message_loop_factory, 127 media::MessageLoopFactory* message_loop_factory,
133 MediaStreamClient* media_stream_client, 128 MediaStreamClient* media_stream_client,
134 media::MediaLog* media_log) 129 media::MediaLog* media_log)
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 filter_collection_.get())) { 261 filter_collection_.get())) {
267 supports_save_ = false; 262 supports_save_ = false;
268 StartPipeline(); 263 StartPipeline();
269 return; 264 return;
270 } 265 }
271 266
272 // Media source pipelines can start immediately. 267 // Media source pipelines can start immediately.
273 if (!url.isEmpty() && url == GetClient()->sourceURL()) { 268 if (!url.isEmpty() && url == GetClient()->sourceURL()) {
274 chunk_demuxer_ = new media::ChunkDemuxer( 269 chunk_demuxer_ = new media::ChunkDemuxer(
275 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnDemuxerOpened), 270 BIND_TO_RENDER_LOOP(&WebMediaPlayerImpl::OnDemuxerOpened),
276 base::Bind(&OnDemuxerNeedKeyTrampoline, 271 BIND_TO_RENDER_LOOP_2(&WebMediaPlayerImpl::OnNeedKey, "", ""));
xhwang 2012/10/23 21:37:03 Thanks for fixing this :)
277 main_loop_->message_loop_proxy(),
278 base::Bind(&WebMediaPlayerImpl::OnNeedKey, AsWeakPtr())));
279 272
280 BuildMediaSourceCollection(chunk_demuxer_, 273 BuildMediaSourceCollection(chunk_demuxer_,
281 message_loop_factory_.get(), 274 message_loop_factory_.get(),
282 filter_collection_.get(), 275 filter_collection_.get(),
283 &decryptor_); 276 &decryptor_);
284 supports_save_ = false; 277 supports_save_ = false;
285 StartPipeline(); 278 StartPipeline();
286 return; 279 return;
287 } 280 }
288 281
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 return audio_source_provider_; 1089 return audio_source_provider_;
1097 } 1090 }
1098 1091
1099 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() { 1092 void WebMediaPlayerImpl::IncrementExternallyAllocatedMemory() {
1100 DCHECK_EQ(main_loop_, MessageLoop::current()); 1093 DCHECK_EQ(main_loop_, MessageLoop::current());
1101 incremented_externally_allocated_memory_ = true; 1094 incremented_externally_allocated_memory_ = true;
1102 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory); 1095 v8::V8::AdjustAmountOfExternalAllocatedMemory(kPlayerExtraMemory);
1103 } 1096 }
1104 1097
1105 } // namespace webkit_media 1098 } // namespace webkit_media
OLDNEW
« media/base/bind_to_loop.h.pump ('K') | « media/base/bind_to_loop_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698