Index: cc/trees/remote_channel_host.h |
diff --git a/cc/trees/remote_channel_host.h b/cc/trees/remote_channel_host.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..08d4c99227365640080eea4e3264da82daede438 |
--- /dev/null |
+++ b/cc/trees/remote_channel_host.h |
@@ -0,0 +1,82 @@ |
+// Copyright 2015 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. |
+ |
+#ifndef CC_TREES_REMOTE_CHANNEL_HOST_H_ |
+#define CC_TREES_REMOTE_CHANNEL_HOST_H_ |
+ |
+#include "base/macros.h" |
+#include "base/threading/thread_checker.h" |
+#include "cc/base/cc_export.h" |
+#include "cc/raster/task_graph_runner.h" |
+#include "cc/trees/remote_channel_host_client.h" |
+#include "cc/trees/remote_channel_impl.h" |
+#include "cc/trees/remote_proto_channel.h" |
+ |
+namespace cc { |
+ |
+// RemoteChannelHost owns and controls the lifetime of the RemoteChannelImpl. |
+// For details, see cc/trees/remote_channel_impl.h. |
+// This class is created and lives on the main thread. |
+class CC_EXPORT RemoteChannelHost : public RemoteProtoChannel::ProtoReceiver { |
+ public: |
+ static scoped_ptr<RemoteChannelHost> Create( |
+ RemoteProtoChannel* remote_proto_channel, |
+ RemoteChannelHostClient* client, |
+ TaskGraphRunner* task_graph_runner, |
+ scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
+ scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); |
+ |
+ ~RemoteChannelHost() override; |
+ |
+ // TODO(khushalsagar): Add APIs for handling output surface requests and |
+ // visibility changes from the client. |
+ |
+ // Called by RemoteChannelImpl. |
+ void SendProto(const proto::CompositorMessage& proto); |
+ |
+ protected: |
+ RemoteChannelHost( |
+ RemoteProtoChannel* remote_proto_channel, |
+ RemoteChannelHostClient* client, |
+ TaskGraphRunner* task_graph_runner, |
+ scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
+ scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); |
+ |
+ // Virtual for testing. |
+ virtual scoped_ptr<RemoteChannelImpl> CreateRemoteChannelImpl( |
+ RemoteChannelHost* remote_channel_host, |
+ TaskGraphRunner* task_graph_runner, |
+ const LayerTreeSettings& settings, |
+ scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
+ scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); |
+ |
+ private: |
+ // RemoteProtoChannel::ProtoReceiver implementation. |
+ void OnProtoReceived(scoped_ptr<proto::CompositorMessage> proto) override; |
+ |
+ void InitializeImpl(const proto::InitializeImpl& proto); |
+ |
+ RemoteProtoChannel* remote_proto_channel_; |
+ RemoteChannelHostClient* client_; |
+ |
+ // These hold a valid value only until the initialize message is received and |
+ // the RemoteChannelImpl is created in Initialize(). |
+ TaskGraphRunner* task_graph_runner_; |
+ scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
+ scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner_; |
+ |
+ base::ThreadChecker main_thread_checker_; |
+ |
+ scoped_ptr<RemoteChannelImpl> remote_channel_impl_; |
+ |
+ // Set when a shutdown message is received and the RemoteChannelImpl is |
+ // destroyed. |
+ bool did_shutdown_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(RemoteChannelHost); |
+}; |
+ |
+} // namespace cc |
+ |
+#endif // CC_TREES_REMOTE_CHANNEL_HOST_H_ |