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 "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" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 pending_connector_request_ = nullptr; | 42 pending_connector_request_ = nullptr; |
43 connector_.reset(new ConnectorImpl(std::move(connector))); | 43 connector_.reset(new ConnectorImpl(std::move(connector))); |
44 } | 44 } |
45 | 45 |
46 //////////////////////////////////////////////////////////////////////////////// | 46 //////////////////////////////////////////////////////////////////////////////// |
47 // ShellConnection, mojom::ShellClient implementation: | 47 // ShellConnection, mojom::ShellClient implementation: |
48 | 48 |
49 void ShellConnection::Initialize(mojom::IdentityPtr identity, | 49 void ShellConnection::Initialize(mojom::IdentityPtr identity, |
50 uint32_t id, | 50 uint32_t id, |
51 const InitializeCallback& callback) { | 51 const InitializeCallback& callback) { |
| 52 identity_ = identity.To<Identity>(); |
52 if (!initialize_handler_.is_null()) | 53 if (!initialize_handler_.is_null()) |
53 initialize_handler_.Run(); | 54 initialize_handler_.Run(); |
54 | 55 |
55 callback.Run(std::move(pending_connector_request_)); | 56 callback.Run(std::move(pending_connector_request_)); |
56 | 57 |
57 DCHECK(binding_.is_bound()); | 58 DCHECK(binding_.is_bound()); |
58 binding_.set_connection_error_handler([this] { OnConnectionError(); }); | 59 binding_.set_connection_error_handler([this] { OnConnectionError(); }); |
59 | 60 |
60 client_->Initialize(connector_.get(), identity.To<Identity>(), id); | 61 client_->Initialize(connector_.get(), identity_, id); |
61 } | 62 } |
62 | 63 |
63 void ShellConnection::AcceptConnection( | 64 void ShellConnection::AcceptConnection( |
64 mojom::IdentityPtr source, | 65 mojom::IdentityPtr source, |
65 uint32_t source_id, | 66 uint32_t source_id, |
66 mojom::InterfaceProviderRequest local_interfaces, | 67 mojom::InterfaceProviderRequest local_interfaces, |
67 mojom::InterfaceProviderPtr remote_interfaces, | 68 mojom::InterfaceProviderPtr remote_interfaces, |
68 mojom::CapabilityRequestPtr allowed_capabilities, | 69 mojom::CapabilityRequestPtr allowed_capabilities, |
69 const mojo::String& name) { | 70 const mojo::String& name) { |
70 std::unique_ptr<Connection> registry(new internal::ConnectionImpl( | 71 std::unique_ptr<Connection> registry(new internal::ConnectionImpl( |
(...skipping 15 matching lines...) Expand all Loading... |
86 // Note that the ShellClient doesn't technically have to quit now, it may live | 87 // Note that the ShellClient doesn't technically have to quit now, it may live |
87 // on to service existing connections. All existing Connectors however are | 88 // on to service existing connections. All existing Connectors however are |
88 // invalid. | 89 // invalid. |
89 if (client_->ShellConnectionLost() && !connection_lost_closure_.is_null()) | 90 if (client_->ShellConnectionLost() && !connection_lost_closure_.is_null()) |
90 connection_lost_closure_.Run(); | 91 connection_lost_closure_.Run(); |
91 // We don't reset the connector as clients may have taken a raw pointer to it. | 92 // 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. | 93 // Connect() will return nullptr if they try to connect to anything. |
93 } | 94 } |
94 | 95 |
95 } // namespace shell | 96 } // namespace shell |
OLD | NEW |