DevTools: cut host and port from webSocketDebuggerUrl in addition to ws:// prefix
[chromium-blink-merge.git] / chrome / browser / devtools / device / adb / mock_adb_server.cc
blobe52299caec5e02503b200405025cd1e9830ef662
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/devtools/device/adb/mock_adb_server.h"
7 #include "base/location.h"
8 #include "base/memory/weak_ptr.h"
9 #include "base/single_thread_task_runner.h"
10 #include "base/strings/string_number_conversions.h"
11 #include "base/strings/string_split.h"
12 #include "base/strings/string_util.h"
13 #include "base/strings/stringprintf.h"
14 #include "base/thread_task_runner_handle.h"
15 #include "base/threading/non_thread_safe.h"
16 #include "content/public/browser/browser_thread.h"
17 #include "content/public/test/browser_test.h"
18 #include "content/public/test/test_utils.h"
19 #include "net/base/io_buffer.h"
20 #include "net/base/ip_endpoint.h"
21 #include "net/base/net_errors.h"
22 #include "net/socket/stream_socket.h"
23 #include "net/socket/tcp_server_socket.h"
25 using content::BrowserThread;
27 namespace {
29 const char kHostTransportPrefix[] = "host:transport:";
30 const char kLocalAbstractPrefix[] = "localabstract:";
32 const char kShellPrefix[] = "shell:";
33 const char kOpenedUnixSocketsCommand[] = "cat /proc/net/unix";
34 const char kDeviceModelCommand[] = "getprop ro.product.model";
35 const char kDumpsysCommand[] = "dumpsys window policy";
36 const char kListProcessesCommand[] = "ps";
37 const char kListUsersCommand[] = "dumpsys user";
38 const char kEchoCommandPrefix[] = "echo ";
40 const char kSerialOnline[] = "01498B321301A00A";
41 const char kSerialOffline[] = "01498B2B0D01300E";
42 const char kDeviceModel[] = "Nexus 6";
44 const char kJsonVersionPath[] = "/json/version";
45 const char kJsonPath[] = "/json";
46 const char kJsonListPath[] = "/json/list";
48 const char kHttpRequestTerminator[] = "\r\n\r\n";
50 const char kHttpResponse[] =
51 "HTTP/1.1 200 OK\r\n"
52 "Content-Length:%d\r\n"
53 "Content-Type:application/json; charset=UTF-8\r\n\r\n%s";
55 const char kSampleOpenedUnixSockets[] =
56 "Num RefCount Protocol Flags Type St Inode Path\n"
57 "00000000: 00000004 00000000"
58 " 00000000 0002 01 3328 /dev/socket/wpa_wlan0\n"
59 "00000000: 00000002 00000000"
60 " 00010000 0001 01 5394 /dev/socket/vold\n"
61 "00000000: 00000002 00000000"
62 " 00010000 0001 01 11810 @webview_devtools_remote_2425\n"
63 "00000000: 00000002 00000000"
64 " 00010000 0001 01 20893 @chrome_devtools_remote\n"
65 "00000000: 00000002 00000000"
66 " 00010000 0001 01 20894 @chrome_devtools_remote_1002\n"
67 "00000000: 00000002 00000000"
68 " 00010000 0001 01 20895 @noprocess_devtools_remote\n";
70 const char kSampleListProcesses[] =
71 "USER PID PPID VSIZE RSS WCHAN PC NAME\n"
72 "root 1 0 688 508 ffffffff 00000000 S /init\r\n"
73 "u0_a75 2425 123 933736 193024 ffffffff 00000000 S com.sample.feed\r\n"
74 "nfc 741 123 706448 26316 ffffffff 00000000 S com.android.nfc\r\n"
75 "u0_a76 1001 124 111111 222222 ffffffff 00000000 S com.android.chrome\r\n"
76 "u10_a77 1002 125 111111 222222 ffffffff 00000000 S com.chrome.beta\r\n"
77 "u0_a78 1003 126 111111 222222 ffffffff 00000000 S com.noprocess.app\r\n";
79 const char kSampleDumpsys[] =
80 "WINDOW MANAGER POLICY STATE (dumpsys window policy)\r\n"
81 " mSafeMode=false mSystemReady=true mSystemBooted=true\r\n"
82 " mStable=(0,50)-(720,1184)\r\n" // Only mStable parameter is parsed
83 " mForceStatusBar=false mForceStatusBarFromKeyguard=false\r\n";
85 const char kSampleListUsers[] =
86 "Users:\r\n"
87 " UserInfo{0:Test User:13} serialNo=0\r\n"
88 " Created: <unknown>\r\n"
89 " Last logged in: +17m18s871ms ago\r\n"
90 " UserInfo{10:Test User : 2:10} serialNo=10\r\n"
91 " Created: +3d4h35m1s139ms ago\r\n"
92 " Last logged in: +17m26s287ms ago\r\n";
94 char kSampleChromeVersion[] = "{\n"
95 " \"Browser\": \"Chrome/32.0.1679.0\",\n"
96 " \"Protocol-Version\": \"1.0\",\n"
97 " \"User-Agent\": \"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 "
98 "(KHTML, like Gecko) Chrome/32.0.1679.0 Safari/537.36\",\n"
99 " \"WebKit-Version\": \"537.36 (@160162)\"\n"
100 "}";
102 char kSampleChromeBetaVersion[] = "{\n"
103 " \"Browser\": \"Chrome/31.0.1599.0\",\n"
104 " \"Protocol-Version\": \"1.0\",\n"
105 " \"User-Agent\": \"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 "
106 "(KHTML, like Gecko) Chrome/32.0.1679.0 Safari/537.36\",\n"
107 " \"WebKit-Version\": \"537.36 (@160162)\"\n"
108 "}";
110 char kSampleWebViewVersion[] = "{\n"
111 " \"Browser\": \"Version/4.0\",\n"
112 " \"Protocol-Version\": \"1.0\",\n"
113 " \"User-Agent\": \"Mozilla/5.0 (Linux; Android 4.3; Build/KRS74B) "
114 "AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Safari/537.36\",\n"
115 " \"WebKit-Version\": \"537.36 (@157588)\"\n"
116 "}";
118 char kSampleChromePages[] = "[ {\n"
119 " \"description\": \"\",\n"
120 " \"devtoolsFrontendUrl\": \"/devtools/devtools.html?"
121 "ws=/devtools/page/0\",\n"
122 " \"id\": \"0\",\n"
123 " \"title\": \"The Chromium Projects\",\n"
124 " \"type\": \"page\",\n"
125 " \"url\": \"http://www.chromium.org/\",\n"
126 " \"webSocketDebuggerUrl\": \""
127 "ws:///devtools/page/0\"\n"
128 "} ]";
130 char kSampleChromeBetaPages[] = "[ {\n"
131 " \"description\": \"\",\n"
132 " \"devtoolsFrontendUrl\": \"/devtools/devtools.html?"
133 "ws=/devtools/page/0\",\n"
134 " \"id\": \"0\",\n"
135 " \"title\": \"The Chromium Projects\",\n"
136 " \"type\": \"page\",\n"
137 " \"url\": \"http://www.chromium.org/\",\n"
138 " \"webSocketDebuggerUrl\": \""
139 "ws:///devtools/page/0\"\n"
140 "} ]";
142 char kSampleWebViewPages[] = "[ {\n"
143 " \"description\": \"{\\\"attached\\\":false,\\\"empty\\\":false,"
144 "\\\"height\\\":1173,\\\"screenX\\\":0,\\\"screenY\\\":0,"
145 "\\\"visible\\\":true,\\\"width\\\":800}\",\n"
146 " \"devtoolsFrontendUrl\": \"http://chrome-devtools-frontend.appspot.com/"
147 "serve_rev/@157588/devtools.html?ws="
148 "/devtools/page/3E962D4D-B676-182D-3BE8-FAE7CE224DE7\",\n"
149 " \"faviconUrl\": \"http://chromium.org/favicon.ico\",\n"
150 " \"id\": \"3E962D4D-B676-182D-3BE8-FAE7CE224DE7\",\n"
151 " \"thumbnailUrl\": \"/thumb/3E962D4D-B676-182D-3BE8-FAE7CE224DE7\",\n"
152 " \"title\": \"Blink - The Chromium Projects\",\n"
153 " \"type\": \"page\",\n"
154 " \"url\": \"http://www.chromium.org/blink\",\n"
155 " \"webSocketDebuggerUrl\": \"ws:///devtools/"
156 "page/3E962D4D-B676-182D-3BE8-FAE7CE224DE7\"\n"
157 "}, {\n"
158 " \"description\": \"{\\\"attached\\\":true,\\\"empty\\\":true,"
159 "\\\"screenX\\\":0,\\\"screenY\\\":33,\\\"visible\\\":false}\",\n"
160 " \"devtoolsFrontendUrl\": \"http://chrome-devtools-frontend.appspot.com/"
161 "serve_rev/@157588/devtools.html?ws="
162 "/devtools/page/44681551-ADFD-2411-076B-3AB14C1C60E2\",\n"
163 " \"faviconUrl\": \"\",\n"
164 " \"id\": \"44681551-ADFD-2411-076B-3AB14C1C60E2\",\n"
165 " \"thumbnailUrl\": \"/thumb/44681551-ADFD-2411-076B-3AB14C1C60E2\",\n"
166 " \"title\": \"More Activity\",\n"
167 " \"type\": \"page\",\n"
168 " \"url\": \"about:blank\",\n"
169 " \"webSocketDebuggerUrl\": \"ws:///devtools/page/"
170 "44681551-ADFD-2411-076B-3AB14C1C60E2\"\n"
171 "}]";
173 static const int kBufferSize = 16*1024;
174 static const uint16 kAdbPort = 5037;
176 static const int kAdbMessageHeaderSize = 4;
178 class SimpleHttpServer : base::NonThreadSafe {
179 public:
180 class Parser {
181 public:
182 virtual int Consume(const char* data, int size) = 0;
183 virtual ~Parser() {}
186 using SendCallback = base::Callback<void(const std::string&)>;
187 using ParserFactory = base::Callback<Parser*(const SendCallback&)>;
189 SimpleHttpServer(const ParserFactory& factory, net::IPEndPoint endpoint);
190 virtual ~SimpleHttpServer();
192 private:
193 class Connection : base::NonThreadSafe {
194 public:
195 Connection(net::StreamSocket* socket, const ParserFactory& factory);
196 virtual ~Connection();
198 private:
199 void Send(const std::string& message);
200 void ReadData();
201 void OnDataRead(int count);
202 void WriteData();
203 void OnDataWritten(int count);
205 scoped_ptr<net::StreamSocket> socket_;
206 scoped_ptr<Parser> parser_;
207 scoped_refptr<net::GrowableIOBuffer> input_buffer_;
208 scoped_refptr<net::GrowableIOBuffer> output_buffer_;
209 int bytes_to_write_;
210 bool read_closed_;
211 base::WeakPtrFactory<Connection> weak_factory_;
213 DISALLOW_COPY_AND_ASSIGN(Connection);
216 void AcceptConnection();
217 void OnAccepted(int result);
219 ParserFactory factory_;
220 scoped_ptr<net::TCPServerSocket> socket_;
221 scoped_ptr<net::StreamSocket> client_socket_;
222 base::WeakPtrFactory<SimpleHttpServer> weak_factory_;
224 DISALLOW_COPY_AND_ASSIGN(SimpleHttpServer);
227 SimpleHttpServer::SimpleHttpServer(const ParserFactory& factory,
228 net::IPEndPoint endpoint)
229 : factory_(factory),
230 socket_(new net::TCPServerSocket(nullptr, net::NetLog::Source())),
231 weak_factory_(this) {
232 socket_->Listen(endpoint, 5);
233 AcceptConnection();
236 SimpleHttpServer::~SimpleHttpServer() {
239 SimpleHttpServer::Connection::Connection(net::StreamSocket* socket,
240 const ParserFactory& factory)
241 : socket_(socket),
242 parser_(factory.Run(base::Bind(&Connection::Send,
243 base::Unretained(this)))),
244 input_buffer_(new net::GrowableIOBuffer()),
245 output_buffer_(new net::GrowableIOBuffer()),
246 bytes_to_write_(0),
247 read_closed_(false),
248 weak_factory_(this) {
249 input_buffer_->SetCapacity(kBufferSize);
250 ReadData();
253 SimpleHttpServer::Connection::~Connection() {
256 void SimpleHttpServer::Connection::Send(const std::string& message) {
257 CHECK(CalledOnValidThread());
258 const char* data = message.c_str();
259 int size = message.size();
261 if ((output_buffer_->offset() + bytes_to_write_ + size) >
262 output_buffer_->capacity()) {
263 // If not enough space without relocation
264 if (output_buffer_->capacity() < (bytes_to_write_ + size)) {
265 // If even buffer is not enough
266 int new_size = std::max(output_buffer_->capacity() * 2, size * 2);
267 output_buffer_->SetCapacity(new_size);
269 memmove(output_buffer_->StartOfBuffer(),
270 output_buffer_->data(),
271 bytes_to_write_);
272 output_buffer_->set_offset(0);
275 memcpy(output_buffer_->data() + bytes_to_write_, data, size);
276 bytes_to_write_ += size;
278 if (bytes_to_write_ == size)
279 // If write loop wasn't yet started, then start it
280 WriteData();
283 void SimpleHttpServer::Connection::ReadData() {
284 CHECK(CalledOnValidThread());
286 if (input_buffer_->RemainingCapacity() == 0)
287 input_buffer_->SetCapacity(input_buffer_->capacity() * 2);
289 int read_result = socket_->Read(
290 input_buffer_.get(),
291 input_buffer_->RemainingCapacity(),
292 base::Bind(&Connection::OnDataRead, base::Unretained(this)));
294 if (read_result != net::ERR_IO_PENDING)
295 OnDataRead(read_result);
298 void SimpleHttpServer::Connection::OnDataRead(int count) {
299 CHECK(CalledOnValidThread());
300 if (count <= 0) {
301 if (bytes_to_write_ == 0)
302 delete this;
303 else
304 read_closed_ = true;
305 return;
307 input_buffer_->set_offset(input_buffer_->offset() + count);
308 int bytes_processed;
310 do {
311 char* data = input_buffer_->StartOfBuffer();
312 int data_size = input_buffer_->offset();
313 bytes_processed = parser_->Consume(data, data_size);
315 if (bytes_processed) {
316 memmove(data, data + bytes_processed, data_size - bytes_processed);
317 input_buffer_->set_offset(data_size - bytes_processed);
319 } while (bytes_processed);
320 // Posting to avoid deep recursion in case of synchronous IO
321 base::ThreadTaskRunnerHandle::Get()->PostTask(
322 FROM_HERE, base::Bind(&Connection::ReadData, weak_factory_.GetWeakPtr()));
325 void SimpleHttpServer::Connection::WriteData() {
326 CHECK(CalledOnValidThread());
327 CHECK_GE(output_buffer_->capacity(),
328 output_buffer_->offset() + bytes_to_write_) << "Overflow";
330 int write_result = socket_->Write(
331 output_buffer_.get(),
332 bytes_to_write_,
333 base::Bind(&Connection::OnDataWritten, base::Unretained(this)));
335 if (write_result != net::ERR_IO_PENDING)
336 OnDataWritten(write_result);
339 void SimpleHttpServer::Connection::OnDataWritten(int count) {
340 CHECK(CalledOnValidThread());
341 if (count < 0) {
342 delete this;
343 return;
345 CHECK_GT(count, 0);
346 CHECK_GE(output_buffer_->capacity(),
347 output_buffer_->offset() + bytes_to_write_) << "Overflow";
349 bytes_to_write_ -= count;
350 output_buffer_->set_offset(output_buffer_->offset() + count);
352 if (bytes_to_write_ != 0)
353 // Posting to avoid deep recursion in case of synchronous IO
354 base::ThreadTaskRunnerHandle::Get()->PostTask(
355 FROM_HERE,
356 base::Bind(&Connection::WriteData, weak_factory_.GetWeakPtr()));
357 else if (read_closed_)
358 delete this;
361 void SimpleHttpServer::AcceptConnection() {
362 CHECK(CalledOnValidThread());
364 int accept_result = socket_->Accept(&client_socket_,
365 base::Bind(&SimpleHttpServer::OnAccepted, base::Unretained(this)));
367 if (accept_result != net::ERR_IO_PENDING)
368 base::ThreadTaskRunnerHandle::Get()->PostTask(
369 FROM_HERE, base::Bind(&SimpleHttpServer::OnAccepted,
370 weak_factory_.GetWeakPtr(), accept_result));
373 void SimpleHttpServer::OnAccepted(int result) {
374 CHECK(CalledOnValidThread());
375 ASSERT_EQ(result, 0); // Fails if the socket is already in use.
376 new Connection(client_socket_.release(), factory_);
377 AcceptConnection();
380 class AdbParser : public SimpleHttpServer::Parser,
381 public base::NonThreadSafe,
382 public MockAndroidConnection::Delegate {
383 public:
384 static Parser* Create(const SimpleHttpServer::SendCallback& callback) {
385 return new AdbParser(callback);
388 ~AdbParser() override {}
389 private:
390 explicit AdbParser(const SimpleHttpServer::SendCallback& callback)
391 : callback_(callback) {
394 int Consume(const char* data, int size) override {
395 CHECK(CalledOnValidThread());
396 if (mock_connection_) {
397 mock_connection_->Receive(std::string(data, size));
398 return size;
400 if (size >= kAdbMessageHeaderSize) {
401 std::string message_header(data, kAdbMessageHeaderSize);
402 int message_size;
404 EXPECT_TRUE(base::HexStringToInt(message_header, &message_size));
406 if (size >= message_size + kAdbMessageHeaderSize) {
407 std::string message_body(data + kAdbMessageHeaderSize, message_size);
408 ProcessCommand(message_body);
409 return kAdbMessageHeaderSize + message_size;
412 return 0;
415 void ProcessCommand(const std::string& command) {
416 CHECK(CalledOnValidThread());
417 if (command == "host:devices") {
418 SendSuccess(base::StringPrintf("%s\tdevice\n%s\toffline",
419 kSerialOnline,
420 kSerialOffline));
421 } else if (command.find(kHostTransportPrefix) == 0) {
422 serial_ = command.substr(strlen(kHostTransportPrefix));
423 SendSuccess(std::string());
424 } else if (serial_ != kSerialOnline) {
425 Send("FAIL", "device offline (x)");
426 } else {
427 mock_connection_ = make_scoped_ptr(
428 new MockAndroidConnection(this, serial_, command));
432 void SendSuccess(const std::string& response) override {
433 Send("OKAY", response);
436 void SendRaw(const std::string& data) override {
437 callback_.Run(data);
440 void Send(const std::string& status, const std::string& response) {
441 CHECK(CalledOnValidThread());
442 CHECK_EQ(4U, status.size());
444 std::stringstream response_stream;
445 response_stream << status;
447 int size = response.size();
448 if (size > 0) {
449 static const char kHexChars[] = "0123456789ABCDEF";
450 for (int i = 3; i >= 0; i--)
451 response_stream << kHexChars[ (size >> 4*i) & 0x0f ];
452 response_stream << response;
454 callback_.Run(response_stream.str());
457 SimpleHttpServer::SendCallback callback_;
458 std::string serial_;
459 scoped_ptr<MockAndroidConnection> mock_connection_;
462 static SimpleHttpServer* mock_adb_server_ = NULL;
464 void StartMockAdbServerOnIOThread() {
465 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
466 CHECK(mock_adb_server_ == NULL);
467 net::IPAddressNumber address;
468 net::ParseIPLiteralToNumber("127.0.0.1", &address);
469 net::IPEndPoint endpoint(address, kAdbPort);
470 mock_adb_server_ =
471 new SimpleHttpServer(base::Bind(&AdbParser::Create), endpoint);
474 void StopMockAdbServerOnIOThread() {
475 CHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
476 CHECK(mock_adb_server_ != NULL);
477 delete mock_adb_server_;
478 mock_adb_server_ = NULL;
481 } // namespace
483 MockAndroidConnection::MockAndroidConnection(
484 Delegate* delegate,
485 const std::string& serial,
486 const std::string& command)
487 : delegate_(delegate),
488 serial_(serial) {
489 ProcessCommand(command);
492 MockAndroidConnection::~MockAndroidConnection() {
495 void MockAndroidConnection::Receive(const std::string& data) {
496 request_ += data;
497 size_t request_end_pos = data.find(kHttpRequestTerminator);
498 if (request_end_pos == std::string::npos)
499 return;
501 std::string request(request_.substr(0, request_end_pos));
502 std::vector<std::string> tokens =
503 base::SplitString(request, " ", base::KEEP_WHITESPACE,
504 base::SPLIT_WANT_NONEMPTY);
505 CHECK_EQ(3U, tokens.size());
506 CHECK_EQ("GET", tokens[0]);
507 CHECK_EQ("HTTP/1.1", tokens[2]);
509 std::string path(tokens[1]);
510 if (path == kJsonPath)
511 path = kJsonListPath;
513 if (socket_name_ == "chrome_devtools_remote") {
514 if (path == kJsonVersionPath)
515 SendHTTPResponse(kSampleChromeVersion);
516 else if (path == kJsonListPath)
517 SendHTTPResponse(kSampleChromePages);
518 else
519 NOTREACHED() << "Unknown command " << request;
520 } else if (socket_name_ == "chrome_devtools_remote_1002") {
521 if (path == kJsonVersionPath)
522 SendHTTPResponse(kSampleChromeBetaVersion);
523 else if (path == kJsonListPath)
524 SendHTTPResponse(kSampleChromeBetaPages);
525 else
526 NOTREACHED() << "Unknown command " << request;
527 } else if (socket_name_.find("noprocess_devtools_remote") == 0) {
528 if (path == kJsonVersionPath)
529 SendHTTPResponse("{}");
530 else if (path == kJsonListPath)
531 SendHTTPResponse("[]");
532 else
533 NOTREACHED() << "Unknown command " << request;
534 } else if (socket_name_ == "webview_devtools_remote_2425") {
535 if (path == kJsonVersionPath)
536 SendHTTPResponse(kSampleWebViewVersion);
537 else if (path == kJsonListPath)
538 SendHTTPResponse(kSampleWebViewPages);
539 else
540 NOTREACHED() << "Unknown command " << request;
541 } else {
542 NOTREACHED() << "Unknown socket " << socket_name_;
546 void MockAndroidConnection::ProcessCommand(const std::string& command) {
547 if (command.find(kLocalAbstractPrefix) == 0) {
548 socket_name_ = command.substr(strlen(kLocalAbstractPrefix));
549 delegate_->SendSuccess(std::string());
550 } else {
551 if (command.find(kShellPrefix) == 0) {
552 std::string result;
553 for (const auto& line :
554 base::SplitString(command.substr(strlen(kShellPrefix)), "\n",
555 base::KEEP_WHITESPACE,
556 base::SPLIT_WANT_NONEMPTY)) {
557 if (line == kDeviceModelCommand) {
558 result += kDeviceModel;
559 result += "\r\n";
560 } else if (line == kOpenedUnixSocketsCommand) {
561 result += kSampleOpenedUnixSockets;
562 } else if (line == kDumpsysCommand) {
563 result += kSampleDumpsys;
564 } else if (line == kListProcessesCommand) {
565 result += kSampleListProcesses;
566 } else if (line == kListUsersCommand) {
567 result += kSampleListUsers;
568 } else if (line.find(kEchoCommandPrefix) == 0) {
569 result += line.substr(strlen(kEchoCommandPrefix));
570 result += "\r\n";
571 } else {
572 NOTREACHED() << "Unknown shell command - " << command;
575 delegate_->SendSuccess(result);
576 } else {
577 NOTREACHED() << "Unknown command - " << command;
579 delegate_->Close();
583 void MockAndroidConnection::SendHTTPResponse(const std::string& body) {
584 std::string response_data(base::StringPrintf(kHttpResponse,
585 static_cast<int>(body.size()),
586 body.c_str()));
587 delegate_->SendRaw(response_data);
590 void StartMockAdbServer() {
591 BrowserThread::PostTaskAndReply(
592 BrowserThread::IO,
593 FROM_HERE,
594 base::Bind(&StartMockAdbServerOnIOThread),
595 base::MessageLoop::QuitClosure());
596 content::RunMessageLoop();
599 void StopMockAdbServer() {
600 BrowserThread::PostTaskAndReply(
601 BrowserThread::IO,
602 FROM_HERE,
603 base::Bind(&StopMockAdbServerOnIOThread),
604 base::MessageLoop::QuitClosure());
605 content::RunMessageLoop();