| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 void ShellConnection::Initialize(mojom::IdentityPtr identity, | 56 void ShellConnection::Initialize(mojom::IdentityPtr identity, |
| 57 uint32_t id, | 57 uint32_t id, |
| 58 const InitializeCallback& callback) { | 58 const InitializeCallback& callback) { |
| 59 identity_ = identity.To<Identity>(); | 59 identity_ = identity.To<Identity>(); |
| 60 if (!initialize_handler_.is_null()) | 60 if (!initialize_handler_.is_null()) |
| 61 initialize_handler_.Run(); | 61 initialize_handler_.Run(); |
| 62 | 62 |
| 63 callback.Run(std::move(pending_connector_request_)); | 63 callback.Run(std::move(pending_connector_request_)); |
| 64 | 64 |
| 65 DCHECK(binding_.is_bound()); | 65 DCHECK(binding_.is_bound()); |
| 66 binding_.set_connection_error_handler([this] { OnConnectionError(); }); | 66 binding_.set_connection_error_handler( |
| 67 base::Bind(&ShellConnection::OnConnectionError, base::Unretained(this))); |
| 67 | 68 |
| 68 client_->Initialize(connector_.get(), identity_, id); | 69 client_->Initialize(connector_.get(), identity_, id); |
| 69 } | 70 } |
| 70 | 71 |
| 71 void ShellConnection::AcceptConnection( | 72 void ShellConnection::AcceptConnection( |
| 72 mojom::IdentityPtr source, | 73 mojom::IdentityPtr source, |
| 73 uint32_t source_id, | 74 uint32_t source_id, |
| 74 mojom::InterfaceProviderRequest local_interfaces, | 75 mojom::InterfaceProviderRequest local_interfaces, |
| 75 mojom::InterfaceProviderPtr remote_interfaces, | 76 mojom::InterfaceProviderPtr remote_interfaces, |
| 76 mojom::CapabilityRequestPtr allowed_capabilities, | 77 mojom::CapabilityRequestPtr allowed_capabilities, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 96 // invalid. | 97 // invalid. |
| 97 should_run_connection_lost_closure_ = client_->ShellConnectionLost(); | 98 should_run_connection_lost_closure_ = client_->ShellConnectionLost(); |
| 98 if (should_run_connection_lost_closure_ && | 99 if (should_run_connection_lost_closure_ && |
| 99 !connection_lost_closure_.is_null()) | 100 !connection_lost_closure_.is_null()) |
| 100 connection_lost_closure_.Run(); | 101 connection_lost_closure_.Run(); |
| 101 // We don't reset the connector as clients may have taken a raw pointer to it. | 102 // We don't reset the connector as clients may have taken a raw pointer to it. |
| 102 // Connect() will return nullptr if they try to connect to anything. | 103 // Connect() will return nullptr if they try to connect to anything. |
| 103 } | 104 } |
| 104 | 105 |
| 105 } // namespace shell | 106 } // namespace shell |
| OLD | NEW |