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

Side by Side Diff: mojo/shell/tests/connect/connect_test_package.cc

Issue 1769163002: Add a instance groups to Connect(), and introduce an Identity struct. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 title_(title), 43 title_(title),
44 request_(std::move(request)) { 44 request_(std::move(request)) {
45 Start(); 45 Start();
46 } 46 }
47 ~ProvidedShellClient() override { 47 ~ProvidedShellClient() override {
48 Join(); 48 Join();
49 } 49 }
50 50
51 private: 51 private:
52 // mojo::ShellClient: 52 // mojo::ShellClient:
53 void Initialize(Connector* connector, const std::string& name, 53 void Initialize(Connector* connector, const Identity& identity,
54 const std::string& user_id, uint32_t id) override { 54 uint32_t id) override {
55 name_ = name; 55 name_ = identity.name();
56 userid_ = identity.user_id();
56 id_ = id; 57 id_ = id;
57 userid_ = user_id;
58 bindings_.set_connection_error_handler( 58 bindings_.set_connection_error_handler(
59 base::Bind(&ProvidedShellClient::OnConnectionError, 59 base::Bind(&ProvidedShellClient::OnConnectionError,
60 base::Unretained(this))); 60 base::Unretained(this)));
61 } 61 }
62 bool AcceptConnection(Connection* connection) override { 62 bool AcceptConnection(Connection* connection) override {
63 connection->AddInterface<test::mojom::ConnectTestService>(this); 63 connection->AddInterface<test::mojom::ConnectTestService>(this);
64 connection->AddInterface<test::mojom::BlockedInterface>(this); 64 connection->AddInterface<test::mojom::BlockedInterface>(this);
65 65
66 uint32_t remote_id = connection->GetRemoteInstanceID(); 66 uint32_t remote_id = connection->GetRemoteInstanceID();
67 test::mojom::ConnectionStatePtr state(test::mojom::ConnectionState::New()); 67 test::mojom::ConnectionStatePtr state(test::mojom::ConnectionState::New());
68 state->connection_local_name = connection->GetConnectionName(); 68 state->connection_local_name = connection->GetConnectionName();
69 state->connection_remote_name = connection->GetRemoteApplicationName(); 69 state->connection_remote_name = connection->GetRemoteIdentity().name();
70 state->connection_remote_userid = connection->GetRemoteUserID(); 70 state->connection_remote_userid = connection->GetRemoteIdentity().user_id();
71 state->connection_remote_id = remote_id; 71 state->connection_remote_id = remote_id;
72 state->initialize_local_name = name_; 72 state->initialize_local_name = name_;
73 state->initialize_id = id_; 73 state->initialize_id = id_;
74 state->initialize_userid = userid_; 74 state->initialize_userid = userid_;
75 connection->GetInterface(&caller_); 75 connection->GetInterface(&caller_);
76 caller_->ConnectionAccepted(std::move(state)); 76 caller_->ConnectionAccepted(std::move(state));
77 77
78 return true; 78 return true;
79 } 79 }
80 80
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 public InterfaceFactory<mojom::ShellClientFactory>, 129 public InterfaceFactory<mojom::ShellClientFactory>,
130 public InterfaceFactory<test::mojom::ConnectTestService>, 130 public InterfaceFactory<test::mojom::ConnectTestService>,
131 public mojom::ShellClientFactory, 131 public mojom::ShellClientFactory,
132 public test::mojom::ConnectTestService { 132 public test::mojom::ConnectTestService {
133 public: 133 public:
134 ConnectTestShellClient() {} 134 ConnectTestShellClient() {}
135 ~ConnectTestShellClient() override {} 135 ~ConnectTestShellClient() override {}
136 136
137 private: 137 private:
138 // mojo::ShellClient: 138 // mojo::ShellClient:
139 void Initialize(Connector* connector, const std::string& name, 139 void Initialize(Connector* connector, const Identity& identity,
140 const std::string& user_id, uint32_t id) override { 140 uint32_t id) override {
141 bindings_.set_connection_error_handler( 141 bindings_.set_connection_error_handler(
142 base::Bind(&ConnectTestShellClient::OnConnectionError, 142 base::Bind(&ConnectTestShellClient::OnConnectionError,
143 base::Unretained(this))); 143 base::Unretained(this)));
144 } 144 }
145 bool AcceptConnection(Connection* connection) override { 145 bool AcceptConnection(Connection* connection) override {
146 connection->AddInterface<ShellClientFactory>(this); 146 connection->AddInterface<ShellClientFactory>(this);
147 connection->AddInterface<test::mojom::ConnectTestService>(this); 147 connection->AddInterface<test::mojom::ConnectTestService>(this);
148 return true; 148 return true;
149 } 149 }
150 void ShellConnectionLost() override { 150 void ShellConnectionLost() override {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 194
195 } // namespace shell 195 } // namespace shell
196 } // namespace mojo 196 } // namespace mojo
197 197
198 198
199 MojoResult MojoMain(MojoHandle shell_handle) { 199 MojoResult MojoMain(MojoHandle shell_handle) {
200 MojoResult rv = mojo::ApplicationRunner( 200 MojoResult rv = mojo::ApplicationRunner(
201 new mojo::shell::ConnectTestShellClient).Run(shell_handle); 201 new mojo::shell::ConnectTestShellClient).Run(shell_handle);
202 return rv; 202 return rv;
203 } 203 }
OLDNEW
« no previous file with comments | « mojo/shell/tests/connect/connect_test_app.cc ('k') | mojo/shell/tests/connect/connect_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698