OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 DCHECK(receiver_); |
| 27 |
| 28 receiver_->OnProtoReceived(std::move(proto)); |
| 29 } |
| 30 |
| 31 bool FakeRemoteProtoChannel::HasReceiver() const { |
| 32 return receiver_ != nullptr; |
| 33 } |
| 34 |
| 35 FakeRemoteProtoChannelMain::FakeRemoteProtoChannelMain( |
| 36 RemoteProtoChannelBridge* bridge, |
| 37 TestHooks* test_hooks) |
| 38 : FakeRemoteProtoChannel(bridge), test_hooks_(test_hooks) {} |
| 39 |
| 40 void FakeRemoteProtoChannelMain::SendCompositorProto( |
| 41 const proto::CompositorMessage& proto) { |
| 42 DCHECK(proto.has_to_impl()); |
| 43 |
| 44 // Check for CompositorMessageToImpl::InitializeImpl and CloseImpl message |
| 45 // types to create and destroy the remote client LayerTreeHost. |
| 46 proto::CompositorMessageToImpl to_impl_proto = proto.to_impl(); |
| 47 switch (to_impl_proto.message_type()) { |
| 48 case proto::CompositorMessageToImpl::UNKNOWN: |
| 49 return; |
| 50 case proto::CompositorMessageToImpl::INITIALIZE_IMPL: |
| 51 test_hooks_->CreateRemoteClientHost(to_impl_proto); |
| 52 return; |
| 53 case proto::CompositorMessageToImpl::CLOSE_IMPL: |
| 54 test_hooks_->DestroyRemoteClientHost(); |
| 55 return; |
| 56 default: |
| 57 bridge_->channel_impl.OnProtoReceived( |
| 58 make_scoped_ptr(new proto::CompositorMessage(proto))); |
| 59 } |
| 60 } |
| 61 |
| 62 FakeRemoteProtoChannelImpl::FakeRemoteProtoChannelImpl( |
| 63 RemoteProtoChannelBridge* bridge) |
| 64 : FakeRemoteProtoChannel(bridge) {} |
| 65 |
| 66 void FakeRemoteProtoChannelImpl::SendCompositorProto( |
| 67 const proto::CompositorMessage& proto) { |
| 68 bridge_->channel_main.OnProtoReceived( |
| 69 make_scoped_ptr(new proto::CompositorMessage(proto))); |
| 70 } |
| 71 |
| 72 RemoteProtoChannelBridge::RemoteProtoChannelBridge(TestHooks* test_hooks) |
| 73 : channel_main(this, test_hooks), channel_impl(this) {} |
| 74 |
| 75 RemoteProtoChannelBridge::~RemoteProtoChannelBridge() {} |
| 76 |
| 77 } // namespace cc |
OLD | NEW |