Clear preference when reset in gesture config UI
[chromium-blink-merge.git] / remoting / client / frame_consumer_proxy.cc
blob6f56c22232cc339d2215ea3b21b188dd278f163c
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 "ppapi/cpp/image_data.h"
12 namespace remoting {
14 FrameConsumerProxy::FrameConsumerProxy(
15 scoped_refptr<base::SingleThreadTaskRunner> task_runner)
16 : task_runner_(task_runner) {
19 void FrameConsumerProxy::ApplyBuffer(const SkISize& view_size,
20 const SkIRect& clip_area,
21 pp::ImageData* buffer,
22 const SkRegion& region) {
23 if (!task_runner_->BelongsToCurrentThread()) {
24 task_runner_->PostTask(FROM_HERE, base::Bind(
25 &FrameConsumerProxy::ApplyBuffer, this,
26 view_size, clip_area, buffer, region));
27 return;
30 if (frame_consumer_.get())
31 frame_consumer_->ApplyBuffer(view_size, clip_area, buffer, region);
34 void FrameConsumerProxy::ReturnBuffer(pp::ImageData* buffer) {
35 if (!task_runner_->BelongsToCurrentThread()) {
36 task_runner_->PostTask(FROM_HERE, base::Bind(
37 &FrameConsumerProxy::ReturnBuffer, this, buffer));
38 return;
41 if (frame_consumer_.get())
42 frame_consumer_->ReturnBuffer(buffer);
45 void FrameConsumerProxy::SetSourceSize(const SkISize& source_size,
46 const SkIPoint& source_dpi) {
47 if (!task_runner_->BelongsToCurrentThread()) {
48 task_runner_->PostTask(FROM_HERE, base::Bind(
49 &FrameConsumerProxy::SetSourceSize, this, source_size, source_dpi));
50 return;
53 if (frame_consumer_.get())
54 frame_consumer_->SetSourceSize(source_size, source_dpi);
57 void FrameConsumerProxy::Attach(
58 const base::WeakPtr<FrameConsumer>& frame_consumer) {
59 DCHECK(task_runner_->BelongsToCurrentThread());
60 DCHECK(frame_consumer_.get() == NULL);
61 frame_consumer_ = frame_consumer;
64 FrameConsumerProxy::~FrameConsumerProxy() {
67 } // namespace remoting