| OLD | NEW |
| 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 "services/service_manager/public/cpp/lib/connector_impl.h" | 5 #include "services/service_manager/public/cpp/lib/connector_impl.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "services/service_manager/public/cpp/identity.h" | 8 #include "services/service_manager/public/cpp/identity.h" |
| 9 #include "services/service_manager/public/cpp/lib/connection_impl.h" | 9 #include "services/service_manager/public/cpp/lib/connection_impl.h" |
| 10 | 10 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 mojom::ConnectorRequest request = GetProxy(&connector); | 92 mojom::ConnectorRequest request = GetProxy(&connector); |
| 93 connector_->Clone(std::move(request)); | 93 connector_->Clone(std::move(request)); |
| 94 return base::MakeUnique<ConnectorImpl>(connector.PassInterface()); | 94 return base::MakeUnique<ConnectorImpl>(connector.PassInterface()); |
| 95 } | 95 } |
| 96 | 96 |
| 97 bool ConnectorImpl::BindIfNecessary() { | 97 bool ConnectorImpl::BindIfNecessary() { |
| 98 // Bind this object to the current thread the first time it is used to | 98 // Bind this object to the current thread the first time it is used to |
| 99 // connect. | 99 // connect. |
| 100 if (!connector_.is_bound()) { | 100 if (!connector_.is_bound()) { |
| 101 if (!unbound_state_.is_valid()) { | 101 if (!unbound_state_.is_valid()) { |
| 102 // It's possible to get here when the link to the shell has been severed | 102 // It's possible to get here when the link to the service manager has been |
| 103 // severed |
| 103 // (and so the connector pipe has been closed) but the app has chosen not | 104 // (and so the connector pipe has been closed) but the app has chosen not |
| 104 // to quit. | 105 // to quit. |
| 105 return false; | 106 return false; |
| 106 } | 107 } |
| 107 | 108 |
| 108 // Bind the ThreadChecker to this thread. | 109 // Bind the ThreadChecker to this thread. |
| 109 DCHECK(thread_checker_.CalledOnValidThread()); | 110 DCHECK(thread_checker_.CalledOnValidThread()); |
| 110 | 111 |
| 111 connector_.Bind(std::move(unbound_state_)); | 112 connector_.Bind(std::move(unbound_state_)); |
| 112 connector_.set_connection_error_handler( | 113 connector_.set_connection_error_handler( |
| 113 base::Bind(&ConnectorImpl::OnConnectionError, base::Unretained(this))); | 114 base::Bind(&ConnectorImpl::OnConnectionError, base::Unretained(this))); |
| 114 } | 115 } |
| 115 | 116 |
| 116 return true; | 117 return true; |
| 117 } | 118 } |
| 118 | 119 |
| 119 std::unique_ptr<Connector> Connector::Create(mojom::ConnectorRequest* request) { | 120 std::unique_ptr<Connector> Connector::Create(mojom::ConnectorRequest* request) { |
| 120 mojom::ConnectorPtr proxy; | 121 mojom::ConnectorPtr proxy; |
| 121 *request = mojo::GetProxy(&proxy); | 122 *request = mojo::GetProxy(&proxy); |
| 122 return base::MakeUnique<ConnectorImpl>(proxy.PassInterface()); | 123 return base::MakeUnique<ConnectorImpl>(proxy.PassInterface()); |
| 123 } | 124 } |
| 124 | 125 |
| 125 } // namespace service_manager | 126 } // namespace service_manager |
| OLD | NEW |