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

Unified Diff: content/renderer/mus/render_widget_window_tree_client_factory.cc

Issue 2111353002: Move content's shell connections to the IO thread (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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 side-by-side diff with in-line comments
Download patch
Index: content/renderer/mus/render_widget_window_tree_client_factory.cc
diff --git a/content/renderer/mus/render_widget_window_tree_client_factory.cc b/content/renderer/mus/render_widget_window_tree_client_factory.cc
index 5abfc23f4c02e40bed6e8a29b965f1eb065e531b..a52d32cf37a3b0e48f61362079e6959af5101341 100644
--- a/content/renderer/mus/render_widget_window_tree_client_factory.cc
+++ b/content/renderer/mus/render_widget_window_tree_client_factory.cc
@@ -9,12 +9,14 @@
#include "base/logging.h"
#include "base/macros.h"
#include "base/memory/ptr_util.h"
+#include "base/memory/ref_counted.h"
+#include "base/sequenced_task_runner.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "content/common/render_widget_window_tree_client_factory.mojom.h"
-#include "content/public/child/child_thread.h"
+#include "content/public/common/connection_filter.h"
#include "content/public/common/mojo_shell_connection.h"
#include "content/renderer/mus/render_widget_mus_connection.h"
#include "mojo/public/cpp/bindings/binding_set.h"
-#include "services/shell/public/cpp/connection.h"
#include "services/shell/public/cpp/interface_factory.h"
#include "services/shell/public/cpp/service.h"
#include "services/ui/public/interfaces/window_tree.mojom.h"
@@ -24,23 +26,32 @@ namespace content {
namespace {
+void BindMusConnectionOnMainThread(
+ uint32_t routing_id,
+ ui::mojom::WindowTreeClientRequest request) {
+ RenderWidgetMusConnection* connection =
+ RenderWidgetMusConnection::GetOrCreate(routing_id);
+ connection->Bind(std::move(request));
+}
+
// This object's lifetime is managed by MojoShellConnection because it's a
// registered with it.
class RenderWidgetWindowTreeClientFactoryImpl
- : public shell::Service,
+ : public ConnectionFilter,
public shell::InterfaceFactory<
mojom::RenderWidgetWindowTreeClientFactory>,
public mojom::RenderWidgetWindowTreeClientFactory {
public:
RenderWidgetWindowTreeClientFactoryImpl() {
- DCHECK(ChildThread::Get()->GetMojoShellConnection());
+ main_thread_task_runner_ = base::ThreadTaskRunnerHandle::Get();
}
~RenderWidgetWindowTreeClientFactoryImpl() override {}
private:
- // shell::Service implementation:
- bool OnConnect(shell::Connection* connection) override {
+ // ConnectionFilter implementation:
+ bool OnConnect(shell::Connection* connection,
+ shell::Connector* connector) override {
connection->AddInterface<mojom::RenderWidgetWindowTreeClientFactory>(this);
return true;
}
@@ -55,12 +66,13 @@ class RenderWidgetWindowTreeClientFactoryImpl
// mojom::RenderWidgetWindowTreeClientFactory implementation.
void CreateWindowTreeClientForRenderWidget(
uint32_t routing_id,
- mojo::InterfaceRequest<ui::mojom::WindowTreeClient> request) override {
- RenderWidgetMusConnection* connection =
- RenderWidgetMusConnection::GetOrCreate(routing_id);
- connection->Bind(std::move(request));
+ ui::mojom::WindowTreeClientRequest request) override {
+ main_thread_task_runner_->PostTask(
+ FROM_HERE, base::Bind(&BindMusConnectionOnMainThread, routing_id,
+ base::Passed(&request)));
}
+ scoped_refptr<base::SequencedTaskRunner> main_thread_task_runner_;
mojo::BindingSet<mojom::RenderWidgetWindowTreeClientFactory> bindings_;
DISALLOW_COPY_AND_ASSIGN(RenderWidgetWindowTreeClientFactoryImpl);
@@ -68,9 +80,10 @@ class RenderWidgetWindowTreeClientFactoryImpl
} // namespace
-void CreateRenderWidgetWindowTreeClientFactory() {
- ChildThread::Get()->GetMojoShellConnection()->MergeService(
- base::WrapUnique(new RenderWidgetWindowTreeClientFactoryImpl));
+void CreateRenderWidgetWindowTreeClientFactory(
+ MojoShellConnection* connection) {
+ connection->AddConnectionFilter(
+ base::MakeUnique<RenderWidgetWindowTreeClientFactoryImpl>());
}
} // namespace content
« no previous file with comments | « content/renderer/mus/render_widget_window_tree_client_factory.h ('k') | content/renderer/render_thread_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698