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

Side by Side Diff: media/base/pipeline_unittest.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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/base/pipeline.cc ('k') | 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 <vector> 5 #include <vector>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/test/simple_test_tick_clock.h" 10 #include "base/test/simple_test_tick_clock.h"
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 base::Bind(&CallbackHelper::OnSeek, 308 base::Bind(&CallbackHelper::OnSeek,
309 base::Unretained(&callbacks_))); 309 base::Unretained(&callbacks_)));
310 310
311 // We expect the time to be updated only after the seek has completed. 311 // We expect the time to be updated only after the seek has completed.
312 EXPECT_NE(seek_time, pipeline_->GetMediaTime()); 312 EXPECT_NE(seek_time, pipeline_->GetMediaTime());
313 message_loop_.RunUntilIdle(); 313 message_loop_.RunUntilIdle();
314 EXPECT_EQ(seek_time, pipeline_->GetMediaTime()); 314 EXPECT_EQ(seek_time, pipeline_->GetMediaTime());
315 } 315 }
316 316
317 void DestroyPipeline() { 317 void DestroyPipeline() {
318 // In real code Pipeline could be destroyed on a different thread. All weak
319 // pointers must have been invalidated before the stop callback returns.
320 DCHECK(!pipeline_->HasWeakPtrsForTesting());
318 pipeline_.reset(); 321 pipeline_.reset();
319 } 322 }
320 323
321 void ExpectDemuxerStop() { 324 void ExpectDemuxerStop() {
322 if (demuxer_) 325 if (demuxer_)
323 EXPECT_CALL(*demuxer_, Stop(_)).WillOnce(RunClosure<0>()); 326 EXPECT_CALL(*demuxer_, Stop(_)).WillOnce(RunClosure<0>());
324 } 327 }
325 328
326 void ExpectPipelineStopAndDestroyPipeline() { 329 void ExpectPipelineStopAndDestroyPipeline() {
327 // After the Pipeline is stopped, it could be destroyed any time. Always 330 // After the Pipeline is stopped, it could be destroyed any time. Always
(...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after
1244 INSTANTIATE_TEARDOWN_TEST(Error, InitDemuxer); 1247 INSTANTIATE_TEARDOWN_TEST(Error, InitDemuxer);
1245 INSTANTIATE_TEARDOWN_TEST(Error, InitAudioRenderer); 1248 INSTANTIATE_TEARDOWN_TEST(Error, InitAudioRenderer);
1246 INSTANTIATE_TEARDOWN_TEST(Error, InitVideoRenderer); 1249 INSTANTIATE_TEARDOWN_TEST(Error, InitVideoRenderer);
1247 INSTANTIATE_TEARDOWN_TEST(Error, Flushing); 1250 INSTANTIATE_TEARDOWN_TEST(Error, Flushing);
1248 INSTANTIATE_TEARDOWN_TEST(Error, Seeking); 1251 INSTANTIATE_TEARDOWN_TEST(Error, Seeking);
1249 INSTANTIATE_TEARDOWN_TEST(Error, Playing); 1252 INSTANTIATE_TEARDOWN_TEST(Error, Playing);
1250 1253
1251 INSTANTIATE_TEARDOWN_TEST(ErrorAndStop, Playing); 1254 INSTANTIATE_TEARDOWN_TEST(ErrorAndStop, Playing);
1252 1255
1253 } // namespace media 1256 } // namespace media
OLDNEW
« no previous file with comments | « media/base/pipeline.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698