OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 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 #ifndef CC_TREES_REMOTE_CHANNEL_HOST_H_ |
| 6 #define CC_TREES_REMOTE_CHANNEL_HOST_H_ |
| 7 |
| 8 #include "base/macros.h" |
| 9 #include "base/threading/thread_checker.h" |
| 10 #include "cc/base/cc_export.h" |
| 11 #include "cc/raster/task_graph_runner.h" |
| 12 #include "cc/trees/remote_channel_host_client.h" |
| 13 #include "cc/trees/remote_channel_impl.h" |
| 14 #include "cc/trees/remote_proto_channel.h" |
| 15 |
| 16 namespace cc { |
| 17 |
| 18 // RemoteChannelHost owns and controls the lifetime of the RemoteChannelImpl. |
| 19 // For details, see cc/trees/remote_channel_impl.h. |
| 20 // This class is created and lives on the main thread. |
| 21 class CC_EXPORT RemoteChannelHost : public RemoteProtoChannel::ProtoReceiver { |
| 22 public: |
| 23 static scoped_ptr<RemoteChannelHost> Create( |
| 24 RemoteProtoChannel* remote_proto_channel, |
| 25 RemoteChannelHostClient* client, |
| 26 TaskGraphRunner* task_graph_runner, |
| 27 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 28 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); |
| 29 |
| 30 ~RemoteChannelHost() override; |
| 31 |
| 32 // TODO(khushalsagar): Add APIs for handling output surface requests and |
| 33 // visibility changes from the client. |
| 34 |
| 35 // Called by RemoteChannelImpl. |
| 36 void SendProto(const proto::CompositorMessage& proto); |
| 37 |
| 38 protected: |
| 39 RemoteChannelHost( |
| 40 RemoteProtoChannel* remote_proto_channel, |
| 41 RemoteChannelHostClient* client, |
| 42 TaskGraphRunner* task_graph_runner, |
| 43 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 44 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); |
| 45 |
| 46 // Virtual for testing. |
| 47 virtual scoped_ptr<RemoteChannelImpl> CreateRemoteChannelImpl( |
| 48 RemoteChannelHost* remote_channel_host, |
| 49 TaskGraphRunner* task_graph_runner, |
| 50 const LayerTreeSettings& settings, |
| 51 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner, |
| 52 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner); |
| 53 |
| 54 private: |
| 55 // RemoteProtoChannel::ProtoReceiver implementation. |
| 56 void OnProtoReceived(scoped_ptr<proto::CompositorMessage> proto) override; |
| 57 |
| 58 void InitializeImpl(const proto::InitializeImpl& proto); |
| 59 |
| 60 RemoteProtoChannel* remote_proto_channel_; |
| 61 RemoteChannelHostClient* client_; |
| 62 |
| 63 // These hold a valid value only until the initialize message is received and |
| 64 // the RemoteChannelImpl is created in Initialize(). |
| 65 TaskGraphRunner* task_graph_runner_; |
| 66 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; |
| 67 scoped_refptr<base::SingleThreadTaskRunner> impl_task_runner_; |
| 68 |
| 69 base::ThreadChecker main_thread_checker_; |
| 70 |
| 71 scoped_ptr<RemoteChannelImpl> remote_channel_impl_; |
| 72 |
| 73 // Set when a shutdown message is received and the RemoteChannelImpl is |
| 74 // destroyed. |
| 75 bool did_shutdown_; |
| 76 |
| 77 DISALLOW_COPY_AND_ASSIGN(RemoteChannelHost); |
| 78 }; |
| 79 |
| 80 } // namespace cc |
| 81 |
| 82 #endif // CC_TREES_REMOTE_CHANNEL_HOST_H_ |
OLD | NEW |