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

Unified Diff: services/navigation/navigation.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
« no previous file with comments | « services/navigation/navigation.h ('k') | services/navigation/view_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/navigation/navigation.cc
diff --git a/services/navigation/navigation.cc b/services/navigation/navigation.cc
index 91e46ce10631eb908d07e919224d273d4f661356..3a8664434465d58c50d7751bd99e7aaef43f4d50 100644
--- a/services/navigation/navigation.cc
+++ b/services/navigation/navigation.cc
@@ -6,24 +6,37 @@
#include "base/bind.h"
#include "base/message_loop/message_loop.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "services/navigation/view_impl.h"
+#include "services/shell/public/cpp/connector.h"
namespace navigation {
+namespace {
+
+void CreateViewOnViewTaskRunner(
+ std::unique_ptr<shell::Connector> connector,
+ const std::string& client_user_id,
+ mojom::ViewClientPtr client,
+ mojom::ViewRequest request,
+ std::unique_ptr<shell::ServiceContextRef> context_ref) {
+ // Owns itself.
+ new ViewImpl(std::move(connector), client_user_id, std::move(client),
+ std::move(request), std::move(context_ref));
+}
+
+} // namespace
+
Navigation::Navigation()
- : ref_factory_(base::MessageLoop::QuitWhenIdleClosure()) {
+ : view_task_runner_(base::ThreadTaskRunnerHandle::Get()),
+ ref_factory_(base::MessageLoop::QuitWhenIdleClosure()) {
bindings_.set_connection_error_handler(
base::Bind(&Navigation::ViewFactoryLost, base::Unretained(this)));
}
Navigation::~Navigation() {}
-void Navigation::OnStart(shell::Connector* connector,
- const shell::Identity& identity,
- uint32_t instance_id) {
- connector_ = connector;
-}
-
-bool Navigation::OnConnect(shell::Connection* connection) {
+bool Navigation::OnConnect(shell::Connection* connection,
+ shell::Connector* connector) {
std::string remote_user_id = connection->GetRemoteIdentity().user_id();
if (!client_user_id_.empty() && client_user_id_ != remote_user_id) {
LOG(ERROR) << "Must have a separate Navigation service instance for "
@@ -44,8 +57,14 @@ void Navigation::Create(shell::Connection* connection,
void Navigation::CreateView(mojom::ViewClientPtr client,
mojom::ViewRequest request) {
- new ViewImpl(connector_, client_user_id_, std::move(client),
- std::move(request), ref_factory_.CreateRef());
+ std::unique_ptr<shell::Connector> new_connector = connector_->Clone();
+ std::unique_ptr<shell::ServiceContextRef> context_ref =
+ ref_factory_.CreateRef();
+ view_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&CreateViewOnViewTaskRunner, base::Passed(&new_connector),
+ client_user_id_, base::Passed(&client), base::Passed(&request),
+ base::Passed(&context_ref)));
}
void Navigation::ViewFactoryLost() {
« no previous file with comments | « services/navigation/navigation.h ('k') | services/navigation/view_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698