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

Side by Side Diff: mojo/shell/public/cpp/lib/shell_connection.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
« no previous file with comments | « mojo/shell/public/cpp/lib/shell_client.cc ('k') | mojo/shell/public/cpp/lib/shell_test.cc » ('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/shell/public/cpp/connector.h" 9 #include "mojo/shell/public/cpp/connector.h"
10 #include "mojo/shell/public/cpp/lib/connection_impl.h" 10 #include "mojo/shell/public/cpp/lib/connection_impl.h"
(...skipping 17 matching lines...) Expand all
28 28
29 void ShellConnection::WaitForInitialize() { 29 void ShellConnection::WaitForInitialize() {
30 DCHECK(!connector_); 30 DCHECK(!connector_);
31 binding_.WaitForIncomingMethodCall(); 31 binding_.WaitForIncomingMethodCall();
32 } 32 }
33 33
34 //////////////////////////////////////////////////////////////////////////////// 34 ////////////////////////////////////////////////////////////////////////////////
35 // ShellConnection, shell::mojom::ShellClient implementation: 35 // ShellConnection, shell::mojom::ShellClient implementation:
36 36
37 void ShellConnection::Initialize(shell::mojom::ConnectorPtr connector, 37 void ShellConnection::Initialize(shell::mojom::ConnectorPtr connector,
38 const String& name, 38 shell::mojom::IdentityPtr identity,
39 const String& user_id,
40 uint32_t id) { 39 uint32_t id) {
41 connector_.reset(new ConnectorImpl(std::move(connector))); 40 connector_.reset(new ConnectorImpl(std::move(connector)));
42 binding_.set_connection_error_handler( 41 binding_.set_connection_error_handler(
43 base::Bind(&ShellConnection::OnConnectionError, 42 base::Bind(&ShellConnection::OnConnectionError,
44 weak_factory_.GetWeakPtr())); 43 weak_factory_.GetWeakPtr()));
45 client_->Initialize(connector_.get(), name, user_id, id); 44 client_->Initialize(connector_.get(), identity.To<Identity>(), id);
46 } 45 }
47 46
48 void ShellConnection::AcceptConnection( 47 void ShellConnection::AcceptConnection(
49 const String& requestor_name, 48 shell::mojom::IdentityPtr source,
50 const String& requestor_user_id, 49 uint32_t source_id,
51 uint32_t requestor_id,
52 shell::mojom::InterfaceProviderRequest local_interfaces, 50 shell::mojom::InterfaceProviderRequest local_interfaces,
53 shell::mojom::InterfaceProviderPtr remote_interfaces, 51 shell::mojom::InterfaceProviderPtr remote_interfaces,
54 Array<String> allowed_interfaces, 52 Array<String> allowed_interfaces,
55 const String& name) { 53 const String& name) {
56 scoped_ptr<Connection> registry(new internal::ConnectionImpl( 54 scoped_ptr<Connection> registry(new internal::ConnectionImpl(
57 name, requestor_name, requestor_id, requestor_user_id, 55 name, source.To<Identity>(), source_id, std::move(remote_interfaces),
58 std::move(remote_interfaces), std::move(local_interfaces), 56 std::move(local_interfaces),
59 allowed_interfaces.To<std::set<std::string>>(), 57 allowed_interfaces.To<std::set<std::string>>(),
60 Connection::State::CONNECTED)); 58 Connection::State::CONNECTED));
61 if (!client_->AcceptConnection(registry.get())) 59 if (!client_->AcceptConnection(registry.get()))
62 return; 60 return;
63 61
64 // TODO(beng): it appears we never prune this list. We should, when the 62 // TODO(beng): it appears we never prune this list. We should, when the
65 // connection's remote service provider pipe breaks. 63 // connection's remote service provider pipe breaks.
66 incoming_connections_.push_back(std::move(registry)); 64 incoming_connections_.push_back(std::move(registry));
67 } 65 }
68 66
69 //////////////////////////////////////////////////////////////////////////////// 67 ////////////////////////////////////////////////////////////////////////////////
70 // ShellConnection, private: 68 // ShellConnection, private:
71 69
72 void ShellConnection::OnConnectionError() { 70 void ShellConnection::OnConnectionError() {
73 // Note that the ShellClient doesn't technically have to quit now, it may live 71 // Note that the ShellClient doesn't technically have to quit now, it may live
74 // on to service existing connections. All existing Connectors however are 72 // on to service existing connections. All existing Connectors however are
75 // invalid. 73 // invalid.
76 client_->ShellConnectionLost(); 74 client_->ShellConnectionLost();
77 // We don't reset the connector as clients may have taken a raw pointer to it. 75 // We don't reset the connector as clients may have taken a raw pointer to it.
78 // Connect() will return nullptr if they try to connect to anything. 76 // Connect() will return nullptr if they try to connect to anything.
79 } 77 }
80 78
81 } // namespace mojo 79 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/shell/public/cpp/lib/shell_client.cc ('k') | mojo/shell/public/cpp/lib/shell_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698