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.h" | 5 #include "components/arc/arc_bridge_service.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 | 170 |
171 void ArcBridgeService::CloseInputChannel() { | 171 void ArcBridgeService::CloseInputChannel() { |
172 DCHECK(CalledOnValidThread()); | 172 DCHECK(CalledOnValidThread()); |
173 if (!input_ptr_) | 173 if (!input_ptr_) |
174 return; | 174 return; |
175 | 175 |
176 input_ptr_.reset(); | 176 input_ptr_.reset(); |
177 FOR_EACH_OBSERVER(Observer, observer_list(), OnInputInstanceClosed()); | 177 FOR_EACH_OBSERVER(Observer, observer_list(), OnInputInstanceClosed()); |
178 } | 178 } |
179 | 179 |
| 180 void ArcBridgeService::OnNetInstanceReady(NetInstancePtr net_ptr) { |
| 181 DCHECK(CalledOnValidThread()); |
| 182 temporary_net_ptr_ = std::move(net_ptr); |
| 183 temporary_net_ptr_.QueryVersion(base::Bind( |
| 184 &ArcBridgeService::OnNetVersionReady, weak_factory_.GetWeakPtr())); |
| 185 } |
| 186 |
| 187 void ArcBridgeService::OnNetVersionReady(int32_t version) { |
| 188 DCHECK(CalledOnValidThread()); |
| 189 net_ptr_ = std::move(temporary_net_ptr_); |
| 190 net_ptr_.set_connection_error_handler(base::Bind( |
| 191 &ArcBridgeService::CloseNetChannel, weak_factory_.GetWeakPtr())); |
| 192 FOR_EACH_OBSERVER(Observer, observer_list(), OnNetInstanceReady()); |
| 193 } |
| 194 |
| 195 void ArcBridgeService::CloseNetChannel() { |
| 196 DCHECK(CalledOnValidThread()); |
| 197 if (!net_ptr_) |
| 198 return; |
| 199 |
| 200 net_ptr_.reset(); |
| 201 FOR_EACH_OBSERVER(Observer, observer_list(), OnNetInstanceClosed()); |
| 202 } |
| 203 |
180 void ArcBridgeService::OnNotificationsInstanceReady( | 204 void ArcBridgeService::OnNotificationsInstanceReady( |
181 NotificationsInstancePtr notifications_ptr) { | 205 NotificationsInstancePtr notifications_ptr) { |
182 DCHECK(CalledOnValidThread()); | 206 DCHECK(CalledOnValidThread()); |
183 temporary_notifications_ptr_ = std::move(notifications_ptr); | 207 temporary_notifications_ptr_ = std::move(notifications_ptr); |
184 temporary_notifications_ptr_.QueryVersion( | 208 temporary_notifications_ptr_.QueryVersion( |
185 base::Bind(&ArcBridgeService::OnNotificationsVersionReady, | 209 base::Bind(&ArcBridgeService::OnNotificationsVersionReady, |
186 weak_factory_.GetWeakPtr())); | 210 weak_factory_.GetWeakPtr())); |
187 } | 211 } |
188 | 212 |
189 void ArcBridgeService::OnNotificationsVersionReady(int32_t version) { | 213 void ArcBridgeService::OnNotificationsVersionReady(int32_t version) { |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
329 CloseImeChannel(); | 353 CloseImeChannel(); |
330 CloseInputChannel(); | 354 CloseInputChannel(); |
331 CloseNotificationsChannel(); | 355 CloseNotificationsChannel(); |
332 ClosePowerChannel(); | 356 ClosePowerChannel(); |
333 CloseProcessChannel(); | 357 CloseProcessChannel(); |
334 CloseSettingsChannel(); | 358 CloseSettingsChannel(); |
335 CloseVideoChannel(); | 359 CloseVideoChannel(); |
336 } | 360 } |
337 | 361 |
338 } // namespace arc | 362 } // namespace arc |
OLD | NEW |