| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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 "cc/test/remote_proto_channel_bridge.h" | 5 #include "cc/test/remote_proto_channel_bridge.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 DCHECK(receiver_); | 28 DCHECK(receiver_); |
| 29 | 29 |
| 30 receiver_->OnProtoReceived(std::move(proto)); | 30 receiver_->OnProtoReceived(std::move(proto)); |
| 31 } | 31 } |
| 32 | 32 |
| 33 bool FakeRemoteProtoChannel::HasReceiver() const { | 33 bool FakeRemoteProtoChannel::HasReceiver() const { |
| 34 return receiver_ != nullptr; | 34 return receiver_ != nullptr; |
| 35 } | 35 } |
| 36 | 36 |
| 37 FakeRemoteProtoChannelMain::FakeRemoteProtoChannelMain( | 37 FakeRemoteProtoChannelMain::FakeRemoteProtoChannelMain( |
| 38 RemoteProtoChannelBridge* bridge, | 38 RemoteProtoChannelBridge* bridge) |
| 39 TestHooks* test_hooks) | 39 : FakeRemoteProtoChannel(bridge) {} |
| 40 : FakeRemoteProtoChannel(bridge), test_hooks_(test_hooks) {} | |
| 41 | 40 |
| 42 void FakeRemoteProtoChannelMain::SendCompositorProto( | 41 void FakeRemoteProtoChannelMain::SendCompositorProto( |
| 43 const proto::CompositorMessage& proto) { | 42 const proto::CompositorMessage& proto) { |
| 44 DCHECK(proto.has_to_impl()); | 43 DCHECK(proto.has_to_impl()); |
| 45 | 44 |
| 46 // Check for CompositorMessageToImpl::InitializeImpl and CloseImpl message | 45 // Check for CompositorMessageToImpl::InitializeImpl and CloseImpl message |
| 47 // types to create and destroy the remote client LayerTreeHost. | 46 // types to create and destroy the remote client LayerTreeHost. |
| 48 proto::CompositorMessageToImpl to_impl_proto = proto.to_impl(); | 47 proto::CompositorMessageToImpl to_impl_proto = proto.to_impl(); |
| 49 switch (to_impl_proto.message_type()) { | 48 switch (to_impl_proto.message_type()) { |
| 50 case proto::CompositorMessageToImpl::UNKNOWN: | 49 case proto::CompositorMessageToImpl::UNKNOWN: |
| 51 return; | 50 return; |
| 52 case proto::CompositorMessageToImpl::INITIALIZE_IMPL: | |
| 53 test_hooks_->CreateRemoteClientHost(to_impl_proto); | |
| 54 return; | |
| 55 case proto::CompositorMessageToImpl::CLOSE_IMPL: | |
| 56 test_hooks_->DestroyRemoteClientHost(); | |
| 57 return; | |
| 58 default: | 51 default: |
| 59 bridge_->channel_impl.OnProtoReceived( | 52 bridge_->channel_impl.OnProtoReceived( |
| 60 base::MakeUnique<proto::CompositorMessage>(proto)); | 53 base::MakeUnique<proto::CompositorMessage>(proto)); |
| 61 } | 54 } |
| 62 } | 55 } |
| 63 | 56 |
| 64 FakeRemoteProtoChannelImpl::FakeRemoteProtoChannelImpl( | 57 FakeRemoteProtoChannelImpl::FakeRemoteProtoChannelImpl( |
| 65 RemoteProtoChannelBridge* bridge) | 58 RemoteProtoChannelBridge* bridge) |
| 66 : FakeRemoteProtoChannel(bridge) {} | 59 : FakeRemoteProtoChannel(bridge) {} |
| 67 | 60 |
| 68 void FakeRemoteProtoChannelImpl::SendCompositorProto( | 61 void FakeRemoteProtoChannelImpl::SendCompositorProto( |
| 69 const proto::CompositorMessage& proto) { | 62 const proto::CompositorMessage& proto) { |
| 70 bridge_->channel_main.OnProtoReceived( | 63 bridge_->channel_main.OnProtoReceived( |
| 71 base::MakeUnique<proto::CompositorMessage>(proto)); | 64 base::MakeUnique<proto::CompositorMessage>(proto)); |
| 72 } | 65 } |
| 73 | 66 |
| 74 RemoteProtoChannelBridge::RemoteProtoChannelBridge(TestHooks* test_hooks) | 67 RemoteProtoChannelBridge::RemoteProtoChannelBridge() |
| 75 : channel_main(this, test_hooks), channel_impl(this) {} | 68 : channel_main(this), channel_impl(this) {} |
| 76 | 69 |
| 77 RemoteProtoChannelBridge::~RemoteProtoChannelBridge() {} | 70 RemoteProtoChannelBridge::~RemoteProtoChannelBridge() {} |
| 78 | 71 |
| 79 } // namespace cc | 72 } // namespace cc |
| OLD | NEW |