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

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

Issue 193303002: WeakPtr destruction order cleanup: media edition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase. Created 6 years, 9 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 | « content/renderer/media/buffered_data_source.h ('k') | content/renderer/media/cdm_session_adapter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/buffered_data_source.cc
diff --git a/content/renderer/media/buffered_data_source.cc b/content/renderer/media/buffered_data_source.cc
index 1992b706ad457222507b6ee84e1ffb6c8057bc34..f14bf493e57b4204e1c45a1b6605064b2e136565 100644
--- a/content/renderer/media/buffered_data_source.cc
+++ b/content/renderer/media/buffered_data_source.cc
@@ -99,7 +99,6 @@ BufferedDataSource::BufferedDataSource(
downloading_cb_(downloading_cb),
weak_factory_(this) {
DCHECK(!downloading_cb_.is_null());
- weak_this_ = weak_factory_.GetWeakPtr();
}
BufferedDataSource::~BufferedDataSource() {}
@@ -159,10 +158,11 @@ void BufferedDataSource::Initialize(
assume_fully_buffered_ = true;
}
+ base::WeakPtr<BufferedDataSource> weak_this = weak_factory_.GetWeakPtr();
loader_->Start(
- base::Bind(&BufferedDataSource::StartCallback, weak_this_),
- base::Bind(&BufferedDataSource::LoadingStateChangedCallback, weak_this_),
- base::Bind(&BufferedDataSource::ProgressCallback, weak_this_),
+ base::Bind(&BufferedDataSource::StartCallback, weak_this),
+ base::Bind(&BufferedDataSource::LoadingStateChangedCallback, weak_this),
+ base::Bind(&BufferedDataSource::ProgressCallback, weak_this),
frame_);
}
@@ -223,13 +223,16 @@ void BufferedDataSource::Stop(const base::Closure& closure) {
}
closure.Run();
- render_loop_->PostTask(FROM_HERE,
- base::Bind(&BufferedDataSource::StopLoader, weak_this_));
+ render_loop_->PostTask(
+ FROM_HERE,
+ base::Bind(&BufferedDataSource::StopLoader, weak_factory_.GetWeakPtr()));
}
void BufferedDataSource::SetBitrate(int bitrate) {
- render_loop_->PostTask(FROM_HERE, base::Bind(
- &BufferedDataSource::SetBitrateTask, weak_this_, bitrate));
+ render_loop_->PostTask(FROM_HERE,
+ base::Bind(&BufferedDataSource::SetBitrateTask,
+ weak_factory_.GetWeakPtr(),
+ bitrate));
}
void BufferedDataSource::Read(
@@ -250,8 +253,9 @@ void BufferedDataSource::Read(
read_op_.reset(new ReadOperation(position, size, data, read_cb));
}
- render_loop_->PostTask(FROM_HERE, base::Bind(
- &BufferedDataSource::ReadTask, weak_this_));
+ render_loop_->PostTask(
+ FROM_HERE,
+ base::Bind(&BufferedDataSource::ReadTask, weak_factory_.GetWeakPtr()));
}
bool BufferedDataSource::GetSize(int64* size_out) {
@@ -326,9 +330,11 @@ void BufferedDataSource::ReadInternal() {
}
// Perform the actual read with BufferedResourceLoader.
- loader_->Read(
- position, size, intermediate_read_buffer_.get(),
- base::Bind(&BufferedDataSource::ReadCallback, weak_this_));
+ loader_->Read(position,
+ size,
+ intermediate_read_buffer_.get(),
+ base::Bind(&BufferedDataSource::ReadCallback,
+ weak_factory_.GetWeakPtr()));
}
@@ -431,11 +437,13 @@ void BufferedDataSource::ReadCallback(
// end of the resource.
loader_.reset(CreateResourceLoader(
read_op_->position(), kPositionNotSpecified));
+
+ base::WeakPtr<BufferedDataSource> weak_this = weak_factory_.GetWeakPtr();
loader_->Start(
- base::Bind(&BufferedDataSource::PartialReadStartCallback, weak_this_),
+ base::Bind(&BufferedDataSource::PartialReadStartCallback, weak_this),
base::Bind(&BufferedDataSource::LoadingStateChangedCallback,
- weak_this_),
- base::Bind(&BufferedDataSource::ProgressCallback, weak_this_),
+ weak_this),
+ base::Bind(&BufferedDataSource::ProgressCallback, weak_this),
frame_);
return;
}
« no previous file with comments | « content/renderer/media/buffered_data_source.h ('k') | content/renderer/media/cdm_session_adapter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698