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

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: Created 7 years, 1 month 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
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 10
11 namespace { 11 namespace {
12 12
13 // Called on VC thread: extracts the state out of the VideoCapture, and 13 // Called on VC thread: extracts the state out of the VideoCapture, and
14 // serialize it into a VideoCaptureState. 14 // serialize it into a VideoCaptureState.
15 media::VideoCaptureHandlerProxy::VideoCaptureState GetState( 15 media::VideoCaptureHandlerProxy::VideoCaptureState GetState(
16 media::VideoCapture* capture) { 16 media::VideoCapture* capture) {
17 media::VideoCaptureHandlerProxy::VideoCaptureState state; 17 media::VideoCaptureHandlerProxy::VideoCaptureState state;
18 state.started = capture->CaptureStarted(); 18 state.started = capture->CaptureStarted();
19 state.frame_rate = capture->CaptureFrameRate(); 19 state.frame_rate = capture->CaptureFrameRate();
20 return state; 20 return state;
21 } 21 }
22 22
23 } // anonymous namespace 23 } // anonymous namespace
24 24
25 namespace media { 25 namespace media {
26 26
27 VideoCaptureHandlerProxy::VideoCaptureHandlerProxy( 27 VideoCaptureHandlerProxy::VideoCaptureHandlerProxy(
28 VideoCapture::EventHandler* proxied, 28 VideoCapture::EventHandler* proxied,
29 scoped_refptr<base::MessageLoopProxy> main_message_loop) 29 const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner)
30 : proxied_(proxied), 30 : proxied_(proxied),
31 main_message_loop_(main_message_loop) { 31 main_task_runner_(main_task_runner) {
32 } 32 }
33 33
34 VideoCaptureHandlerProxy::~VideoCaptureHandlerProxy() { 34 VideoCaptureHandlerProxy::~VideoCaptureHandlerProxy() {
35 } 35 }
36 36
37 void VideoCaptureHandlerProxy::OnStarted(VideoCapture* capture) { 37 void VideoCaptureHandlerProxy::OnStarted(VideoCapture* capture) {
38 main_message_loop_->PostTask(FROM_HERE, base::Bind( 38 main_task_runner_->PostTask(FROM_HERE, base::Bind(
39 &VideoCaptureHandlerProxy::OnStartedOnMainThread, 39 &VideoCaptureHandlerProxy::OnStartedOnMainThread,
40 base::Unretained(this), 40 base::Unretained(this),
41 capture, 41 capture,
42 GetState(capture))); 42 GetState(capture)));
43 } 43 }
44 44
45 void VideoCaptureHandlerProxy::OnStopped(VideoCapture* capture) { 45 void VideoCaptureHandlerProxy::OnStopped(VideoCapture* capture) {
46 main_message_loop_->PostTask(FROM_HERE, base::Bind( 46 main_task_runner_->PostTask(FROM_HERE, base::Bind(
47 &VideoCaptureHandlerProxy::OnStoppedOnMainThread, 47 &VideoCaptureHandlerProxy::OnStoppedOnMainThread,
48 base::Unretained(this), 48 base::Unretained(this),
49 capture, 49 capture,
50 GetState(capture))); 50 GetState(capture)));
51 } 51 }
52 52
53 void VideoCaptureHandlerProxy::OnPaused(VideoCapture* capture) { 53 void VideoCaptureHandlerProxy::OnPaused(VideoCapture* capture) {
54 main_message_loop_->PostTask(FROM_HERE, base::Bind( 54 main_task_runner_->PostTask(FROM_HERE, base::Bind(
55 &VideoCaptureHandlerProxy::OnPausedOnMainThread, 55 &VideoCaptureHandlerProxy::OnPausedOnMainThread,
56 base::Unretained(this), 56 base::Unretained(this),
57 capture, 57 capture,
58 GetState(capture))); 58 GetState(capture)));
59 } 59 }
60 60
61 void VideoCaptureHandlerProxy::OnError(VideoCapture* capture, int error_code) { 61 void VideoCaptureHandlerProxy::OnError(VideoCapture* capture, int error_code) {
62 main_message_loop_->PostTask(FROM_HERE, base::Bind( 62 main_task_runner_->PostTask(FROM_HERE, base::Bind(
63 &VideoCaptureHandlerProxy::OnErrorOnMainThread, 63 &VideoCaptureHandlerProxy::OnErrorOnMainThread,
64 base::Unretained(this), 64 base::Unretained(this),
65 capture, 65 capture,
66 GetState(capture), 66 GetState(capture),
67 error_code)); 67 error_code));
68 } 68 }
69 69
70 void VideoCaptureHandlerProxy::OnRemoved(VideoCapture* capture) { 70 void VideoCaptureHandlerProxy::OnRemoved(VideoCapture* capture) {
71 main_message_loop_->PostTask(FROM_HERE, base::Bind( 71 main_task_runner_->PostTask(FROM_HERE, base::Bind(
72 &VideoCaptureHandlerProxy::OnRemovedOnMainThread, 72 &VideoCaptureHandlerProxy::OnRemovedOnMainThread,
73 base::Unretained(this), 73 base::Unretained(this),
74 capture, 74 capture,
75 GetState(capture))); 75 GetState(capture)));
76 } 76 }
77 77
78 void VideoCaptureHandlerProxy::OnFrameReady( 78 void VideoCaptureHandlerProxy::OnFrameReady(
79 VideoCapture* capture, 79 VideoCapture* capture,
80 const scoped_refptr<VideoFrame>& frame) { 80 const scoped_refptr<VideoFrame>& frame) {
81 main_message_loop_->PostTask( 81 main_task_runner_->PostTask(
82 FROM_HERE, 82 FROM_HERE,
83 base::Bind(&VideoCaptureHandlerProxy::OnFrameReadyOnMainThread, 83 base::Bind(&VideoCaptureHandlerProxy::OnFrameReadyOnMainThread,
84 base::Unretained(this), 84 base::Unretained(this),
85 capture, 85 capture,
86 GetState(capture), 86 GetState(capture),
87 frame)); 87 frame));
88 } 88 }
89 89
90 void VideoCaptureHandlerProxy::OnStartedOnMainThread( 90 void VideoCaptureHandlerProxy::OnStartedOnMainThread(
91 VideoCapture* capture, 91 VideoCapture* capture,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 125
126 void VideoCaptureHandlerProxy::OnFrameReadyOnMainThread( 126 void VideoCaptureHandlerProxy::OnFrameReadyOnMainThread(
127 VideoCapture* capture, 127 VideoCapture* capture,
128 const VideoCaptureState& state, 128 const VideoCaptureState& state,
129 const scoped_refptr<VideoFrame>& frame) { 129 const scoped_refptr<VideoFrame>& frame) {
130 state_ = state; 130 state_ = state;
131 proxied_->OnFrameReady(capture, frame); 131 proxied_->OnFrameReady(capture, frame);
132 } 132 }
133 133
134 } // namespace media 134 } // namespace media
OLDNEW
« media/audio/scoped_task_runner_observer.h ('K') | « 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