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

Unified Diff: media/base/pipeline.cc

Issue 444333007: Pipeline: Invalidate weak pointers before returning stop callback. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add HasWeakPtrsForTesting Created 6 years, 4 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/pipeline.h ('k') | media/base/pipeline_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/pipeline.cc
diff --git a/media/base/pipeline.cc b/media/base/pipeline.cc
index c1446828394c60a725fc2c33700d2270e7a5e05f..bc55981f6cfbdbaf96e29f2d1c50da616d6b624a 100644
--- a/media/base/pipeline.cc
+++ b/media/base/pipeline.cc
@@ -200,6 +200,11 @@ void Pipeline::SetErrorForTesting(PipelineStatus status) {
OnError(status);
}
+bool Pipeline::HasWeakPtrsForTesting() const {
+ DCHECK(task_runner_->BelongsToCurrentThread());
+ return weak_factory_.HasWeakPtrs();
+}
+
void Pipeline::SetState(State next_state) {
DVLOG(1) << GetStateString(state_) << " -> " << GetStateString(next_state);
@@ -602,7 +607,14 @@ void Pipeline::StopTask(const base::Closure& stop_cb) {
DCHECK(stop_cb_.is_null());
if (state_ == kStopped) {
+ // Invalid all weak pointers so it's safe to destroy |this| on the render
+ // main thread.
+ weak_factory_.InvalidateWeakPtrs();
+
+ // NOTE: pipeline may be deleted at this point in time as a result of
+ // executing |stop_cb|.
stop_cb.Run();
+
return;
}
« no previous file with comments | « media/base/pipeline.h ('k') | media/base/pipeline_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698