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

Side by Side Diff: media/video/capture/video_capture_proxy.cc

Issue 66183002: Replace MessageLoopProxy with SingleThreadTaskRunner for the rest of media/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix win and audio tests Created 6 years, 11 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/video/capture/video_capture_proxy.h ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/video/capture/video_capture_proxy.h" 5 #include "media/video/capture/video_capture_proxy.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/single_thread_task_runner.h"
10 #include "media/base/video_frame.h" 10 #include "media/base/video_frame.h"
11 11
12 namespace { 12 namespace {
13 13
14 // Called on VC thread: extracts the state out of the VideoCapture, and 14 // Called on VC thread: extracts the state out of the VideoCapture, and
15 // serialize it into a VideoCaptureState. 15 // serialize it into a VideoCaptureState.
16 media::VideoCaptureHandlerProxy::VideoCaptureState GetState( 16 media::VideoCaptureHandlerProxy::VideoCaptureState GetState(
17 media::VideoCapture* capture) { 17 media::VideoCapture* capture) {
18 media::VideoCaptureHandlerProxy::VideoCaptureState state; 18 media::VideoCaptureHandlerProxy::VideoCaptureState state;
19 state.started = capture->CaptureStarted(); 19 state.started = capture->CaptureStarted();
20 state.frame_rate = capture->CaptureFrameRate(); 20 state.frame_rate = capture->CaptureFrameRate();
21 return state; 21 return state;
22 } 22 }
23 23
24 } // anonymous namespace 24 } // anonymous namespace
25 25
26 namespace media { 26 namespace media {
27 27
28 VideoCaptureHandlerProxy::VideoCaptureHandlerProxy( 28 VideoCaptureHandlerProxy::VideoCaptureHandlerProxy(
29 VideoCapture::EventHandler* proxied, 29 VideoCapture::EventHandler* proxied,
30 scoped_refptr<base::MessageLoopProxy> main_message_loop) 30 const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner)
31 : proxied_(proxied), 31 : proxied_(proxied),
32 main_message_loop_(main_message_loop) { 32 main_task_runner_(main_task_runner) {
33 } 33 }
34 34
35 VideoCaptureHandlerProxy::~VideoCaptureHandlerProxy() { 35 VideoCaptureHandlerProxy::~VideoCaptureHandlerProxy() {
36 } 36 }
37 37
38 void VideoCaptureHandlerProxy::OnStarted(VideoCapture* capture) { 38 void VideoCaptureHandlerProxy::OnStarted(VideoCapture* capture) {
39 main_message_loop_->PostTask(FROM_HERE, base::Bind( 39 main_task_runner_->PostTask(FROM_HERE, base::Bind(
40 &VideoCaptureHandlerProxy::OnStartedOnMainThread, 40 &VideoCaptureHandlerProxy::OnStartedOnMainThread,
41 base::Unretained(this), 41 base::Unretained(this),
42 capture, 42 capture,
43 GetState(capture))); 43 GetState(capture)));
44 } 44 }
45 45
46 void VideoCaptureHandlerProxy::OnStopped(VideoCapture* capture) { 46 void VideoCaptureHandlerProxy::OnStopped(VideoCapture* capture) {
47 main_message_loop_->PostTask(FROM_HERE, base::Bind( 47 main_task_runner_->PostTask(FROM_HERE, base::Bind(
48 &VideoCaptureHandlerProxy::OnStoppedOnMainThread, 48 &VideoCaptureHandlerProxy::OnStoppedOnMainThread,
49 base::Unretained(this), 49 base::Unretained(this),
50 capture, 50 capture,
51 GetState(capture))); 51 GetState(capture)));
52 } 52 }
53 53
54 void VideoCaptureHandlerProxy::OnPaused(VideoCapture* capture) { 54 void VideoCaptureHandlerProxy::OnPaused(VideoCapture* capture) {
55 main_message_loop_->PostTask(FROM_HERE, base::Bind( 55 main_task_runner_->PostTask(FROM_HERE, base::Bind(
56 &VideoCaptureHandlerProxy::OnPausedOnMainThread, 56 &VideoCaptureHandlerProxy::OnPausedOnMainThread,
57 base::Unretained(this), 57 base::Unretained(this),
58 capture, 58 capture,
59 GetState(capture))); 59 GetState(capture)));
60 } 60 }
61 61
62 void VideoCaptureHandlerProxy::OnError(VideoCapture* capture, int error_code) { 62 void VideoCaptureHandlerProxy::OnError(VideoCapture* capture, int error_code) {
63 main_message_loop_->PostTask(FROM_HERE, base::Bind( 63 main_task_runner_->PostTask(FROM_HERE, base::Bind(
64 &VideoCaptureHandlerProxy::OnErrorOnMainThread, 64 &VideoCaptureHandlerProxy::OnErrorOnMainThread,
65 base::Unretained(this), 65 base::Unretained(this),
66 capture, 66 capture,
67 GetState(capture), 67 GetState(capture),
68 error_code)); 68 error_code));
69 } 69 }
70 70
71 void VideoCaptureHandlerProxy::OnRemoved(VideoCapture* capture) { 71 void VideoCaptureHandlerProxy::OnRemoved(VideoCapture* capture) {
72 main_message_loop_->PostTask(FROM_HERE, base::Bind( 72 main_task_runner_->PostTask(FROM_HERE, base::Bind(
73 &VideoCaptureHandlerProxy::OnRemovedOnMainThread, 73 &VideoCaptureHandlerProxy::OnRemovedOnMainThread,
74 base::Unretained(this), 74 base::Unretained(this),
75 capture, 75 capture,
76 GetState(capture))); 76 GetState(capture)));
77 } 77 }
78 78
79 void VideoCaptureHandlerProxy::OnFrameReady( 79 void VideoCaptureHandlerProxy::OnFrameReady(
80 VideoCapture* capture, 80 VideoCapture* capture,
81 const scoped_refptr<VideoFrame>& frame) { 81 const scoped_refptr<VideoFrame>& frame) {
82 main_message_loop_->PostTask( 82 main_task_runner_->PostTask(
83 FROM_HERE, 83 FROM_HERE,
84 base::Bind(&VideoCaptureHandlerProxy::OnFrameReadyOnMainThread, 84 base::Bind(&VideoCaptureHandlerProxy::OnFrameReadyOnMainThread,
85 base::Unretained(this), 85 base::Unretained(this),
86 capture, 86 capture,
87 GetState(capture), 87 GetState(capture),
88 frame)); 88 frame));
89 } 89 }
90 90
91 void VideoCaptureHandlerProxy::OnStartedOnMainThread( 91 void VideoCaptureHandlerProxy::OnStartedOnMainThread(
92 VideoCapture* capture, 92 VideoCapture* capture,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 126
127 void VideoCaptureHandlerProxy::OnFrameReadyOnMainThread( 127 void VideoCaptureHandlerProxy::OnFrameReadyOnMainThread(
128 VideoCapture* capture, 128 VideoCapture* capture,
129 const VideoCaptureState& state, 129 const VideoCaptureState& state,
130 const scoped_refptr<VideoFrame>& frame) { 130 const scoped_refptr<VideoFrame>& frame) {
131 state_ = state; 131 state_ = state;
132 proxied_->OnFrameReady(capture, frame); 132 proxied_->OnFrameReady(capture, frame);
133 } 133 }
134 134
135 } // namespace media 135 } // namespace media
OLDNEW
« no previous file with comments | « media/video/capture/video_capture_proxy.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698