OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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. |
| 4 |
| 5 #include "cc/test/remote_proto_channel_bridge.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "cc/proto/compositor_message.pb.h" |
| 10 |
| 11 namespace cc { |
| 12 |
| 13 FakeRemoteProtoChannel::FakeRemoteProtoChannel(RemoteProtoChannelBridge* bridge) |
| 14 : bridge_(bridge), receiver_(nullptr) { |
| 15 DCHECK(bridge_); |
| 16 } |
| 17 |
| 18 FakeRemoteProtoChannel::~FakeRemoteProtoChannel() {} |
| 19 |
| 20 void FakeRemoteProtoChannel::SetProtoReceiver(ProtoReceiver* receiver) { |
| 21 receiver_ = receiver; |
| 22 } |
| 23 |
| 24 void FakeRemoteProtoChannel::OnProtoReceived( |
| 25 scoped_ptr<proto::CompositorMessage> proto) { |
| 26 // Drop the protos if we don't have a receiver. |
| 27 if (!receiver_) |
| 28 return; |
| 29 |
| 30 receiver_->OnProtoReceived(std::move(proto)); |
| 31 } |
| 32 |
| 33 bool FakeRemoteProtoChannel::HasReceiver() const { |
| 34 return receiver_ != nullptr; |
| 35 } |
| 36 |
| 37 FakeRemoteProtoChannelMain::FakeRemoteProtoChannelMain( |
| 38 RemoteProtoChannelBridge* bridge) |
| 39 : FakeRemoteProtoChannel(bridge) {} |
| 40 |
| 41 void FakeRemoteProtoChannelMain::SendCompositorProto( |
| 42 const proto::CompositorMessage& proto) { |
| 43 bridge_->channel_impl.OnProtoReceived( |
| 44 make_scoped_ptr(new proto::CompositorMessage(proto))); |
| 45 } |
| 46 |
| 47 FakeRemoteProtoChannelImpl::FakeRemoteProtoChannelImpl( |
| 48 RemoteProtoChannelBridge* bridge) |
| 49 : FakeRemoteProtoChannel(bridge) {} |
| 50 |
| 51 void FakeRemoteProtoChannelImpl::SendCompositorProto( |
| 52 const proto::CompositorMessage& proto) { |
| 53 bridge_->channel_main.OnProtoReceived( |
| 54 make_scoped_ptr(new proto::CompositorMessage(proto))); |
| 55 } |
| 56 |
| 57 RemoteProtoChannelBridge::RemoteProtoChannelBridge() |
| 58 : channel_main(this), channel_impl(this) {} |
| 59 |
| 60 RemoteProtoChannelBridge::~RemoteProtoChannelBridge() {} |
| 61 |
| 62 } // namespace cc |
OLD | NEW |