Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(591)

Unified Diff: cc/test/remote_proto_channel_bridge.cc

Issue 1513643010: cc:: Add remote mode to the compositor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed vmpstr's comments. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/test/remote_proto_channel_bridge.h ('k') | cc/test/test_hooks.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/test/remote_proto_channel_bridge.cc
diff --git a/cc/test/remote_proto_channel_bridge.cc b/cc/test/remote_proto_channel_bridge.cc
new file mode 100644
index 0000000000000000000000000000000000000000..496479f78ccc122651d81ad5c812e1072c52bbbd
--- /dev/null
+++ b/cc/test/remote_proto_channel_bridge.cc
@@ -0,0 +1,77 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cc/test/remote_proto_channel_bridge.h"
+
+#include "base/logging.h"
+#include "base/memory/scoped_ptr.h"
+#include "cc/proto/compositor_message.pb.h"
+
+namespace cc {
+
+FakeRemoteProtoChannel::FakeRemoteProtoChannel(RemoteProtoChannelBridge* bridge)
+ : bridge_(bridge), receiver_(nullptr) {
+ DCHECK(bridge_);
+}
+
+FakeRemoteProtoChannel::~FakeRemoteProtoChannel() {}
+
+void FakeRemoteProtoChannel::SetProtoReceiver(ProtoReceiver* receiver) {
+ receiver_ = receiver;
+}
+
+void FakeRemoteProtoChannel::OnProtoReceived(
+ scoped_ptr<proto::CompositorMessage> proto) {
+ DCHECK(receiver_);
+
+ receiver_->OnProtoReceived(std::move(proto));
+}
+
+bool FakeRemoteProtoChannel::HasReceiver() const {
+ return receiver_ != nullptr;
+}
+
+FakeRemoteProtoChannelMain::FakeRemoteProtoChannelMain(
+ RemoteProtoChannelBridge* bridge,
+ TestHooks* test_hooks)
+ : FakeRemoteProtoChannel(bridge), test_hooks_(test_hooks) {}
+
+void FakeRemoteProtoChannelMain::SendCompositorProto(
+ const proto::CompositorMessage& proto) {
+ DCHECK(proto.has_to_impl());
+
+ // Check for CompositorMessageToImpl::InitializeImpl and CloseImpl message
+ // types to create and destroy the remote client LayerTreeHost.
+ proto::CompositorMessageToImpl to_impl_proto = proto.to_impl();
+ switch (to_impl_proto.message_type()) {
+ case proto::CompositorMessageToImpl::UNKNOWN:
+ return;
+ case proto::CompositorMessageToImpl::INITIALIZE_IMPL:
+ test_hooks_->CreateRemoteClientHost(to_impl_proto);
+ return;
+ case proto::CompositorMessageToImpl::CLOSE_IMPL:
+ test_hooks_->DestroyRemoteClientHost();
+ return;
+ default:
+ bridge_->channel_impl.OnProtoReceived(
+ make_scoped_ptr(new proto::CompositorMessage(proto)));
+ }
+}
+
+FakeRemoteProtoChannelImpl::FakeRemoteProtoChannelImpl(
+ RemoteProtoChannelBridge* bridge)
+ : FakeRemoteProtoChannel(bridge) {}
+
+void FakeRemoteProtoChannelImpl::SendCompositorProto(
+ const proto::CompositorMessage& proto) {
+ bridge_->channel_main.OnProtoReceived(
+ make_scoped_ptr(new proto::CompositorMessage(proto)));
+}
+
+RemoteProtoChannelBridge::RemoteProtoChannelBridge(TestHooks* test_hooks)
+ : channel_main(this, test_hooks), channel_impl(this) {}
+
+RemoteProtoChannelBridge::~RemoteProtoChannelBridge() {}
+
+} // namespace cc
« no previous file with comments | « cc/test/remote_proto_channel_bridge.h ('k') | cc/test/test_hooks.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698