OLD | NEW |
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 Loading... |
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 mojo::String& name, | 38 const String& name, |
39 uint32_t id, | 39 const String& user_id, |
40 uint32_t user_id) { | 40 uint32_t id) { |
41 connector_.reset(new ConnectorImpl(std::move(connector))); | 41 connector_.reset(new ConnectorImpl(std::move(connector))); |
42 binding_.set_connection_error_handler( | 42 binding_.set_connection_error_handler( |
43 base::Bind(&ShellConnection::OnConnectionError, | 43 base::Bind(&ShellConnection::OnConnectionError, |
44 weak_factory_.GetWeakPtr())); | 44 weak_factory_.GetWeakPtr())); |
45 client_->Initialize(connector_.get(), name, id, user_id); | 45 client_->Initialize(connector_.get(), name, user_id, id); |
46 } | 46 } |
47 | 47 |
48 void ShellConnection::AcceptConnection( | 48 void ShellConnection::AcceptConnection( |
49 const String& requestor_name, | 49 const String& requestor_name, |
| 50 const String& requestor_user_id, |
50 uint32_t requestor_id, | 51 uint32_t requestor_id, |
51 uint32_t requestor_user_id, | |
52 shell::mojom::InterfaceProviderRequest local_interfaces, | 52 shell::mojom::InterfaceProviderRequest local_interfaces, |
53 shell::mojom::InterfaceProviderPtr remote_interfaces, | 53 shell::mojom::InterfaceProviderPtr remote_interfaces, |
54 Array<String> allowed_interfaces, | 54 Array<String> allowed_interfaces, |
55 const String& name) { | 55 const String& name) { |
56 scoped_ptr<Connection> registry(new internal::ConnectionImpl( | 56 scoped_ptr<Connection> registry(new internal::ConnectionImpl( |
57 name, requestor_name, requestor_id, requestor_user_id, | 57 name, requestor_name, requestor_id, requestor_user_id, |
58 std::move(remote_interfaces), std::move(local_interfaces), | 58 std::move(remote_interfaces), std::move(local_interfaces), |
59 allowed_interfaces.To<std::set<std::string>>())); | 59 allowed_interfaces.To<std::set<std::string>>())); |
60 if (!client_->AcceptConnection(registry.get())) | 60 if (!client_->AcceptConnection(registry.get())) |
61 return; | 61 return; |
62 | 62 |
63 // TODO(beng): it appears we never prune this list. We should, when the | 63 // TODO(beng): it appears we never prune this list. We should, when the |
64 // connection's remote service provider pipe breaks. | 64 // connection's remote service provider pipe breaks. |
65 incoming_connections_.push_back(std::move(registry)); | 65 incoming_connections_.push_back(std::move(registry)); |
66 } | 66 } |
67 | 67 |
68 //////////////////////////////////////////////////////////////////////////////// | 68 //////////////////////////////////////////////////////////////////////////////// |
69 // ShellConnection, private: | 69 // ShellConnection, private: |
70 | 70 |
71 void ShellConnection::OnConnectionError() { | 71 void ShellConnection::OnConnectionError() { |
72 // Note that the ShellClient doesn't technically have to quit now, it may live | 72 // Note that the ShellClient doesn't technically have to quit now, it may live |
73 // on to service existing connections. All existing Connectors however are | 73 // on to service existing connections. All existing Connectors however are |
74 // invalid. | 74 // invalid. |
75 client_->ShellConnectionLost(); | 75 client_->ShellConnectionLost(); |
76 // We don't reset the connector as clients may have taken a raw pointer to it. | 76 // We don't reset the connector as clients may have taken a raw pointer to it. |
77 // Connect() will return nullptr if they try to connect to anything. | 77 // Connect() will return nullptr if they try to connect to anything. |
78 } | 78 } |
79 | 79 |
80 } // namespace mojo | 80 } // namespace mojo |
OLD | NEW |