| 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 <memory> | |
| 8 | |
| 9 #include "base/logging.h" | |
| 10 #include "base/memory/ptr_util.h" | |
| 11 #include "cc/proto/compositor_message.pb.h" | |
| 12 | |
| 13 namespace cc { | |
| 14 | |
| 15 FakeRemoteProtoChannel::FakeRemoteProtoChannel(RemoteProtoChannelBridge* bridge) | |
| 16 : bridge_(bridge), receiver_(nullptr) { | |
| 17 DCHECK(bridge_); | |
| 18 } | |
| 19 | |
| 20 FakeRemoteProtoChannel::~FakeRemoteProtoChannel() {} | |
| 21 | |
| 22 void FakeRemoteProtoChannel::SetProtoReceiver(ProtoReceiver* receiver) { | |
| 23 receiver_ = receiver; | |
| 24 } | |
| 25 | |
| 26 void FakeRemoteProtoChannel::OnProtoReceived( | |
| 27 std::unique_ptr<proto::CompositorMessage> proto) { | |
| 28 DCHECK(receiver_); | |
| 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 DCHECK(proto.has_to_impl()); | |
| 44 | |
| 45 // Check for CompositorMessageToImpl::InitializeImpl and CloseImpl message | |
| 46 // types to create and destroy the remote client LayerTreeHost. | |
| 47 proto::CompositorMessageToImpl to_impl_proto = proto.to_impl(); | |
| 48 switch (to_impl_proto.message_type()) { | |
| 49 case proto::CompositorMessageToImpl::UNKNOWN: | |
| 50 return; | |
| 51 default: | |
| 52 bridge_->channel_impl.OnProtoReceived( | |
| 53 base::MakeUnique<proto::CompositorMessage>(proto)); | |
| 54 } | |
| 55 } | |
| 56 | |
| 57 FakeRemoteProtoChannelImpl::FakeRemoteProtoChannelImpl( | |
| 58 RemoteProtoChannelBridge* bridge) | |
| 59 : FakeRemoteProtoChannel(bridge) {} | |
| 60 | |
| 61 void FakeRemoteProtoChannelImpl::SendCompositorProto( | |
| 62 const proto::CompositorMessage& proto) { | |
| 63 bridge_->channel_main.OnProtoReceived( | |
| 64 base::MakeUnique<proto::CompositorMessage>(proto)); | |
| 65 } | |
| 66 | |
| 67 RemoteProtoChannelBridge::RemoteProtoChannelBridge() | |
| 68 : channel_main(this), channel_impl(this) {} | |
| 69 | |
| 70 RemoteProtoChannelBridge::~RemoteProtoChannelBridge() {} | |
| 71 | |
| 72 } // namespace cc | |
| OLD | NEW |