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

Side by Side 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: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "media/base/pipeline.h" 5 #include "media/base/pipeline.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 } 595 }
596 596
597 StateTransitionTask(PIPELINE_OK); 597 StateTransitionTask(PIPELINE_OK);
598 } 598 }
599 599
600 void Pipeline::StopTask(const base::Closure& stop_cb) { 600 void Pipeline::StopTask(const base::Closure& stop_cb) {
601 DCHECK(task_runner_->BelongsToCurrentThread()); 601 DCHECK(task_runner_->BelongsToCurrentThread());
602 DCHECK(stop_cb_.is_null()); 602 DCHECK(stop_cb_.is_null());
603 603
604 if (state_ == kStopped) { 604 if (state_ == kStopped) {
605 // Invalid all weak pointers so it's safe to destroy |this| on the render
606 // main thread.
607 weak_factory_.InvalidateWeakPtrs();
608
609 // NOTE: pipeline may be deleted at this point in time as a result of
610 // executing |stop_cb|.
605 stop_cb.Run(); 611 stop_cb.Run();
612
606 return; 613 return;
607 } 614 }
608 615
609 stop_cb_ = stop_cb; 616 stop_cb_ = stop_cb;
610 617
611 // We may already be stopping due to a runtime error. 618 // We may already be stopping due to a runtime error.
612 if (state_ == kStopping) 619 if (state_ == kStopping)
613 return; 620 return;
614 621
615 SetState(kStopping); 622 SetState(kStopping);
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() { 918 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() {
912 lock_.AssertAcquired(); 919 lock_.AssertAcquired();
913 if (interpolation_state_ != INTERPOLATION_WAITING_FOR_AUDIO_TIME_UPDATE) 920 if (interpolation_state_ != INTERPOLATION_WAITING_FOR_AUDIO_TIME_UPDATE)
914 return; 921 return;
915 922
916 interpolation_state_ = INTERPOLATION_STARTED; 923 interpolation_state_ = INTERPOLATION_STARTED;
917 interpolator_->StartInterpolating(); 924 interpolator_->StartInterpolating();
918 } 925 }
919 926
920 } // namespace media 927 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698