| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "remoting/host/daemon_process.h" | 5 #include "remoting/host/daemon_process.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 } | 296 } |
| 297 } | 297 } |
| 298 | 298 |
| 299 bool DaemonProcess::WasTerminalIdAllocated(int terminal_id) { | 299 bool DaemonProcess::WasTerminalIdAllocated(int terminal_id) { |
| 300 return terminal_id < next_terminal_id_; | 300 return terminal_id < next_terminal_id_; |
| 301 } | 301 } |
| 302 | 302 |
| 303 void DaemonProcess::OnAccessDenied(const std::string& jid) { | 303 void DaemonProcess::OnAccessDenied(const std::string& jid) { |
| 304 DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 304 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
| 305 | 305 |
| 306 FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, OnAccessDenied(jid)); | 306 for (auto& observer : status_observers_) |
| 307 observer.OnAccessDenied(jid); |
| 307 } | 308 } |
| 308 | 309 |
| 309 void DaemonProcess::OnClientAuthenticated(const std::string& jid) { | 310 void DaemonProcess::OnClientAuthenticated(const std::string& jid) { |
| 310 DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 311 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
| 311 | 312 |
| 312 FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, | 313 for (auto& observer : status_observers_) |
| 313 OnClientAuthenticated(jid)); | 314 observer.OnClientAuthenticated(jid); |
| 314 } | 315 } |
| 315 | 316 |
| 316 void DaemonProcess::OnClientConnected(const std::string& jid) { | 317 void DaemonProcess::OnClientConnected(const std::string& jid) { |
| 317 DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 318 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
| 318 | 319 |
| 319 FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, | 320 for (auto& observer : status_observers_) |
| 320 OnClientConnected(jid)); | 321 observer.OnClientConnected(jid); |
| 321 } | 322 } |
| 322 | 323 |
| 323 void DaemonProcess::OnClientDisconnected(const std::string& jid) { | 324 void DaemonProcess::OnClientDisconnected(const std::string& jid) { |
| 324 DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 325 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
| 325 | 326 |
| 326 FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, | 327 for (auto& observer : status_observers_) |
| 327 OnClientDisconnected(jid)); | 328 observer.OnClientDisconnected(jid); |
| 328 } | 329 } |
| 329 | 330 |
| 330 void DaemonProcess::OnClientRouteChange(const std::string& jid, | 331 void DaemonProcess::OnClientRouteChange(const std::string& jid, |
| 331 const std::string& channel_name, | 332 const std::string& channel_name, |
| 332 const SerializedTransportRoute& route) { | 333 const SerializedTransportRoute& route) { |
| 333 DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 334 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
| 334 | 335 |
| 335 protocol::TransportRoute parsed_route; | 336 protocol::TransportRoute parsed_route; |
| 336 parsed_route.type = route.type; | 337 parsed_route.type = route.type; |
| 337 | 338 |
| 338 net::IPAddress remote_ip(route.remote_ip); | 339 net::IPAddress remote_ip(route.remote_ip); |
| 339 CHECK(remote_ip.empty() || remote_ip.IsValid()); | 340 CHECK(remote_ip.empty() || remote_ip.IsValid()); |
| 340 parsed_route.remote_address = net::IPEndPoint(remote_ip, route.remote_port); | 341 parsed_route.remote_address = net::IPEndPoint(remote_ip, route.remote_port); |
| 341 | 342 |
| 342 net::IPAddress local_ip(route.local_ip); | 343 net::IPAddress local_ip(route.local_ip); |
| 343 CHECK(local_ip.empty() || local_ip.IsValid()); | 344 CHECK(local_ip.empty() || local_ip.IsValid()); |
| 344 parsed_route.local_address = net::IPEndPoint(local_ip, route.local_port); | 345 parsed_route.local_address = net::IPEndPoint(local_ip, route.local_port); |
| 345 | 346 |
| 346 FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, | 347 for (auto& observer : status_observers_) |
| 347 OnClientRouteChange(jid, channel_name, parsed_route)); | 348 observer.OnClientRouteChange(jid, channel_name, parsed_route); |
| 348 } | 349 } |
| 349 | 350 |
| 350 void DaemonProcess::OnHostStarted(const std::string& xmpp_login) { | 351 void DaemonProcess::OnHostStarted(const std::string& xmpp_login) { |
| 351 DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 352 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
| 352 | 353 |
| 353 FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, OnStart(xmpp_login)); | 354 for (auto& observer : status_observers_) |
| 355 observer.OnStart(xmpp_login); |
| 354 } | 356 } |
| 355 | 357 |
| 356 void DaemonProcess::OnHostShutdown() { | 358 void DaemonProcess::OnHostShutdown() { |
| 357 DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 359 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
| 358 | 360 |
| 359 FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, OnShutdown()); | 361 for (auto& observer : status_observers_) |
| 362 observer.OnShutdown(); |
| 360 } | 363 } |
| 361 | 364 |
| 362 void DaemonProcess::DeleteAllDesktopSessions() { | 365 void DaemonProcess::DeleteAllDesktopSessions() { |
| 363 while (!desktop_sessions_.empty()) { | 366 while (!desktop_sessions_.empty()) { |
| 364 delete desktop_sessions_.front(); | 367 delete desktop_sessions_.front(); |
| 365 desktop_sessions_.pop_front(); | 368 desktop_sessions_.pop_front(); |
| 366 } | 369 } |
| 367 } | 370 } |
| 368 | 371 |
| 369 } // namespace remoting | 372 } // namespace remoting |
| OLD | NEW |