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

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: removes comment Created 4 years, 2 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 | « media/filters/chunk_demuxer.h ('k') | media/filters/chunk_demuxer_unittest.cc » ('j') | 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/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 <utility> 9 #include <utility>
10 10
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 detected_video_track_count_(0), 417 detected_video_track_count_(0),
418 detected_text_track_count_(0) { 418 detected_text_track_count_(0) {
419 DCHECK(!open_cb_.is_null()); 419 DCHECK(!open_cb_.is_null());
420 DCHECK(!encrypted_media_init_data_cb_.is_null()); 420 DCHECK(!encrypted_media_init_data_cb_.is_null());
421 } 421 }
422 422
423 std::string ChunkDemuxer::GetDisplayName() const { 423 std::string ChunkDemuxer::GetDisplayName() const {
424 return "ChunkDemuxer"; 424 return "ChunkDemuxer";
425 } 425 }
426 426
427 void ChunkDemuxer::Initialize( 427 void ChunkDemuxer::Initialize(DemuxerHost* host,
428 DemuxerHost* host, 428 const PipelineStatusCB& init_cb,
429 const PipelineStatusCB& cb, 429 bool enable_text_tracks) {
430 bool enable_text_tracks) {
431 DVLOG(1) << "Init()"; 430 DVLOG(1) << "Init()";
432 431
433 base::AutoLock auto_lock(lock_); 432 base::AutoLock auto_lock(lock_);
434
435 // The |init_cb_| must only be run after this method returns, so always post.
436 init_cb_ = BindToCurrentLoop(cb);
437 if (state_ == SHUTDOWN) { 433 if (state_ == SHUTDOWN) {
438 base::ResetAndReturn(&init_cb_).Run(DEMUXER_ERROR_COULD_NOT_OPEN); 434 // Init cb must only be run after this method returns, so post.
435 base::ThreadTaskRunnerHandle::Get()->PostTask(
436 FROM_HERE, base::Bind(init_cb, DEMUXER_ERROR_COULD_NOT_OPEN));
439 return; 437 return;
440 } 438 }
439
441 DCHECK_EQ(state_, WAITING_FOR_INIT); 440 DCHECK_EQ(state_, WAITING_FOR_INIT);
442 host_ = host; 441 host_ = host;
442 // Do not post init_cb once this function returns because if there is an
443 // error after initialization, the error might be reported before init_cb
444 // has a chance to run. This is because ChunkDemuxer::ReportError_Locked
445 // directly calls DemuxerHost::OnDemuxerError: crbug.com/633016.
446 init_cb_ = init_cb;
443 enable_text_ = enable_text_tracks; 447 enable_text_ = enable_text_tracks;
444 448
445 ChangeState_Locked(INITIALIZING); 449 ChangeState_Locked(INITIALIZING);
446 450
447 base::ResetAndReturn(&open_cb_).Run(); 451 base::ResetAndReturn(&open_cb_).Run();
448 } 452 }
449 453
450 void ChunkDemuxer::Stop() { 454 void ChunkDemuxer::Stop() {
451 DVLOG(1) << "Stop()"; 455 DVLOG(1) << "Stop()";
452 Shutdown(); 456 Shutdown();
(...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after
1309 } 1313 }
1310 1314
1311 void ChunkDemuxer::ShutdownAllStreams() { 1315 void ChunkDemuxer::ShutdownAllStreams() {
1312 for (auto itr = source_state_map_.begin(); itr != source_state_map_.end(); 1316 for (auto itr = source_state_map_.begin(); itr != source_state_map_.end();
1313 ++itr) { 1317 ++itr) {
1314 itr->second->Shutdown(); 1318 itr->second->Shutdown();
1315 } 1319 }
1316 } 1320 }
1317 1321
1318 } // namespace media 1322 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/chunk_demuxer.h ('k') | media/filters/chunk_demuxer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698