Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 "remoting/client/frame_consumer_proxy.h" | 5 #include "remoting/client/frame_consumer_proxy.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/location.h" |
| 9 #include "base/single_thread_task_runner.h" | |
| 9 #include "ppapi/cpp/image_data.h" | 10 #include "ppapi/cpp/image_data.h" |
| 10 | 11 |
| 11 namespace remoting { | 12 namespace remoting { |
| 12 | 13 |
| 13 FrameConsumerProxy::FrameConsumerProxy( | 14 FrameConsumerProxy::FrameConsumerProxy( |
| 14 scoped_refptr<base::MessageLoopProxy> frame_consumer_message_loop) | 15 scoped_refptr<base::SingleThreadTaskRunner> frame_consumer_task_runner) |
| 15 : frame_consumer_message_loop_(frame_consumer_message_loop) { | 16 : frame_consumer_task_runner_(frame_consumer_task_runner) { |
| 16 } | 17 } |
| 17 | 18 |
| 18 void FrameConsumerProxy::ApplyBuffer(const SkISize& view_size, | 19 void FrameConsumerProxy::ApplyBuffer(const SkISize& view_size, |
| 19 const SkIRect& clip_area, | 20 const SkIRect& clip_area, |
| 20 pp::ImageData* buffer, | 21 pp::ImageData* buffer, |
| 21 const SkRegion& region) { | 22 const SkRegion& region) { |
| 22 if (!frame_consumer_message_loop_->BelongsToCurrentThread()) { | 23 if (!frame_consumer_task_runner_->BelongsToCurrentThread()) { |
| 23 frame_consumer_message_loop_->PostTask(FROM_HERE, base::Bind( | 24 frame_consumer_task_runner_->PostTask(FROM_HERE, base::Bind( |
| 24 &FrameConsumerProxy::ApplyBuffer, this, | 25 &FrameConsumerProxy::ApplyBuffer, this, |
| 25 view_size, clip_area, buffer, region)); | 26 view_size, clip_area, buffer, region)); |
| 26 return; | 27 return; |
| 27 } | 28 } |
| 28 | 29 |
| 29 if (frame_consumer_) | 30 if (frame_consumer_) |
| 30 frame_consumer_->ApplyBuffer(view_size, clip_area, buffer, region); | 31 frame_consumer_->ApplyBuffer(view_size, clip_area, buffer, region); |
| 31 } | 32 } |
| 32 | 33 |
| 33 void FrameConsumerProxy::ReturnBuffer(pp::ImageData* buffer) { | 34 void FrameConsumerProxy::ReturnBuffer(pp::ImageData* buffer) { |
| 34 if (!frame_consumer_message_loop_->BelongsToCurrentThread()) { | 35 if (!frame_consumer_task_runner_->BelongsToCurrentThread()) { |
| 35 frame_consumer_message_loop_->PostTask(FROM_HERE, base::Bind( | 36 frame_consumer_task_runner_->PostTask(FROM_HERE, base::Bind( |
| 36 &FrameConsumerProxy::ReturnBuffer, this, buffer)); | 37 &FrameConsumerProxy::ReturnBuffer, this, buffer)); |
| 37 return; | 38 return; |
| 38 } | 39 } |
| 39 | 40 |
| 40 if (frame_consumer_) | 41 if (frame_consumer_) |
| 41 frame_consumer_->ReturnBuffer(buffer); | 42 frame_consumer_->ReturnBuffer(buffer); |
| 42 } | 43 } |
| 43 | 44 |
| 44 void FrameConsumerProxy::SetSourceSize(const SkISize& source_size) { | 45 void FrameConsumerProxy::SetSourceSize(const SkISize& source_size) { |
| 45 if (!frame_consumer_message_loop_->BelongsToCurrentThread()) { | 46 if (!frame_consumer_task_runner_->BelongsToCurrentThread()) { |
| 46 frame_consumer_message_loop_->PostTask(FROM_HERE, base::Bind( | 47 frame_consumer_task_runner_->PostTask(FROM_HERE, base::Bind( |
| 47 &FrameConsumerProxy::SetSourceSize, this, source_size)); | 48 &FrameConsumerProxy::SetSourceSize, this, source_size)); |
| 48 return; | 49 return; |
| 49 } | 50 } |
| 50 | 51 |
| 51 if (frame_consumer_) | 52 if (frame_consumer_) |
| 52 frame_consumer_->SetSourceSize(source_size); | 53 frame_consumer_->SetSourceSize(source_size); |
| 53 } | 54 } |
| 54 | 55 |
| 55 void FrameConsumerProxy::Attach( | 56 void FrameConsumerProxy::Attach( |
| 56 const base::WeakPtr<FrameConsumer>& frame_consumer) { | 57 const base::WeakPtr<FrameConsumer>& frame_consumer) { |
| 57 DCHECK(frame_consumer_message_loop_->BelongsToCurrentThread()); | 58 DCHECK(frame_consumer_task_runner_->BelongsToCurrentThread()); |
| 58 DCHECK(frame_consumer_ == NULL); | 59 DCHECK(frame_consumer_ == NULL); |
| 59 frame_consumer_ = frame_consumer; | 60 frame_consumer_ = frame_consumer; |
| 60 } | 61 } |
| 61 | 62 |
| 62 FrameConsumerProxy::~FrameConsumerProxy() { | 63 FrameConsumerProxy::~FrameConsumerProxy() { |
| 63 DCHECK(frame_consumer_message_loop_->BelongsToCurrentThread()); | 64 DCHECK(frame_consumer_task_runner_->BelongsToCurrentThread()); |
|
Wez
2012/05/26 00:18:40
This DCHECK() looks wrong. FrameConsumerProxy is r
Sergey Ulanov
2012/05/30 01:07:07
Agree. Removed it.
| |
| 64 } | 65 } |
| 65 | 66 |
| 66 } // namespace remoting | 67 } // namespace remoting |
| OLD | NEW |