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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 void ArcBridgeServiceImpl::PrerequisitesChanged() { | 71 void ArcBridgeServiceImpl::PrerequisitesChanged() { |
72 DCHECK(CalledOnValidThread()); | 72 DCHECK(CalledOnValidThread()); |
73 VLOG(1) << "Prerequisites changed. " | 73 VLOG(1) << "Prerequisites changed. " |
74 << "state=" << static_cast<uint32_t>(state()) | 74 << "state=" << static_cast<uint32_t>(state()) |
75 << ", available=" << available() | 75 << ", available=" << available() |
76 << ", session_started=" << session_started_; | 76 << ", session_started=" << session_started_; |
77 if (state() == State::STOPPED) { | 77 if (state() == State::STOPPED) { |
78 if (!available() || !session_started_) | 78 if (!available() || !session_started_) |
79 return; | 79 return; |
80 VLOG(0) << "Prerequisites met, starting ARC"; | 80 VLOG(0) << "Prerequisites met, starting ARC"; |
| 81 SetStopReason(StopReason::SHUTDOWN); |
81 SetState(State::CONNECTING); | 82 SetState(State::CONNECTING); |
82 bootstrap_->Start(); | 83 bootstrap_->Start(); |
83 } else { | 84 } else { |
84 if (available() && session_started_) | 85 if (available() && session_started_) |
85 return; | 86 return; |
86 VLOG(0) << "Prerequisites stopped being met, stopping ARC"; | 87 VLOG(0) << "Prerequisites stopped being met, stopping ARC"; |
87 StopInstance(); | 88 StopInstance(); |
88 } | 89 } |
89 } | 90 } |
90 | 91 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 | 130 |
130 instance_ptr_->Init(binding_.CreateInterfacePtrAndBind()); | 131 instance_ptr_->Init(binding_.CreateInterfacePtrAndBind()); |
131 | 132 |
132 // The container can be considered to have been successfully launched, so | 133 // The container can be considered to have been successfully launched, so |
133 // restart if the connection goes down without being requested. | 134 // restart if the connection goes down without being requested. |
134 reconnect_ = true; | 135 reconnect_ = true; |
135 VLOG(0) << "ARC ready"; | 136 VLOG(0) << "ARC ready"; |
136 SetState(State::READY); | 137 SetState(State::READY); |
137 } | 138 } |
138 | 139 |
139 void ArcBridgeServiceImpl::OnStopped() { | 140 void ArcBridgeServiceImpl::OnStopped(StopReason stop_reason) { |
140 DCHECK(CalledOnValidThread()); | 141 DCHECK(CalledOnValidThread()); |
| 142 SetStopReason(stop_reason); |
141 SetState(State::STOPPED); | 143 SetState(State::STOPPED); |
142 VLOG(0) << "ARC stopped"; | 144 VLOG(0) << "ARC stopped"; |
143 if (reconnect_) { | 145 if (reconnect_) { |
144 // There was a previous invocation and it crashed for some reason. Try | 146 // There was a previous invocation and it crashed for some reason. Try |
145 // starting the container again. | 147 // starting the container again. |
146 reconnect_ = false; | 148 reconnect_ = false; |
147 VLOG(0) << "ARC reconnecting"; | 149 VLOG(0) << "ARC reconnecting"; |
148 if (use_delay_before_reconnecting_) { | 150 if (use_delay_before_reconnecting_) { |
149 // Instead of immediately trying to restart the container, give it some | 151 // Instead of immediately trying to restart the container, give it some |
150 // time to finish tearing down in case it is still in the process of | 152 // time to finish tearing down in case it is still in the process of |
(...skipping 16 matching lines...) Expand all Loading... |
167 return; | 169 return; |
168 } | 170 } |
169 VLOG(1) << "Mojo connection lost"; | 171 VLOG(1) << "Mojo connection lost"; |
170 instance_ptr_.reset(); | 172 instance_ptr_.reset(); |
171 if (binding_.is_bound()) | 173 if (binding_.is_bound()) |
172 binding_.Close(); | 174 binding_.Close(); |
173 CloseAllChannels(); | 175 CloseAllChannels(); |
174 } | 176 } |
175 | 177 |
176 } // namespace arc | 178 } // namespace arc |
OLD | NEW |