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

Side by Side Diff: webkit/glue/media/simple_data_source.cc

Issue 7452016: Remove MediaFormat once and for all. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src
Patch Set: Created 9 years, 5 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/glue/media/simple_data_source.h ('k') | webkit/glue/webmediaplayer_impl.cc » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/glue/media/simple_data_source.h" 5 #include "webkit/glue/media/simple_data_source.h"
6 6
7 #include "base/message_loop.h" 7 #include "base/message_loop.h"
8 #include "base/process_util.h" 8 #include "base/process_util.h"
9 #include "media/base/filter_host.h" 9 #include "media/base/filter_host.h"
10 #include "net/base/data_url.h" 10 #include "net/base/data_url.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 // lock and running the destructor. 84 // lock and running the destructor.
85 scoped_refptr<SimpleDataSource> destruction_guard(this); 85 scoped_refptr<SimpleDataSource> destruction_guard(this);
86 { 86 {
87 base::AutoLock auto_lock(lock_); 87 base::AutoLock auto_lock(lock_);
88 DCHECK_EQ(state_, UNINITIALIZED); 88 DCHECK_EQ(state_, UNINITIALIZED);
89 DCHECK(callback); 89 DCHECK(callback);
90 state_ = INITIALIZING; 90 state_ = INITIALIZING;
91 initialize_callback_.reset(callback); 91 initialize_callback_.reset(callback);
92 92
93 // Validate the URL. 93 // Validate the URL.
94 SetURL(GURL(url)); 94 url_ = GURL(url);
95 if (!url_.is_valid() || !IsProtocolSupportedForMedia(url_)) { 95 if (!url_.is_valid() || !IsProtocolSupportedForMedia(url_)) {
96 DoneInitialization_Locked(false); 96 DoneInitialization_Locked(false);
97 return; 97 return;
98 } 98 }
99 99
100 // Post a task to the render thread to start loading the resource. 100 // Post a task to the render thread to start loading the resource.
101 render_loop_->PostTask(FROM_HERE, 101 render_loop_->PostTask(FROM_HERE,
102 NewRunnableMethod(this, &SimpleDataSource::StartTask)); 102 NewRunnableMethod(this, &SimpleDataSource::StartTask));
103 } 103 }
104 } 104 }
105 105
106 void SimpleDataSource::CancelInitialize() { 106 void SimpleDataSource::CancelInitialize() {
107 base::AutoLock auto_lock(lock_); 107 base::AutoLock auto_lock(lock_);
108 DCHECK(initialize_callback_.get()); 108 DCHECK(initialize_callback_.get());
109 state_ = STOPPED; 109 state_ = STOPPED;
110 initialize_callback_.reset(); 110 initialize_callback_.reset();
111 111
112 // Post a task to the render thread to cancel loading the resource. 112 // Post a task to the render thread to cancel loading the resource.
113 render_loop_->PostTask(FROM_HERE, 113 render_loop_->PostTask(FROM_HERE,
114 NewRunnableMethod(this, &SimpleDataSource::CancelTask)); 114 NewRunnableMethod(this, &SimpleDataSource::CancelTask));
115 } 115 }
116 116
117 const media::MediaFormat& SimpleDataSource::media_format() {
118 return media_format_;
119 }
120
121 void SimpleDataSource::Read(int64 position, 117 void SimpleDataSource::Read(int64 position,
122 size_t size, 118 size_t size,
123 uint8* data, 119 uint8* data,
124 ReadCallback* read_callback) { 120 ReadCallback* read_callback) {
125 DCHECK_GE(size_, 0); 121 DCHECK_GE(size_, 0);
126 if (position >= size_) { 122 if (position >= size_) {
127 read_callback->RunWithParams(Tuple1<size_t>(0)); 123 read_callback->RunWithParams(Tuple1<size_t>(0));
128 delete read_callback; 124 delete read_callback;
129 } else { 125 } else {
130 size_t copied = std::min(size, static_cast<size_t>(size_ - position)); 126 size_t copied = std::min(size, static_cast<size_t>(size_ - position));
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 bool SimpleDataSource::HasSingleOrigin() { 255 bool SimpleDataSource::HasSingleOrigin() {
260 DCHECK(MessageLoop::current() == render_loop_); 256 DCHECK(MessageLoop::current() == render_loop_);
261 return single_origin_; 257 return single_origin_;
262 } 258 }
263 259
264 void SimpleDataSource::Abort() { 260 void SimpleDataSource::Abort() {
265 DCHECK(MessageLoop::current() == render_loop_); 261 DCHECK(MessageLoop::current() == render_loop_);
266 frame_ = NULL; 262 frame_ = NULL;
267 } 263 }
268 264
269 void SimpleDataSource::SetURL(const GURL& url) {
270 url_ = url;
271 media_format_.Clear();
272 media_format_.SetAsString(media::MediaFormat::kURL, url.spec());
273 }
274
275 void SimpleDataSource::StartTask() { 265 void SimpleDataSource::StartTask() {
276 DCHECK(MessageLoop::current() == render_loop_); 266 DCHECK(MessageLoop::current() == render_loop_);
277 // Reference to prevent destruction while inside the |initialize_callback_| 267 // Reference to prevent destruction while inside the |initialize_callback_|
278 // call. This is a temporary fix to prevent crashes caused by holding the 268 // call. This is a temporary fix to prevent crashes caused by holding the
279 // lock and running the destructor. 269 // lock and running the destructor.
280 scoped_refptr<SimpleDataSource> destruction_guard(this); 270 scoped_refptr<SimpleDataSource> destruction_guard(this);
281 { 271 {
282 base::AutoLock auto_lock(lock_); 272 base::AutoLock auto_lock(lock_);
283 273
284 // We may have stopped. 274 // We may have stopped.
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 void SimpleDataSource::UpdateHostState() { 342 void SimpleDataSource::UpdateHostState() {
353 if (host()) { 343 if (host()) {
354 host()->SetTotalBytes(size_); 344 host()->SetTotalBytes(size_);
355 host()->SetBufferedBytes(size_); 345 host()->SetBufferedBytes(size_);
356 // If scheme is file or data, say we are loaded. 346 // If scheme is file or data, say we are loaded.
357 host()->SetLoaded(url_.SchemeIsFile() || url_.SchemeIs(kDataScheme)); 347 host()->SetLoaded(url_.SchemeIsFile() || url_.SchemeIs(kDataScheme));
358 } 348 }
359 } 349 }
360 350
361 } // namespace webkit_glue 351 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « webkit/glue/media/simple_data_source.h ('k') | webkit/glue/webmediaplayer_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698