Prevented race in auto enrollment check screen.
[chromium-blink-merge.git] / remoting / client / frame_consumer_proxy.cc
blobbf70da533b8354e4619243d49fba84aaec13ddd6
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
3 // found in the LICENSE file.
5 #include "remoting/client/frame_consumer_proxy.h"
7 #include "base/bind.h"
8 #include "base/location.h"
9 #include "base/single_thread_task_runner.h"
10 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
11 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
12 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h"
14 namespace remoting {
16 FrameConsumerProxy::FrameConsumerProxy(
17 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
18 const base::WeakPtr<FrameConsumer>& frame_consumer)
19 : frame_consumer_(frame_consumer),
20 task_runner_(task_runner) {
21 pixel_format_ = frame_consumer_->GetPixelFormat();
24 void FrameConsumerProxy::ApplyBuffer(const webrtc::DesktopSize& view_size,
25 const webrtc::DesktopRect& clip_area,
26 webrtc::DesktopFrame* buffer,
27 const webrtc::DesktopRegion& region,
28 const webrtc::DesktopRegion& shape) {
29 if (!task_runner_->BelongsToCurrentThread()) {
30 task_runner_->PostTask(FROM_HERE, base::Bind(
31 &FrameConsumerProxy::ApplyBuffer, this,
32 view_size, clip_area, buffer, region, shape));
33 return;
36 if (frame_consumer_.get())
37 frame_consumer_->ApplyBuffer(view_size, clip_area, buffer, region, shape);
40 void FrameConsumerProxy::ReturnBuffer(webrtc::DesktopFrame* buffer) {
41 if (!task_runner_->BelongsToCurrentThread()) {
42 task_runner_->PostTask(FROM_HERE, base::Bind(
43 &FrameConsumerProxy::ReturnBuffer, this, buffer));
44 return;
47 if (frame_consumer_.get())
48 frame_consumer_->ReturnBuffer(buffer);
51 void FrameConsumerProxy::SetSourceSize(
52 const webrtc::DesktopSize& source_size,
53 const webrtc::DesktopVector& source_dpi) {
54 if (!task_runner_->BelongsToCurrentThread()) {
55 task_runner_->PostTask(FROM_HERE, base::Bind(
56 &FrameConsumerProxy::SetSourceSize, this, source_size, source_dpi));
57 return;
60 if (frame_consumer_.get())
61 frame_consumer_->SetSourceSize(source_size, source_dpi);
64 FrameConsumer::PixelFormat FrameConsumerProxy::GetPixelFormat() {
65 return pixel_format_;
68 FrameConsumerProxy::~FrameConsumerProxy() {
71 } // namespace remoting