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

Side by Side Diff: tools/android/forwarder2/forwarders_manager.cc

Issue 1179163002: Migrate callers of message_loop_proxy() to task_runner() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 5 years, 6 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 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 <sys/select.h> 7 #include <sys/select.h>
8 #include <unistd.h> 8 #include <unistd.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 17 matching lines...) Expand all
28 28
29 29
30 ForwardersManager::~ForwardersManager() { 30 ForwardersManager::~ForwardersManager() {
31 deletion_notifier_.Notify(); 31 deletion_notifier_.Notify();
32 } 32 }
33 33
34 void ForwardersManager::CreateAndStartNewForwarder(scoped_ptr<Socket> socket1, 34 void ForwardersManager::CreateAndStartNewForwarder(scoped_ptr<Socket> socket1,
35 scoped_ptr<Socket> socket2) { 35 scoped_ptr<Socket> socket2) {
36 // Note that the internal Forwarder vector is populated on the internal thread 36 // Note that the internal Forwarder vector is populated on the internal thread
37 // which is the only thread from which it's accessed. 37 // which is the only thread from which it's accessed.
38 thread_.message_loop_proxy()->PostTask( 38 thread_.task_runner()->PostTask(
39 FROM_HERE, 39 FROM_HERE,
40 base::Bind(&ForwardersManager::CreateNewForwarderOnInternalThread, 40 base::Bind(&ForwardersManager::CreateNewForwarderOnInternalThread,
41 base::Unretained(this), base::Passed(&socket1), 41 base::Unretained(this), base::Passed(&socket1),
42 base::Passed(&socket2))); 42 base::Passed(&socket2)));
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_.message_loop_proxy()->RunsTasksOnCurrentThread()); 52 DCHECK(thread_.task_runner()->RunsTasksOnCurrentThread());
53 forwarders_.push_back(new Forwarder(socket1.Pass(), socket2.Pass())); 53 forwarders_.push_back(new Forwarder(socket1.Pass(), socket2.Pass()));
54 } 54 }
55 55
56 void ForwardersManager::WaitForEventsOnInternalThreadSoon() { 56 void ForwardersManager::WaitForEventsOnInternalThreadSoon() {
57 thread_.message_loop_proxy()->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() {
64 DCHECK(thread_.message_loop_proxy()->RunsTasksOnCurrentThread()); 64 DCHECK(thread_.task_runner()->RunsTasksOnCurrentThread());
65 fd_set read_fds; 65 fd_set read_fds;
66 fd_set write_fds; 66 fd_set write_fds;
67 67
68 FD_ZERO(&read_fds); 68 FD_ZERO(&read_fds);
69 FD_ZERO(&write_fds); 69 FD_ZERO(&write_fds);
70 70
71 // Populate the file descriptor sets. 71 // Populate the file descriptor sets.
72 int max_fd = -1; 72 int max_fd = -1;
73 for (ScopedVector<Forwarder>::iterator it = forwarders_.begin(); 73 for (ScopedVector<Forwarder>::iterator it = forwarders_.begin();
74 it != forwarders_.end(); ++it) { 74 it != forwarders_.end(); ++it) {
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « tools/android/forwarder2/device_listener.cc ('k') | tools/android/forwarder2/host_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698