| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/forwarders_manager.h" | 5 #include "tools/android/forwarder2/forwarders_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <sys/select.h> | 8 #include <sys/select.h> |
| 9 #include <unistd.h> | 9 #include <unistd.h> |
| 10 | |
| 11 #include <algorithm> | 10 #include <algorithm> |
| 11 #include <utility> |
| 12 | 12 |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/callback_helpers.h" | 14 #include "base/callback_helpers.h" |
| 15 #include "base/location.h" | 15 #include "base/location.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/macros.h" | 17 #include "base/macros.h" |
| 18 #include "base/posix/eintr_wrapper.h" | 18 #include "base/posix/eintr_wrapper.h" |
| 19 #include "tools/android/forwarder2/forwarder.h" | 19 #include "tools/android/forwarder2/forwarder.h" |
| 20 #include "tools/android/forwarder2/socket.h" | 20 #include "tools/android/forwarder2/socket.h" |
| 21 | 21 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 43 | 43 |
| 44 // Guarantees that the CreateNewForwarderOnInternalThread callback posted to | 44 // Guarantees that the CreateNewForwarderOnInternalThread callback posted to |
| 45 // the internal thread gets executed immediately. | 45 // the internal thread gets executed immediately. |
| 46 wakeup_notifier_.Notify(); | 46 wakeup_notifier_.Notify(); |
| 47 } | 47 } |
| 48 | 48 |
| 49 void ForwardersManager::CreateNewForwarderOnInternalThread( | 49 void ForwardersManager::CreateNewForwarderOnInternalThread( |
| 50 scoped_ptr<Socket> socket1, | 50 scoped_ptr<Socket> socket1, |
| 51 scoped_ptr<Socket> socket2) { | 51 scoped_ptr<Socket> socket2) { |
| 52 DCHECK(thread_.task_runner()->RunsTasksOnCurrentThread()); | 52 DCHECK(thread_.task_runner()->RunsTasksOnCurrentThread()); |
| 53 forwarders_.push_back(new Forwarder(socket1.Pass(), socket2.Pass())); | 53 forwarders_.push_back(new Forwarder(std::move(socket1), std::move(socket2))); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void ForwardersManager::WaitForEventsOnInternalThreadSoon() { | 56 void ForwardersManager::WaitForEventsOnInternalThreadSoon() { |
| 57 thread_.task_runner()->PostTask( | 57 thread_.task_runner()->PostTask( |
| 58 FROM_HERE, | 58 FROM_HERE, |
| 59 base::Bind(&ForwardersManager::WaitForEventsOnInternalThread, | 59 base::Bind(&ForwardersManager::WaitForEventsOnInternalThread, |
| 60 base::Unretained(this))); | 60 base::Unretained(this))); |
| 61 } | 61 } |
| 62 | 62 |
| 63 void ForwardersManager::WaitForEventsOnInternalThread() { | 63 void ForwardersManager::WaitForEventsOnInternalThread() { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 ++i; | 123 ++i; |
| 124 continue; | 124 continue; |
| 125 } | 125 } |
| 126 | 126 |
| 127 std::swap(forwarders_[i], forwarders_.back()); | 127 std::swap(forwarders_[i], forwarders_.back()); |
| 128 forwarders_.pop_back(); | 128 forwarders_.pop_back(); |
| 129 } | 129 } |
| 130 } | 130 } |
| 131 | 131 |
| 132 } // namespace forwarder2 | 132 } // namespace forwarder2 |
| OLD | NEW |