Chromium Code Reviews| Index: content/renderer/render_widget_window_tree_client_factory.cc |
| diff --git a/content/renderer/render_widget_window_tree_client_factory.cc b/content/renderer/render_widget_window_tree_client_factory.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..0256789e09004b355a90c29efd0c69d65d3c6396 |
| --- /dev/null |
| +++ b/content/renderer/render_widget_window_tree_client_factory.cc |
| @@ -0,0 +1,69 @@ |
| +// 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 "content/renderer/render_widget_window_tree_client_factory.h" |
| + |
| +#include "base/logging.h" |
| +#include "base/macros.h" |
| +#include "components/mus/public/interfaces/window_tree.mojom.h" |
| +#include "content/common/render_widget_window_tree_client_factory.mojom.h" |
| +#include "content/public/common/mojo_shell_connection.h" |
| +#include "content/renderer/render_widget_mus_connection.h" |
| +#include "mojo/application/public/cpp/application_connection.h" |
| +#include "mojo/application/public/cpp/interface_factory.h" |
| +#include "mojo/common/weak_binding_set.h" |
| +#include "url/gurl.h" |
| + |
| +namespace content { |
| + |
| +namespace { |
| + |
| +class RenderWidgetWindowTreeClientFactoryImpl |
| + : public MojoShellConnection::Listener, |
| + public mojo::InterfaceFactory<mojom::RenderWidgetWindowTreeClientFactory>, |
| + public mojom::RenderWidgetWindowTreeClientFactory { |
| + public: |
| + static void Create() { new RenderWidgetWindowTreeClientFactoryImpl; } |
|
Ben Goodger (Google)
2015/11/25 20:28:15
at this point you may as well just make the ctor p
Fady Samuel
2015/11/25 20:46:50
Done.
|
| + |
| + private: |
| + RenderWidgetWindowTreeClientFactoryImpl() { |
| + DCHECK(MojoShellConnection::Get()); |
| + MojoShellConnection::Get()->AddListener(this); |
| + } |
| + |
| + ~RenderWidgetWindowTreeClientFactoryImpl() override {} |
|
Ben Goodger (Google)
2015/11/25 20:28:15
how is this object ever deleted?
Fady Samuel
2015/11/25 20:46:50
It's owned by MojoShellConnection because it's a l
Ben Goodger (Google)
2015/11/25 20:50:56
duh. i know you have the comment in MojoShellConne
|
| + |
| + // MojoShellConnection::Listener implementation: |
| + bool ConfigureIncomingConnection( |
| + mojo::ApplicationConnection* connection) override { |
| + connection->AddService<mojom::RenderWidgetWindowTreeClientFactory>(this); |
| + return true; |
| + } |
| + |
| + // mojo::InterfaceFactory<mojom::RenderWidgetWindowTreeClientFactory>: |
| + void Create(mojo::ApplicationConnection* connection, |
| + mojo::InterfaceRequest<mojom::RenderWidgetWindowTreeClientFactory> |
| + request) override { |
| + bindings_.AddBinding(this, request.Pass()); |
| + } |
| + |
| + // mojom::RenderWidgetWindowTreeClientFactory implementation. |
| + void CreateWindowTreeClientForRenderWidget( |
| + uint32_t routing_id, |
| + mojo::InterfaceRequest<mus::mojom::WindowTreeClient> request) override { |
| + new RenderWidgetMusConnection(routing_id, request.Pass()); |
| + } |
| + |
| + mojo::WeakBindingSet<mojom::RenderWidgetWindowTreeClientFactory> bindings_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(RenderWidgetWindowTreeClientFactoryImpl); |
| +}; |
| + |
| +} // namespace |
| + |
| +void CreateRenderWidgetWindowTreeClientFactory() { |
| + RenderWidgetWindowTreeClientFactoryImpl::Create(); |
| +} |
| + |
| +} // namespace content |