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

Side by Side Diff: content/renderer/mus/render_widget_window_tree_client_factory.cc

Issue 2138263002: Revert of Move content's shell connections to the IO thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/mus/render_widget_window_tree_client_factory.h" 5 #include "content/renderer/mus/render_widget_window_tree_client_factory.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/sequenced_task_runner.h"
14 #include "base/threading/thread_task_runner_handle.h"
15 #include "content/common/render_widget_window_tree_client_factory.mojom.h" 12 #include "content/common/render_widget_window_tree_client_factory.mojom.h"
16 #include "content/public/common/connection_filter.h"
17 #include "content/public/common/mojo_shell_connection.h" 13 #include "content/public/common/mojo_shell_connection.h"
18 #include "content/renderer/mus/render_widget_mus_connection.h" 14 #include "content/renderer/mus/render_widget_mus_connection.h"
19 #include "mojo/public/cpp/bindings/binding_set.h" 15 #include "mojo/public/cpp/bindings/binding_set.h"
16 #include "services/shell/public/cpp/connection.h"
20 #include "services/shell/public/cpp/interface_factory.h" 17 #include "services/shell/public/cpp/interface_factory.h"
21 #include "services/shell/public/cpp/service.h" 18 #include "services/shell/public/cpp/service.h"
22 #include "services/ui/public/interfaces/window_tree.mojom.h" 19 #include "services/ui/public/interfaces/window_tree.mojom.h"
23 #include "url/gurl.h" 20 #include "url/gurl.h"
24 21
25 namespace content { 22 namespace content {
26 23
27 namespace { 24 namespace {
28 25
29 void BindMusConnectionOnMainThread(
30 uint32_t routing_id,
31 ui::mojom::WindowTreeClientRequest request) {
32 RenderWidgetMusConnection* connection =
33 RenderWidgetMusConnection::GetOrCreate(routing_id);
34 connection->Bind(std::move(request));
35 }
36
37 // This object's lifetime is managed by MojoShellConnection because it's a 26 // This object's lifetime is managed by MojoShellConnection because it's a
38 // registered with it. 27 // registered with it.
39 class RenderWidgetWindowTreeClientFactoryImpl 28 class RenderWidgetWindowTreeClientFactoryImpl
40 : public ConnectionFilter, 29 : public shell::Service,
41 public shell::InterfaceFactory< 30 public shell::InterfaceFactory<
42 mojom::RenderWidgetWindowTreeClientFactory>, 31 mojom::RenderWidgetWindowTreeClientFactory>,
43 public mojom::RenderWidgetWindowTreeClientFactory { 32 public mojom::RenderWidgetWindowTreeClientFactory {
44 public: 33 public:
45 RenderWidgetWindowTreeClientFactoryImpl() { 34 RenderWidgetWindowTreeClientFactoryImpl() {
46 DCHECK(MojoShellConnection::GetForProcess()); 35 DCHECK(MojoShellConnection::GetForProcess());
47
48 main_thread_task_runner_ = base::ThreadTaskRunnerHandle::Get();
49 } 36 }
50 37
51 ~RenderWidgetWindowTreeClientFactoryImpl() override {} 38 ~RenderWidgetWindowTreeClientFactoryImpl() override {}
52 39
53 private: 40 private:
54 // ConnectionFilter implementation: 41 // shell::Service implementation:
55 bool OnConnect(shell::Connection* connection, 42 bool OnConnect(shell::Connection* connection) override {
56 shell::Connector* connector) override {
57 connection->AddInterface<mojom::RenderWidgetWindowTreeClientFactory>(this); 43 connection->AddInterface<mojom::RenderWidgetWindowTreeClientFactory>(this);
58 return true; 44 return true;
59 } 45 }
60 46
61 // shell::InterfaceFactory<mojom::RenderWidgetWindowTreeClientFactory>: 47 // shell::InterfaceFactory<mojom::RenderWidgetWindowTreeClientFactory>:
62 void Create(shell::Connection* connection, 48 void Create(shell::Connection* connection,
63 mojo::InterfaceRequest<mojom::RenderWidgetWindowTreeClientFactory> 49 mojo::InterfaceRequest<mojom::RenderWidgetWindowTreeClientFactory>
64 request) override { 50 request) override {
65 bindings_.AddBinding(this, std::move(request)); 51 bindings_.AddBinding(this, std::move(request));
66 } 52 }
67 53
68 // mojom::RenderWidgetWindowTreeClientFactory implementation. 54 // mojom::RenderWidgetWindowTreeClientFactory implementation.
69 void CreateWindowTreeClientForRenderWidget( 55 void CreateWindowTreeClientForRenderWidget(
70 uint32_t routing_id, 56 uint32_t routing_id,
71 ui::mojom::WindowTreeClientRequest request) override { 57 mojo::InterfaceRequest<ui::mojom::WindowTreeClient> request) override {
72 main_thread_task_runner_->PostTask( 58 RenderWidgetMusConnection* connection =
73 FROM_HERE, base::Bind(&BindMusConnectionOnMainThread, routing_id, 59 RenderWidgetMusConnection::GetOrCreate(routing_id);
74 base::Passed(&request))); 60 connection->Bind(std::move(request));
75 } 61 }
76 62
77 scoped_refptr<base::SequencedTaskRunner> main_thread_task_runner_;
78 mojo::BindingSet<mojom::RenderWidgetWindowTreeClientFactory> bindings_; 63 mojo::BindingSet<mojom::RenderWidgetWindowTreeClientFactory> bindings_;
79 64
80 DISALLOW_COPY_AND_ASSIGN(RenderWidgetWindowTreeClientFactoryImpl); 65 DISALLOW_COPY_AND_ASSIGN(RenderWidgetWindowTreeClientFactoryImpl);
81 }; 66 };
82 67
83 } // namespace 68 } // namespace
84 69
85 void CreateRenderWidgetWindowTreeClientFactory( 70 void CreateRenderWidgetWindowTreeClientFactory() {
86 MojoShellConnection* connection) { 71 MojoShellConnection::GetForProcess()->MergeService(
87 connection->AddConnectionFilter( 72 base::WrapUnique(new RenderWidgetWindowTreeClientFactoryImpl));
88 base::MakeUnique<RenderWidgetWindowTreeClientFactoryImpl>());
89 } 73 }
90 74
91 } // namespace content 75 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/mus/render_widget_window_tree_client_factory.h ('k') | content/renderer/render_thread_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698