| 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 "tools/android/forwarder2/device_controller.h" | 5 #include "tools/android/forwarder2/device_controller.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 DeviceController::~DeviceController() { | 40 DeviceController::~DeviceController() { |
| 41 DCHECK(construction_task_runner_->RunsTasksOnCurrentThread()); | 41 DCHECK(construction_task_runner_->RunsTasksOnCurrentThread()); |
| 42 } | 42 } |
| 43 | 43 |
| 44 void DeviceController::Start() { | 44 void DeviceController::Start() { |
| 45 AcceptHostCommandSoon(); | 45 AcceptHostCommandSoon(); |
| 46 } | 46 } |
| 47 | 47 |
| 48 DeviceController::DeviceController(scoped_ptr<Socket> host_socket, | 48 DeviceController::DeviceController(scoped_ptr<Socket> host_socket, |
| 49 int exit_notifier_fd) | 49 int exit_notifier_fd) |
| 50 : host_socket_(host_socket.Pass()), | 50 : weak_ptr_factory_(this), |
| 51 host_socket_(host_socket.Pass()), |
| 51 exit_notifier_fd_(exit_notifier_fd), | 52 exit_notifier_fd_(exit_notifier_fd), |
| 52 construction_task_runner_(base::MessageLoopProxy::current()), | 53 construction_task_runner_(base::MessageLoopProxy::current()) { |
| 53 weak_ptr_factory_(this) { | |
| 54 host_socket_->AddEventFd(exit_notifier_fd); | 54 host_socket_->AddEventFd(exit_notifier_fd); |
| 55 } | 55 } |
| 56 | 56 |
| 57 void DeviceController::AcceptHostCommandSoon() { | 57 void DeviceController::AcceptHostCommandSoon() { |
| 58 base::MessageLoopProxy::current()->PostTask( | 58 base::MessageLoopProxy::current()->PostTask( |
| 59 FROM_HERE, | 59 FROM_HERE, |
| 60 base::Bind(&DeviceController::AcceptHostCommandInternal, | 60 base::Bind(&DeviceController::AcceptHostCommandInternal, |
| 61 base::Unretained(this))); | 61 base::Unretained(this))); |
| 62 } | 62 } |
| 63 | 63 |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 return; | 149 return; |
| 150 } | 150 } |
| 151 DCHECK(controller->construction_task_runner_->RunsTasksOnCurrentThread()); | 151 DCHECK(controller->construction_task_runner_->RunsTasksOnCurrentThread()); |
| 152 bool listener_did_exist = DeleteRefCountedValueInMap( | 152 bool listener_did_exist = DeleteRefCountedValueInMap( |
| 153 listener->listener_port(), &controller->listeners_); | 153 listener->listener_port(), &controller->listeners_); |
| 154 DCHECK(listener_did_exist); | 154 DCHECK(listener_did_exist); |
| 155 // Note that |listener| was deleted by DeleteRefCountedValueInMap(). | 155 // Note that |listener| was deleted by DeleteRefCountedValueInMap(). |
| 156 } | 156 } |
| 157 | 157 |
| 158 } // namespace forwarder | 158 } // namespace forwarder |
| OLD | NEW |