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

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

Issue 2273273002: Directly call ChunkDemuxer::Initialize completion callback. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: public mock method Created 4 years, 3 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
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/chunk_demuxer.h" 5 #include "media/filters/chunk_demuxer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <list> 9 #include <list>
10 #include <utility> 10 #include <utility>
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 detected_video_track_count_(0), 418 detected_video_track_count_(0),
419 detected_text_track_count_(0) { 419 detected_text_track_count_(0) {
420 DCHECK(!open_cb_.is_null()); 420 DCHECK(!open_cb_.is_null());
421 DCHECK(!encrypted_media_init_data_cb_.is_null()); 421 DCHECK(!encrypted_media_init_data_cb_.is_null());
422 } 422 }
423 423
424 std::string ChunkDemuxer::GetDisplayName() const { 424 std::string ChunkDemuxer::GetDisplayName() const {
425 return "ChunkDemuxer"; 425 return "ChunkDemuxer";
426 } 426 }
427 427
428 void ChunkDemuxer::Initialize( 428 void ChunkDemuxer::Initialize(DemuxerHost* host,
429 DemuxerHost* host, 429 const PipelineStatusCB& init_cb,
430 const PipelineStatusCB& cb, 430 bool enable_text_tracks) {
431 bool enable_text_tracks) {
432 DVLOG(1) << "Init()"; 431 DVLOG(1) << "Init()";
433 432
434 base::AutoLock auto_lock(lock_); 433 base::AutoLock auto_lock(lock_);
435
436 // The |init_cb_| must only be run after this method returns, so always post.
437 init_cb_ = BindToCurrentLoop(cb);
438 if (state_ == SHUTDOWN) { 434 if (state_ == SHUTDOWN) {
439 base::ResetAndReturn(&init_cb_).Run(DEMUXER_ERROR_COULD_NOT_OPEN); 435 // Init cb must only be run after this method returns, so always post.
wolenetz 2016/09/23 00:11:46 nit: s/always//
alokp 2016/09/28 17:22:45 Done.
436 base::ThreadTaskRunnerHandle::Get()->PostTask(
437 FROM_HERE, base::Bind(init_cb, DEMUXER_ERROR_COULD_NOT_OPEN));
440 return; 438 return;
441 } 439 }
440
442 DCHECK_EQ(state_, WAITING_FOR_INIT); 441 DCHECK_EQ(state_, WAITING_FOR_INIT);
443 host_ = host; 442 host_ = host;
443 // Do not post init_cb once this function returns because if there is an
444 // error after initialization, the error might be reported before init_cb
445 // has a chance to run. This is because ChunkDemuxer::ReportError_Locked
446 // directly calls DemuxerHost::OnDemuxerError: crbug.com/633016.
447 init_cb_ = init_cb;
444 enable_text_ = enable_text_tracks; 448 enable_text_ = enable_text_tracks;
445 449
446 ChangeState_Locked(INITIALIZING); 450 ChangeState_Locked(INITIALIZING);
447 451
448 base::ResetAndReturn(&open_cb_).Run(); 452 base::ResetAndReturn(&open_cb_).Run();
449 } 453 }
450 454
451 void ChunkDemuxer::Stop() { 455 void ChunkDemuxer::Stop() {
452 DVLOG(1) << "Stop()"; 456 DVLOG(1) << "Stop()";
453 Shutdown(); 457 Shutdown();
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
1023 1027
1024 ShutdownAllStreams(); 1028 ShutdownAllStreams();
1025 } 1029 }
1026 1030
1027 if (!cb.is_null()) { 1031 if (!cb.is_null()) {
1028 cb.Run(error); 1032 cb.Run(error);
1029 return; 1033 return;
1030 } 1034 }
1031 1035
1032 base::AutoUnlock auto_unlock(lock_); 1036 base::AutoUnlock auto_unlock(lock_);
1033 host_->OnDemuxerError(error); 1037 host_->OnDemuxerError(error);
wolenetz 2016/09/23 00:11:46 Doesn't the host trampoline this back to the media
wolenetz 2016/09/27 21:01:14 Ignore (see my previous reply on the CL message th
alokp 2016/09/28 17:22:45 Acknowledged.
1034 } 1038 }
1035 1039
1036 bool ChunkDemuxer::IsSeekWaitingForData_Locked() const { 1040 bool ChunkDemuxer::IsSeekWaitingForData_Locked() const {
1037 lock_.AssertAcquired(); 1041 lock_.AssertAcquired();
1038 for (MediaSourceStateMap::const_iterator itr = source_state_map_.begin(); 1042 for (MediaSourceStateMap::const_iterator itr = source_state_map_.begin();
1039 itr != source_state_map_.end(); ++itr) { 1043 itr != source_state_map_.end(); ++itr) {
1040 if (itr->second->IsSeekWaitingForData()) 1044 if (itr->second->IsSeekWaitingForData())
1041 return true; 1045 return true;
1042 } 1046 }
1043 1047
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1272 } 1276 }
1273 1277
1274 void ChunkDemuxer::ShutdownAllStreams() { 1278 void ChunkDemuxer::ShutdownAllStreams() {
1275 for (MediaSourceStateMap::iterator itr = source_state_map_.begin(); 1279 for (MediaSourceStateMap::iterator itr = source_state_map_.begin();
1276 itr != source_state_map_.end(); ++itr) { 1280 itr != source_state_map_.end(); ++itr) {
1277 itr->second->Shutdown(); 1281 itr->second->Shutdown();
1278 } 1282 }
1279 } 1283 }
1280 1284
1281 } // namespace media 1285 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698