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

Side by Side Diff: media/filters/ffmpeg_demuxer.cc

Issue 2084643003: Invalidate FFmpegDemuxer WeakPtrs on the right thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/filters/ffmpeg_demuxer.h" 5 #include "media/filters/ffmpeg_demuxer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 768 matching lines...) Expand 10 before | Expand all | Expand 10 after
779 text_enabled_(false), 779 text_enabled_(false),
780 duration_known_(false), 780 duration_known_(false),
781 encrypted_media_init_data_cb_(encrypted_media_init_data_cb), 781 encrypted_media_init_data_cb_(encrypted_media_init_data_cb),
782 media_tracks_updated_cb_(media_tracks_updated_cb), 782 media_tracks_updated_cb_(media_tracks_updated_cb),
783 weak_factory_(this) { 783 weak_factory_(this) {
784 DCHECK(task_runner_.get()); 784 DCHECK(task_runner_.get());
785 DCHECK(data_source_); 785 DCHECK(data_source_);
786 DCHECK(!media_tracks_updated_cb_.is_null()); 786 DCHECK(!media_tracks_updated_cb_.is_null());
787 } 787 }
788 788
789 FFmpegDemuxer::~FFmpegDemuxer() {} 789 FFmpegDemuxer::~FFmpegDemuxer() {
790 // NOTE: This class is not destroyed on |task_runner|, so we must ensure that
791 // there are no outstanding WeakPtrs by the time we reach here.
792 DCHECK(!weak_factory_.HasWeakPtrs());
793 }
790 794
791 std::string FFmpegDemuxer::GetDisplayName() const { 795 std::string FFmpegDemuxer::GetDisplayName() const {
792 return "FFmpegDemuxer"; 796 return "FFmpegDemuxer";
793 } 797 }
794 798
795 void FFmpegDemuxer::Initialize(DemuxerHost* host, 799 void FFmpegDemuxer::Initialize(DemuxerHost* host,
796 const PipelineStatusCB& status_cb, 800 const PipelineStatusCB& status_cb,
797 bool enable_text_tracks) { 801 bool enable_text_tracks) {
798 DCHECK(task_runner_->BelongsToCurrentThread()); 802 DCHECK(task_runner_->BelongsToCurrentThread());
799 host_ = host; 803 host_ = host;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 // thread and drop their results on the floor. 845 // thread and drop their results on the floor.
842 blocking_thread_.Stop(); 846 blocking_thread_.Stop();
843 847
844 StreamVector::iterator iter; 848 StreamVector::iterator iter;
845 for (iter = streams_.begin(); iter != streams_.end(); ++iter) { 849 for (iter = streams_.begin(); iter != streams_.end(); ++iter) {
846 if (*iter) 850 if (*iter)
847 (*iter)->Stop(); 851 (*iter)->Stop();
848 } 852 }
849 853
850 data_source_ = NULL; 854 data_source_ = NULL;
855
856 // Invalidate WeakPtrs on |task_runner_|, destruction may happen on another
857 // thread.
858 weak_factory_.InvalidateWeakPtrs();
851 } 859 }
852 860
853 void FFmpegDemuxer::StartWaitingForSeek(base::TimeDelta seek_time) {} 861 void FFmpegDemuxer::StartWaitingForSeek(base::TimeDelta seek_time) {}
854 862
855 void FFmpegDemuxer::CancelPendingSeek(base::TimeDelta seek_time) {} 863 void FFmpegDemuxer::CancelPendingSeek(base::TimeDelta seek_time) {}
856 864
857 void FFmpegDemuxer::Seek(base::TimeDelta time, const PipelineStatusCB& cb) { 865 void FFmpegDemuxer::Seek(base::TimeDelta time, const PipelineStatusCB& cb) {
858 DCHECK(task_runner_->BelongsToCurrentThread()); 866 DCHECK(task_runner_->BelongsToCurrentThread());
859 CHECK(!pending_seek_); 867 CHECK(!pending_seek_);
860 868
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
1596 1604
1597 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) { 1605 void FFmpegDemuxer::SetLiveness(DemuxerStream::Liveness liveness) {
1598 DCHECK(task_runner_->BelongsToCurrentThread()); 1606 DCHECK(task_runner_->BelongsToCurrentThread());
1599 for (const auto& stream : streams_) { // |stream| is a ref to a pointer. 1607 for (const auto& stream : streams_) { // |stream| is a ref to a pointer.
1600 if (stream) 1608 if (stream)
1601 stream->SetLiveness(liveness); 1609 stream->SetLiveness(liveness);
1602 } 1610 }
1603 } 1611 }
1604 1612
1605 } // namespace media 1613 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698