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

Side by Side Diff: mojo/shell/public/cpp/lib/shell_connection.cc

Issue 1801963002: Change primordial pipes to ShellClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase onto catalog CL Created 4 years, 9 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
« no previous file with comments | « mojo/shell/public/cpp/lib/connector_impl.cc ('k') | mojo/shell/public/cpp/names.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "mojo/public/cpp/bindings/interface_ptr.h" 8 #include "mojo/public/cpp/bindings/interface_ptr.h"
9 #include "mojo/public/cpp/bindings/interface_request.h" 9 #include "mojo/public/cpp/bindings/interface_request.h"
10 #include "mojo/shell/public/cpp/capabilities.h" 10 #include "mojo/shell/public/cpp/capabilities.h"
11 #include "mojo/shell/public/cpp/connector.h" 11 #include "mojo/shell/public/cpp/connector.h"
12 #include "mojo/shell/public/cpp/lib/connection_impl.h" 12 #include "mojo/shell/public/cpp/lib/connection_impl.h"
13 #include "mojo/shell/public/cpp/lib/connector_impl.h" 13 #include "mojo/shell/public/cpp/lib/connector_impl.h"
14 #include "mojo/shell/public/cpp/shell_client.h" 14 #include "mojo/shell/public/cpp/shell_client.h"
15 #include "mojo/shell/public/cpp/shell_connection.h" 15 #include "mojo/shell/public/cpp/shell_connection.h"
16 16
17 namespace mojo { 17 namespace mojo {
18 18
19 //////////////////////////////////////////////////////////////////////////////// 19 ////////////////////////////////////////////////////////////////////////////////
20 // ShellConnection, public: 20 // ShellConnection, public:
21 21
22 ShellConnection::ShellConnection(mojo::ShellClient* client)
23 : ShellConnection(client, nullptr) {}
24
25 ShellConnection::ShellConnection(mojo::ShellClient* client, 22 ShellConnection::ShellConnection(mojo::ShellClient* client,
26 shell::mojom::ShellClientRequest request) 23 shell::mojom::ShellClientRequest request)
27 : client_(client), binding_(this) { 24 : client_(client), binding_(this) {
28 shell::mojom::ConnectorPtr connector; 25 shell::mojom::ConnectorPtr connector;
29 pending_connector_request_ = GetProxy(&connector); 26 pending_connector_request_ = GetProxy(&connector);
30 connector_.reset(new ConnectorImpl(std::move(connector))); 27 connector_.reset(new ConnectorImpl(std::move(connector)));
31 28
32 if (request.is_pending()) 29 DCHECK(request.is_pending());
33 BindToRequest(std::move(request)); 30 binding_.Bind(std::move(request));
34 } 31 }
35 32
36 ShellConnection::~ShellConnection() {} 33 ShellConnection::~ShellConnection() {}
37 34
38 void ShellConnection::BindToRequest(shell::mojom::ShellClientRequest request) {
39 DCHECK(!binding_.is_bound());
40 binding_.Bind(std::move(request));
41 }
42
43 void ShellConnection::SetAppTestConnectorForTesting( 35 void ShellConnection::SetAppTestConnectorForTesting(
44 shell::mojom::ConnectorPtr connector) { 36 shell::mojom::ConnectorPtr connector) {
45 pending_connector_request_ = nullptr; 37 pending_connector_request_ = nullptr;
46 connector_.reset(new ConnectorImpl(std::move(connector))); 38 connector_.reset(new ConnectorImpl(std::move(connector)));
47 } 39 }
48 40
49 //////////////////////////////////////////////////////////////////////////////// 41 ////////////////////////////////////////////////////////////////////////////////
50 // ShellConnection, shell::mojom::ShellClient implementation: 42 // ShellConnection, shell::mojom::ShellClient implementation:
51 43
52 void ShellConnection::Initialize(shell::mojom::IdentityPtr identity, 44 void ShellConnection::Initialize(shell::mojom::IdentityPtr identity,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 void ShellConnection::OnConnectionError() { 78 void ShellConnection::OnConnectionError() {
87 // Note that the ShellClient doesn't technically have to quit now, it may live 79 // Note that the ShellClient doesn't technically have to quit now, it may live
88 // on to service existing connections. All existing Connectors however are 80 // on to service existing connections. All existing Connectors however are
89 // invalid. 81 // invalid.
90 client_->ShellConnectionLost(); 82 client_->ShellConnectionLost();
91 // We don't reset the connector as clients may have taken a raw pointer to it. 83 // We don't reset the connector as clients may have taken a raw pointer to it.
92 // Connect() will return nullptr if they try to connect to anything. 84 // Connect() will return nullptr if they try to connect to anything.
93 } 85 }
94 86
95 } // namespace mojo 87 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/public/cpp/lib/connector_impl.cc ('k') | mojo/shell/public/cpp/names.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698