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

Unified Diff: chrome/renderer/media/buffered_data_source.cc

Issue 155608: Adding callback support to media filter Initialize() and Seek(). (Closed)
Patch Set: Full patch Created 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/media/buffered_data_source.h ('k') | media/base/filter_host.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/media/buffered_data_source.cc
diff --git a/chrome/renderer/media/buffered_data_source.cc b/chrome/renderer/media/buffered_data_source.cc
index ef987a53005fe838f9654e994740dfea1c8f350b..edec5c1ff28a7040071c7a050340571a3d7442c9 100644
--- a/chrome/renderer/media/buffered_data_source.cc
+++ b/chrome/renderer/media/buffered_data_source.cc
@@ -532,14 +532,20 @@ void BufferedDataSource::Stop() {
resource_loader->Stop();
}
-bool BufferedDataSource::Initialize(const std::string& url) {
+void BufferedDataSource::Initialize(const std::string& url,
+ media::FilterCallback* callback) {
+ DCHECK(callback);
+ initialize_callback_.reset(callback);
+
// Save the url.
url_ = GURL(url);
// Make sure we support the scheme of the URL.
if (!IsSchemeSupported(url_)) {
host()->Error(media::PIPELINE_ERROR_NETWORK);
- return false;
+ initialize_callback_->Run();
+ initialize_callback_.reset();
+ return;
}
media_format_.SetAsString(media::MediaFormat::kMimeType,
@@ -562,16 +568,19 @@ bool BufferedDataSource::Initialize(const std::string& url) {
}
// Use the local reference to start the request.
- if (resource_loader) {
- if (net::ERR_IO_PENDING != resource_loader->Start(
- NewCallback(this, &BufferedDataSource::InitialRequestStarted))) {
- host()->Error(media::PIPELINE_ERROR_NETWORK);
- return false;
- }
- return true;
+ if (!resource_loader) {
+ host()->Error(media::PIPELINE_ERROR_NETWORK);
+ initialize_callback_->Run();
+ initialize_callback_.reset();
+ return;
+ }
+
+ if (net::ERR_IO_PENDING != resource_loader->Start(
+ NewCallback(this, &BufferedDataSource::InitialRequestStarted))) {
+ host()->Error(media::PIPELINE_ERROR_NETWORK);
+ initialize_callback_->Run();
+ initialize_callback_.reset();
}
- host()->Error(media::PIPELINE_ERROR_NETWORK);
- return false;
}
size_t BufferedDataSource::Read(uint8* data, size_t size) {
@@ -688,7 +697,7 @@ void BufferedDataSource::InitialRequestStarted(int error) {
}
void BufferedDataSource::OnInitialRequestStarted(int error) {
- // Acquiring a lock should not be needed because stopped_ is only written
+ // Acquiring a lock should not be needed because |stopped_| is only written
// on pipeline thread and we are on pipeline thread but just to be safe.
AutoLock auto_lock(lock_);
if (!stopped_) {
@@ -699,11 +708,12 @@ void BufferedDataSource::OnInitialRequestStarted(int error) {
// TODO(hclam): report the amount of bytes buffered accurately.
host()->SetBufferedBytes(total_bytes_);
}
- host()->InitializationComplete();
} else {
host()->Error(media::PIPELINE_ERROR_NETWORK);
}
}
+ initialize_callback_->Run();
+ initialize_callback_.reset();
}
const media::MediaFormat& BufferedDataSource::media_format() {
« no previous file with comments | « chrome/renderer/media/buffered_data_source.h ('k') | media/base/filter_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698