OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/arc/arc_bridge_service_impl.h" | 5 #include "components/arc/arc_bridge_service_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 DCHECK(CalledOnValidThread()); | 94 DCHECK(CalledOnValidThread()); |
95 if (state() != State::CONNECTING) { | 95 if (state() != State::CONNECTING) { |
96 VLOG(1) << "StopInstance() called while connecting"; | 96 VLOG(1) << "StopInstance() called while connecting"; |
97 return; | 97 return; |
98 } | 98 } |
99 | 99 |
100 instance_ptr_ = std::move(instance); | 100 instance_ptr_ = std::move(instance); |
101 instance_ptr_.set_connection_error_handler(base::Bind( | 101 instance_ptr_.set_connection_error_handler(base::Bind( |
102 &ArcBridgeServiceImpl::OnChannelClosed, weak_factory_.GetWeakPtr())); | 102 &ArcBridgeServiceImpl::OnChannelClosed, weak_factory_.GetWeakPtr())); |
103 | 103 |
104 ArcBridgeHostPtr host; | 104 instance_ptr_->Init(binding_.CreateInterfacePtrAndBind()); |
105 binding_.Bind(GetProxy(&host)); | |
106 instance_ptr_->Init(std::move(host)); | |
107 | 105 |
108 SetState(State::READY); | 106 SetState(State::READY); |
109 } | 107 } |
110 | 108 |
111 void ArcBridgeServiceImpl::OnStopped() { | 109 void ArcBridgeServiceImpl::OnStopped() { |
112 DCHECK(CalledOnValidThread()); | 110 DCHECK(CalledOnValidThread()); |
113 SetState(State::STOPPED); | 111 SetState(State::STOPPED); |
114 if (reconnect_) { | 112 if (reconnect_) { |
115 // There was a previous invocation and it crashed for some reason. Try | 113 // There was a previous invocation and it crashed for some reason. Try |
116 // starting the container again. | 114 // starting the container again. |
117 reconnect_ = false; | 115 reconnect_ = false; |
118 PrerequisitesChanged(); | 116 PrerequisitesChanged(); |
119 } | 117 } |
120 } | 118 } |
121 | 119 |
122 void ArcBridgeServiceImpl::OnChannelClosed() { | 120 void ArcBridgeServiceImpl::OnChannelClosed() { |
123 DCHECK(CalledOnValidThread()); | 121 DCHECK(CalledOnValidThread()); |
124 if (state() == State::STOPPED || state() == State::STOPPING) { | 122 if (state() == State::STOPPED || state() == State::STOPPING) { |
125 // This will happen when the instance is shut down. Ignore that case. | 123 // This will happen when the instance is shut down. Ignore that case. |
126 return; | 124 return; |
127 } | 125 } |
128 VLOG(1) << "Mojo connection lost"; | 126 VLOG(1) << "Mojo connection lost"; |
129 CloseAllChannels(); | 127 CloseAllChannels(); |
130 reconnect_ = true; | 128 reconnect_ = true; |
131 StopInstance(); | 129 StopInstance(); |
132 } | 130 } |
133 | 131 |
134 } // namespace arc | 132 } // namespace arc |
OLD | NEW |