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 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
333 DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 333 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
334 | 334 |
335 // Validate |route|. | 335 // Validate |route|. |
336 if (route.type != protocol::TransportRoute::DIRECT && | 336 if (route.type != protocol::TransportRoute::DIRECT && |
337 route.type != protocol::TransportRoute::STUN && | 337 route.type != protocol::TransportRoute::STUN && |
338 route.type != protocol::TransportRoute::RELAY) { | 338 route.type != protocol::TransportRoute::RELAY) { |
339 LOG(ERROR) << "An invalid RouteType " << route.type << " passed."; | 339 LOG(ERROR) << "An invalid RouteType " << route.type << " passed."; |
340 CrashNetworkProcess(FROM_HERE); | 340 CrashNetworkProcess(FROM_HERE); |
341 return; | 341 return; |
342 } | 342 } |
343 if (route.remote_address.size() != net::kIPv4AddressSize && | 343 net::IPAddress remote_address(route.remote_address); |
344 route.remote_address.size() != net::kIPv6AddressSize) { | 344 if (!remote_address.IsValid()) { |
345 LOG(ERROR) << "An invalid net::IPAddressNumber size " | 345 LOG(ERROR) << "An invalid IPAddress size " << remote_address.size() |
346 << route.remote_address.size() << " passed."; | 346 << " passed."; |
347 CrashNetworkProcess(FROM_HERE); | 347 CrashNetworkProcess(FROM_HERE); |
348 return; | 348 return; |
349 } | 349 } |
350 if (route.local_address.size() != net::kIPv4AddressSize && | 350 net::IPAddress local_address(route.local_address); |
351 route.local_address.size() != net::kIPv6AddressSize) { | 351 if (!local_address.IsValid()) { |
352 LOG(ERROR) << "An invalid net::IPAddressNumber size " | 352 LOG(ERROR) << "An invalid IPAddress size " << local_address.size() |
353 << route.local_address.size() << " passed."; | 353 << " passed."; |
354 CrashNetworkProcess(FROM_HERE); | 354 CrashNetworkProcess(FROM_HERE); |
355 return; | 355 return; |
356 } | 356 } |
357 | 357 |
358 protocol::TransportRoute parsed_route; | 358 protocol::TransportRoute parsed_route; |
359 parsed_route.type = | 359 parsed_route.type = |
360 static_cast<protocol::TransportRoute::RouteType>(route.type); | 360 static_cast<protocol::TransportRoute::RouteType>(route.type); |
dcheng
2016/04/04 19:13:53
Unrelated, but IPC_STRUCT_MEMBER for type should p
martijnc
2016/04/05 17:02:35
Done.
| |
361 parsed_route.remote_address = | 361 parsed_route.remote_address = |
362 net::IPEndPoint(route.remote_address, route.remote_port); | 362 net::IPEndPoint(remote_address, route.remote_port); |
363 parsed_route.local_address = | 363 parsed_route.local_address = net::IPEndPoint(local_address, route.local_port); |
364 net::IPEndPoint(route.local_address, route.local_port); | |
365 FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, | 364 FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, |
366 OnClientRouteChange(jid, channel_name, parsed_route)); | 365 OnClientRouteChange(jid, channel_name, parsed_route)); |
367 } | 366 } |
368 | 367 |
369 void DaemonProcess::OnHostStarted(const std::string& xmpp_login) { | 368 void DaemonProcess::OnHostStarted(const std::string& xmpp_login) { |
370 DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 369 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
371 | 370 |
372 FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, OnStart(xmpp_login)); | 371 FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, OnStart(xmpp_login)); |
373 } | 372 } |
374 | 373 |
375 void DaemonProcess::OnHostShutdown() { | 374 void DaemonProcess::OnHostShutdown() { |
376 DCHECK(caller_task_runner()->BelongsToCurrentThread()); | 375 DCHECK(caller_task_runner()->BelongsToCurrentThread()); |
377 | 376 |
378 FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, OnShutdown()); | 377 FOR_EACH_OBSERVER(HostStatusObserver, status_observers_, OnShutdown()); |
379 } | 378 } |
380 | 379 |
381 void DaemonProcess::DeleteAllDesktopSessions() { | 380 void DaemonProcess::DeleteAllDesktopSessions() { |
382 while (!desktop_sessions_.empty()) { | 381 while (!desktop_sessions_.empty()) { |
383 delete desktop_sessions_.front(); | 382 delete desktop_sessions_.front(); |
384 desktop_sessions_.pop_front(); | 383 desktop_sessions_.pop_front(); |
385 } | 384 } |
386 } | 385 } |
387 | 386 |
388 } // namespace remoting | 387 } // namespace remoting |
OLD | NEW |