Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Side by Side Diff: remoting/host/daemon_process.cc

Issue 2881673002: Avoid heap allocations in IPAddress (Closed)
Patch Set: Done Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 } 325 }
326 326
327 void DaemonProcess::OnClientRouteChange(const std::string& jid, 327 void DaemonProcess::OnClientRouteChange(const std::string& jid,
328 const std::string& channel_name, 328 const std::string& channel_name,
329 const SerializedTransportRoute& route) { 329 const SerializedTransportRoute& route) {
330 DCHECK(caller_task_runner()->BelongsToCurrentThread()); 330 DCHECK(caller_task_runner()->BelongsToCurrentThread());
331 331
332 protocol::TransportRoute parsed_route; 332 protocol::TransportRoute parsed_route;
333 parsed_route.type = route.type; 333 parsed_route.type = route.type;
334 334
335 net::IPAddress remote_ip(route.remote_ip); 335 net::IPAddress remote_ip(route.remote_ip.data(), route.remote_ip.size());
336 CHECK(remote_ip.empty() || remote_ip.IsValid()); 336 CHECK(remote_ip.empty() || remote_ip.IsValid());
337 parsed_route.remote_address = net::IPEndPoint(remote_ip, route.remote_port); 337 parsed_route.remote_address = net::IPEndPoint(remote_ip, route.remote_port);
338 338
339 net::IPAddress local_ip(route.local_ip); 339 net::IPAddress local_ip(route.local_ip.data(), route.local_ip.size());
340 CHECK(local_ip.empty() || local_ip.IsValid()); 340 CHECK(local_ip.empty() || local_ip.IsValid());
341 parsed_route.local_address = net::IPEndPoint(local_ip, route.local_port); 341 parsed_route.local_address = net::IPEndPoint(local_ip, route.local_port);
342 342
343 for (auto& observer : status_observers_) 343 for (auto& observer : status_observers_)
344 observer.OnClientRouteChange(jid, channel_name, parsed_route); 344 observer.OnClientRouteChange(jid, channel_name, parsed_route);
345 } 345 }
346 346
347 void DaemonProcess::OnHostStarted(const std::string& xmpp_login) { 347 void DaemonProcess::OnHostStarted(const std::string& xmpp_login) {
348 DCHECK(caller_task_runner()->BelongsToCurrentThread()); 348 DCHECK(caller_task_runner()->BelongsToCurrentThread());
349 349
350 for (auto& observer : status_observers_) 350 for (auto& observer : status_observers_)
351 observer.OnStart(xmpp_login); 351 observer.OnStart(xmpp_login);
352 } 352 }
353 353
354 void DaemonProcess::OnHostShutdown() { 354 void DaemonProcess::OnHostShutdown() {
355 DCHECK(caller_task_runner()->BelongsToCurrentThread()); 355 DCHECK(caller_task_runner()->BelongsToCurrentThread());
356 356
357 for (auto& observer : status_observers_) 357 for (auto& observer : status_observers_)
358 observer.OnShutdown(); 358 observer.OnShutdown();
359 } 359 }
360 360
361 void DaemonProcess::DeleteAllDesktopSessions() { 361 void DaemonProcess::DeleteAllDesktopSessions() {
362 while (!desktop_sessions_.empty()) { 362 while (!desktop_sessions_.empty()) {
363 delete desktop_sessions_.front(); 363 delete desktop_sessions_.front();
364 desktop_sessions_.pop_front(); 364 desktop_sessions_.pop_front();
365 } 365 }
366 } 366 }
367 367
368 } // namespace remoting 368 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698