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

Unified Diff: tools/android/forwarder2/device_forwarder_main.cc

Issue 19478003: Remove Thread wrapper class in forwarder2. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: tools/android/forwarder2/device_forwarder_main.cc
diff --git a/tools/android/forwarder2/device_forwarder_main.cc b/tools/android/forwarder2/device_forwarder_main.cc
index 5c94769f8e2b3c3c1b88fafbdf431231901a1fd3..23f88e7bf17947f6276720e91a15e67c9be60c76 100644
--- a/tools/android/forwarder2/device_forwarder_main.cc
+++ b/tools/android/forwarder2/device_forwarder_main.cc
@@ -65,31 +65,27 @@ class ServerDelegate : public Daemon::ServerDelegate {
}
controller_thread_->message_loop()->PostTask(
FROM_HERE,
- base::Bind(&ServerDelegate::StartController, GetExitNotifierFD(),
- base::Passed(&client_socket)));
+ base::Bind(&ServerDelegate::StartController, base::Unretained(this),
+ GetExitNotifierFD(), base::Passed(&client_socket)));
initialized_ = true;
}
private:
- static void StartController(int exit_notifier_fd,
- scoped_ptr<Socket> client_socket) {
- forwarder2::DeviceController controller(exit_notifier_fd);
- if (!controller.Init(kUnixDomainSocketPath)) {
+ void StartController(int exit_notifier_fd, scoped_ptr<Socket> client_socket) {
+ controller_.reset(new DeviceController(exit_notifier_fd));
+ if (!controller_->Init(kUnixDomainSocketPath)) {
client_socket->WriteString(
base::StringPrintf("ERROR: Could not initialize device controller "
"with ADB socket path: %s",
kUnixDomainSocketPath));
return;
}
+ controller_->Start();
client_socket->WriteString("OK");
client_socket->Close();
- // Note that the following call is blocking which explains why the device
- // controller has to live on a separate thread (so that the daemon command
- // server is not blocked).
- controller.Start();
}
- base::AtExitManager at_exit_manager_; // Used by base::Thread.
+ scoped_ptr<DeviceController> controller_;
scoped_ptr<base::Thread> controller_thread_;
bool initialized_;
};
@@ -128,6 +124,7 @@ int RunDeviceForwarder(int argc, char** argv) {
std::cerr << "Usage: device_forwarder [--kill-server]" << std::endl;
return 1;
}
+ base::AtExitManager at_exit_manager; // Used by base::Thread.
ClientDelegate client_delegate;
ServerDelegate daemon_delegate;
const char kLogFilePath[] = ""; // Log to logcat.

Powered by Google App Engine
This is Rietveld 408576698