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

Unified Diff: media/base/text_renderer.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 | « media/base/text_renderer.h ('k') | media/base/user_input_monitor_linux.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/text_renderer.cc
diff --git a/media/base/text_renderer.cc b/media/base/text_renderer.cc
index 45f61b45a761f1eb7dbe8341b1dd517b76f4853f..6f88ef71a697f64617e7dc87f47699fc0dcb24b2 100644
--- a/media/base/text_renderer.cc
+++ b/media/base/text_renderer.cc
@@ -21,11 +21,10 @@ TextRenderer::TextRenderer(
const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
const AddTextTrackCB& add_text_track_cb)
: task_runner_(task_runner),
- weak_factory_(this),
add_text_track_cb_(add_text_track_cb),
state_(kUninitialized),
- pending_read_count_(0) {
-}
+ pending_read_count_(0),
+ weak_factory_(this) {}
TextRenderer::~TextRenderer() {
DCHECK(state_ == kUninitialized ||
@@ -43,7 +42,6 @@ void TextRenderer::Initialize(const base::Closure& ended_cb) {
DCHECK(pending_eos_set_.empty());
DCHECK(ended_cb_.is_null());
- weak_this_ = weak_factory_.GetWeakPtr();
ended_cb_ = ended_cb;
state_ = kPaused;
}
@@ -127,8 +125,10 @@ void TextRenderer::AddTextStream(DemuxerStream* text_stream,
DCHECK(pending_eos_set_.find(text_stream) ==
pending_eos_set_.end());
- AddTextTrackDoneCB done_cb = BindToCurrentLoop(
- base::Bind(&TextRenderer::OnAddTextTrackDone, weak_this_, text_stream));
+ AddTextTrackDoneCB done_cb =
+ BindToCurrentLoop(base::Bind(&TextRenderer::OnAddTextTrackDone,
+ weak_factory_.GetWeakPtr(),
+ text_stream));
add_text_track_cb_.Run(config, done_cb);
}
@@ -354,9 +354,8 @@ void TextRenderer::Read(
state->read_state = TextTrackState::kReadPending;
++pending_read_count_;
- text_stream->Read(base::Bind(&TextRenderer::BufferReady,
- weak_this_,
- text_stream));
+ text_stream->Read(base::Bind(
+ &TextRenderer::BufferReady, weak_factory_.GetWeakPtr(), text_stream));
}
TextRenderer::TextTrackState::TextTrackState(scoped_ptr<TextTrack> tt)
« no previous file with comments | « media/base/text_renderer.h ('k') | media/base/user_input_monitor_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698