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

Side by Side Diff: services/shell/public/cpp/lib/shell_connection.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: . 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "services/shell/public/cpp/shell_connection.h" 5 #include "services/shell/public/cpp/shell_connection.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "mojo/public/cpp/bindings/interface_ptr.h" 10 #include "mojo/public/cpp/bindings/interface_ptr.h"
11 #include "mojo/public/cpp/bindings/interface_request.h" 11 #include "mojo/public/cpp/bindings/interface_request.h"
12 #include "services/shell/public/cpp/capabilities.h" 12 #include "services/shell/public/cpp/capabilities.h"
13 #include "services/shell/public/cpp/connector.h"
14 #include "services/shell/public/cpp/lib/connection_impl.h" 13 #include "services/shell/public/cpp/lib/connection_impl.h"
15 #include "services/shell/public/cpp/lib/connector_impl.h" 14 #include "services/shell/public/cpp/lib/connector_impl.h"
16 #include "services/shell/public/cpp/shell_client.h" 15 #include "services/shell/public/cpp/shell_client.h"
17 16
18 namespace shell { 17 namespace shell {
19 18
20 //////////////////////////////////////////////////////////////////////////////// 19 ////////////////////////////////////////////////////////////////////////////////
21 // ShellConnection, public: 20 // ShellConnection, public:
22 21
23 ShellConnection::ShellConnection(shell::ShellClient* client, 22 ShellConnection::ShellConnection(shell::ShellClient* client,
24 mojom::ShellClientRequest request) 23 mojom::ShellClientRequest request,
25 : client_(client), binding_(this) { 24 std::unique_ptr<Connector> connector,
26 mojom::ConnectorPtr connector; 25 mojom::ConnectorRequest connector_request)
27 pending_connector_request_ = GetProxy(&connector); 26 : pending_connector_request_(std::move(connector_request)),
28 connector_.reset(new ConnectorImpl(std::move(connector))); 27 client_(client), binding_(this), connector_(std::move(connector)) {
28 if (!connector_) {
29 connector_ = Connector::Create(&pending_connector_request_);
30 } else {
31 DCHECK(pending_connector_request_.is_pending());
32 }
29 33
30 DCHECK(request.is_pending()); 34 DCHECK(request.is_pending());
31 binding_.Bind(std::move(request)); 35 binding_.Bind(std::move(request));
32 } 36 }
33 37
34 ShellConnection::~ShellConnection() {} 38 ShellConnection::~ShellConnection() {}
35 39
36 void ShellConnection::set_initialize_handler(const base::Closure& callback) { 40 void ShellConnection::set_initialize_handler(const base::Closure& callback) {
37 initialize_handler_ = callback; 41 initialize_handler_ = callback;
38 } 42 }
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 // invalid. 124 // invalid.
121 should_run_connection_lost_closure_ = client_->ShellConnectionLost(); 125 should_run_connection_lost_closure_ = client_->ShellConnectionLost();
122 if (should_run_connection_lost_closure_ && 126 if (should_run_connection_lost_closure_ &&
123 !connection_lost_closure_.is_null()) 127 !connection_lost_closure_.is_null())
124 connection_lost_closure_.Run(); 128 connection_lost_closure_.Run();
125 // We don't reset the connector as clients may have taken a raw pointer to it. 129 // We don't reset the connector as clients may have taken a raw pointer to it.
126 // Connect() will return nullptr if they try to connect to anything. 130 // Connect() will return nullptr if they try to connect to anything.
127 } 131 }
128 132
129 } // namespace shell 133 } // namespace shell
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698