| Index: cc/trees/remote_channel_host.cc
|
| diff --git a/cc/trees/remote_channel_host.cc b/cc/trees/remote_channel_host.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..f00e68d3f16e9e10ecad7163d6e3d9bd9550caaf
|
| --- /dev/null
|
| +++ b/cc/trees/remote_channel_host.cc
|
| @@ -0,0 +1,114 @@
|
| +// 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.
|
| +
|
| +#include "cc/trees/remote_channel_host.h"
|
| +
|
| +#include "cc/proto/compositor_message.pb.h"
|
| +#include "cc/proto/compositor_message_to_impl.pb.h"
|
| +
|
| +namespace cc {
|
| +
|
| +scoped_ptr<RemoteChannelHost> 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) {
|
| + return make_scoped_ptr(
|
| + new RemoteChannelHost(remote_proto_channel, client, task_graph_runner,
|
| + main_task_runner, impl_task_runner));
|
| +}
|
| +
|
| +RemoteChannelHost::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)
|
| + : remote_proto_channel_(remote_proto_channel),
|
| + client_(client),
|
| + task_graph_runner_(task_graph_runner),
|
| + main_task_runner_(main_task_runner),
|
| + impl_task_runner_(impl_task_runner),
|
| + did_shutdown_(false) {
|
| + DCHECK(main_thread_checker_.CalledOnValidThread());
|
| + DCHECK(remote_proto_channel_);
|
| + DCHECK(client_);
|
| + DCHECK(task_graph_runner_);
|
| +
|
| + remote_proto_channel_->SetProtoReceiver(this);
|
| +}
|
| +
|
| +RemoteChannelHost::~RemoteChannelHost() {
|
| + DCHECK(main_thread_checker_.CalledOnValidThread());
|
| +
|
| + remote_proto_channel_->SetProtoReceiver(nullptr);
|
| + remote_channel_impl_.reset();
|
| +}
|
| +
|
| +scoped_ptr<RemoteChannelImpl> RemoteChannelHost::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) {
|
| + return RemoteChannelImpl::Create(remote_channel_host, task_graph_runner,
|
| + settings, main_task_runner,
|
| + impl_task_runner);
|
| +}
|
| +
|
| +void RemoteChannelHost::SendProto(const proto::CompositorMessage& proto) {
|
| + DCHECK(main_thread_checker_.CalledOnValidThread());
|
| +
|
| + remote_proto_channel_->SendCompositorProto(proto);
|
| +}
|
| +
|
| +void RemoteChannelHost::OnProtoReceived(
|
| + scoped_ptr<proto::CompositorMessage> proto) {
|
| + DCHECK(main_thread_checker_.CalledOnValidThread());
|
| + DCHECK(!did_shutdown_);
|
| + DCHECK(proto->has_to_impl());
|
| +
|
| + proto::CompositorMessageToImpl to_impl_proto = proto->to_impl();
|
| + switch (to_impl_proto.message_type()) {
|
| + case proto::CompositorMessageToImpl::Unknown:
|
| + return;
|
| + case proto::CompositorMessageToImpl::InitializeImpl:
|
| + InitializeImpl(to_impl_proto.initialize_impl_message());
|
| + return;
|
| + case proto::CompositorMessageToImpl::CloseImpl:
|
| + DCHECK(remote_channel_impl_);
|
| + remote_channel_impl_.reset();
|
| +
|
| + did_shutdown_ = true;
|
| +
|
| + // It is not safe to access any variables after this method is called. The
|
| + // client may destroy us now so |this| will not be there anymore.
|
| + client_->DidShutdown();
|
| + return;
|
| + default:
|
| + DCHECK(remote_channel_impl_);
|
| + remote_channel_impl_->HandleProto(to_impl_proto);
|
| + }
|
| +}
|
| +
|
| +void RemoteChannelHost::InitializeImpl(const proto::InitializeImpl& proto) {
|
| + DCHECK(main_thread_checker_.CalledOnValidThread());
|
| + DCHECK(!remote_channel_impl_);
|
| +
|
| + LayerTreeSettings settings;
|
| + settings.FromProtobuf(proto.layer_tree_settings());
|
| +
|
| + client_->OverrideLayerTreeSettings(&settings);
|
| +
|
| + remote_channel_impl_ = CreateRemoteChannelImpl(
|
| + this, task_graph_runner_, settings, main_task_runner_, impl_task_runner_);
|
| + remote_channel_impl_->Initialize();
|
| +
|
| + task_graph_runner_ = nullptr;
|
| + main_task_runner_ = nullptr;
|
| + impl_task_runner_ = nullptr;
|
| +}
|
| +
|
| +} // namespace cc
|
|
|