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

Side by Side Diff: tools/android/forwarder2/host_forwarder_main.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 (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 <errno.h> 5 #include <errno.h>
6 #include <signal.h> 6 #include <signal.h>
7 #include <sys/types.h> 7 #include <sys/types.h>
8 #include <sys/wait.h> 8 #include <sys/wait.h>
9 #include <unistd.h> 9 #include <unistd.h>
10 10
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 HostControllersManager() 86 HostControllersManager()
87 : controllers_(new HostControllerMap()), 87 : controllers_(new HostControllerMap()),
88 has_failed_(false), 88 has_failed_(false),
89 weak_ptr_factory_(this) { 89 weak_ptr_factory_(this) {
90 } 90 }
91 91
92 ~HostControllersManager() { 92 ~HostControllersManager() {
93 if (!thread_.get()) 93 if (!thread_.get())
94 return; 94 return;
95 // Delete the controllers on the thread they were created on. 95 // Delete the controllers on the thread they were created on.
96 thread_->message_loop_proxy()->DeleteSoon( 96 thread_->task_runner()->DeleteSoon(
97 FROM_HERE, controllers_.release()); 97 FROM_HERE, controllers_.release());
98 } 98 }
99 99
100 void HandleRequest(const std::string& adb_path, 100 void HandleRequest(const std::string& adb_path,
101 const std::string& device_serial, 101 const std::string& device_serial,
102 int device_port, 102 int device_port,
103 int host_port, 103 int host_port,
104 scoped_ptr<Socket> client_socket) { 104 scoped_ptr<Socket> client_socket) {
105 // Lazy initialize so that the CLI process doesn't get this thread created. 105 // Lazy initialize so that the CLI process doesn't get this thread created.
106 InitOnce(); 106 InitOnce();
107 thread_->message_loop_proxy()->PostTask( 107 thread_->task_runner()->PostTask(
108 FROM_HERE, 108 FROM_HERE,
109 base::Bind(&HostControllersManager::HandleRequestOnInternalThread, 109 base::Bind(&HostControllersManager::HandleRequestOnInternalThread,
110 base::Unretained(this), adb_path, device_serial, device_port, 110 base::Unretained(this), adb_path, device_serial, device_port,
111 host_port, base::Passed(&client_socket))); 111 host_port, base::Passed(&client_socket)));
112 } 112 }
113 113
114 bool has_failed() const { return has_failed_; } 114 bool has_failed() const { return has_failed_; }
115 115
116 private: 116 private:
117 typedef base::hash_map< 117 typedef base::hash_map<
(...skipping 18 matching lines...) Expand all
136 const base::WeakPtr<HostControllersManager>& manager_ptr, 136 const base::WeakPtr<HostControllersManager>& manager_ptr,
137 scoped_ptr<HostController> host_controller) { 137 scoped_ptr<HostController> host_controller) {
138 HostController* const controller = host_controller.release(); 138 HostController* const controller = host_controller.release();
139 HostControllersManager* const manager = manager_ptr.get(); 139 HostControllersManager* const manager = manager_ptr.get();
140 if (!manager) { 140 if (!manager) {
141 // Note that |controller| is not leaked in this case since the host 141 // Note that |controller| is not leaked in this case since the host
142 // controllers manager owns the controllers. If the manager was deleted 142 // controllers manager owns the controllers. If the manager was deleted
143 // then all the controllers (including |controller|) were also deleted. 143 // then all the controllers (including |controller|) were also deleted.
144 return; 144 return;
145 } 145 }
146 DCHECK(manager->thread_->message_loop_proxy()->RunsTasksOnCurrentThread()); 146 DCHECK(manager->thread_->task_runner()->RunsTasksOnCurrentThread());
147 // Note that this will delete |controller| which is owned by the map. 147 // Note that this will delete |controller| which is owned by the map.
148 DeleteRefCountedValueInMap( 148 DeleteRefCountedValueInMap(
149 MakeHostControllerMapKey( 149 MakeHostControllerMapKey(
150 controller->adb_port(), controller->device_port()), 150 controller->adb_port(), controller->device_port()),
151 manager->controllers_.get()); 151 manager->controllers_.get());
152 } 152 }
153 153
154 void HandleRequestOnInternalThread(const std::string& adb_path, 154 void HandleRequestOnInternalThread(const std::string& adb_path,
155 const std::string& device_serial, 155 const std::string& device_serial,
156 int device_port, 156 int device_port,
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
458 458
459 return client_delegate.has_failed() || daemon_delegate.has_failed(); 459 return client_delegate.has_failed() || daemon_delegate.has_failed();
460 } 460 }
461 461
462 } // namespace 462 } // namespace
463 } // namespace forwarder2 463 } // namespace forwarder2
464 464
465 int main(int argc, char** argv) { 465 int main(int argc, char** argv) {
466 return forwarder2::RunHostForwarder(argc, argv); 466 return forwarder2::RunHostForwarder(argc, argv);
467 } 467 }
OLDNEW
« no previous file with comments | « tools/android/forwarder2/host_controller.cc ('k') | tools/ipc_fuzzer/message_replay/replay_process.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698