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

Side by Side Diff: content/renderer/media/webmediaplayer_ms_unittest.cc

Issue 2082343002: Remove calls to deprecated MessageLoop methods in content. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR Created 4 years, 5 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "base/single_thread_task_runner.h"
8 #include "content/public/renderer/media_stream_renderer_factory.h" 9 #include "content/public/renderer/media_stream_renderer_factory.h"
9 #include "content/renderer/media/webmediaplayer_ms.h" 10 #include "content/renderer/media/webmediaplayer_ms.h"
10 #include "content/renderer/media/webmediaplayer_ms_compositor.h" 11 #include "content/renderer/media/webmediaplayer_ms_compositor.h"
11 #include "content/renderer/render_frame_impl.h" 12 #include "content/renderer/render_frame_impl.h"
12 #include "media/base/test_helpers.h" 13 #include "media/base/test_helpers.h"
13 #include "media/base/video_frame.h" 14 #include "media/base/video_frame.h"
14 #include "third_party/WebKit/public/platform/WebMediaPlayer.h" 15 #include "third_party/WebKit/public/platform/WebMediaPlayer.h"
15 #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h" 16 #include "third_party/WebKit/public/platform/WebMediaPlayerClient.h"
16 #include "third_party/WebKit/public/platform/WebMediaPlayerSource.h" 17 #include "third_party/WebKit/public/platform/WebMediaPlayerSource.h"
17 18
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 } 506 }
506 507
507 void WebMediaPlayerMSTest::StopUsingProvider() { 508 void WebMediaPlayerMSTest::StopUsingProvider() {
508 if (rendering_) 509 if (rendering_)
509 StopRendering(); 510 StopRendering();
510 } 511 }
511 512
512 void WebMediaPlayerMSTest::StartRendering() { 513 void WebMediaPlayerMSTest::StartRendering() {
513 if (!rendering_) { 514 if (!rendering_) {
514 rendering_ = true; 515 rendering_ = true;
515 message_loop_.PostTask( 516 message_loop_.task_runner()->PostTask(
516 FROM_HERE, 517 FROM_HERE,
517 base::Bind(&WebMediaPlayerMSTest::RenderFrame, base::Unretained(this))); 518 base::Bind(&WebMediaPlayerMSTest::RenderFrame, base::Unretained(this)));
518 } 519 }
519 DoStartRendering(); 520 DoStartRendering();
520 } 521 }
521 522
522 void WebMediaPlayerMSTest::StopRendering() { 523 void WebMediaPlayerMSTest::StopRendering() {
523 rendering_ = false; 524 rendering_ = false;
524 DoStopRendering(); 525 DoStopRendering();
525 } 526 }
526 527
527 void WebMediaPlayerMSTest::RenderFrame() { 528 void WebMediaPlayerMSTest::RenderFrame() {
528 if (!rendering_ || !compositor_) 529 if (!rendering_ || !compositor_)
529 return; 530 return;
530 531
531 base::TimeTicks now = base::TimeTicks::Now(); 532 base::TimeTicks now = base::TimeTicks::Now();
532 base::TimeTicks deadline_min = 533 base::TimeTicks deadline_min =
533 now + base::TimeDelta::FromSecondsD(1.0 / 60.0); 534 now + base::TimeDelta::FromSecondsD(1.0 / 60.0);
534 base::TimeTicks deadline_max = 535 base::TimeTicks deadline_max =
535 deadline_min + base::TimeDelta::FromSecondsD(1.0 / 60.0); 536 deadline_min + base::TimeDelta::FromSecondsD(1.0 / 60.0);
536 537
537 // Background rendering is different from stop rendering. The rendering loop 538 // Background rendering is different from stop rendering. The rendering loop
538 // is still running but we do not ask frames from |compositor_|. And 539 // is still running but we do not ask frames from |compositor_|. And
539 // background rendering is not initiated from |compositor_|. 540 // background rendering is not initiated from |compositor_|.
540 if (!background_rendering_) { 541 if (!background_rendering_) {
541 compositor_->UpdateCurrentFrame(deadline_min, deadline_max); 542 compositor_->UpdateCurrentFrame(deadline_min, deadline_max);
542 auto frame = compositor_->GetCurrentFrame(); 543 auto frame = compositor_->GetCurrentFrame();
543 compositor_->PutCurrentFrame(); 544 compositor_->PutCurrentFrame();
544 } 545 }
545 message_loop_.PostDelayedTask( 546 message_loop_.task_runner()->PostDelayedTask(
546 FROM_HERE, 547 FROM_HERE,
547 base::Bind(&WebMediaPlayerMSTest::RenderFrame, base::Unretained(this)), 548 base::Bind(&WebMediaPlayerMSTest::RenderFrame, base::Unretained(this)),
548 base::TimeDelta::FromSecondsD(1.0 / 60.0)); 549 base::TimeDelta::FromSecondsD(1.0 / 60.0));
549 } 550 }
550 551
551 void WebMediaPlayerMSTest::sizeChanged() { 552 void WebMediaPlayerMSTest::sizeChanged() {
552 gfx::Size frame_size = compositor_->GetCurrentSize(); 553 gfx::Size frame_size = compositor_->GetCurrentSize();
553 CheckSizeChanged(frame_size); 554 CheckSizeChanged(frame_size);
554 } 555 }
555 556
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 // OnShown() should restart after a forced suspension. 833 // OnShown() should restart after a forced suspension.
833 player_->OnShown(); 834 player_->OnShown();
834 EXPECT_FALSE(player_->paused()); 835 EXPECT_FALSE(player_->paused());
835 EXPECT_CALL(*this, DoSetWebLayer(false)); 836 EXPECT_CALL(*this, DoSetWebLayer(false));
836 837
837 message_loop_.RunUntilIdle(); 838 message_loop_.RunUntilIdle();
838 } 839 }
839 #endif 840 #endif
840 841
841 } // namespace content 842 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/webmediaplayer_ms_compositor.cc ('k') | content/renderer/pepper/plugin_module.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698