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

Side by Side Diff: chrome/test/chromedriver/server/chromedriver_server.cc

Issue 2104363004: Remove remaining calls to deprecated MessageLoop methods. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: CR gab Created 4 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include <locale> 9 #include <locale>
10 #include <memory> 10 #include <memory>
11 #include <string> 11 #include <string>
12 #include <utility> 12 #include <utility>
13 #include <vector> 13 #include <vector>
14 14
15 #include "base/at_exit.h" 15 #include "base/at_exit.h"
16 #include "base/bind.h" 16 #include "base/bind.h"
17 #include "base/callback.h" 17 #include "base/callback.h"
18 #include "base/command_line.h" 18 #include "base/command_line.h"
19 #include "base/files/file_path.h" 19 #include "base/files/file_path.h"
20 #include "base/lazy_instance.h" 20 #include "base/lazy_instance.h"
21 #include "base/logging.h" 21 #include "base/logging.h"
22 #include "base/macros.h" 22 #include "base/macros.h"
23 #include "base/message_loop/message_loop.h" 23 #include "base/message_loop/message_loop.h"
24 #include "base/run_loop.h" 24 #include "base/run_loop.h"
25 #include "base/single_thread_task_runner.h"
25 #include "base/strings/string_number_conversions.h" 26 #include "base/strings/string_number_conversions.h"
26 #include "base/strings/string_split.h" 27 #include "base/strings/string_split.h"
27 #include "base/strings/string_util.h" 28 #include "base/strings/string_util.h"
28 #include "base/strings/stringprintf.h" 29 #include "base/strings/stringprintf.h"
29 #include "base/synchronization/waitable_event.h" 30 #include "base/synchronization/waitable_event.h"
30 #include "base/threading/thread.h" 31 #include "base/threading/thread.h"
31 #include "base/threading/thread_local.h" 32 #include "base/threading/thread_local.h"
32 #include "base/threading/thread_task_runner_handle.h" 33 #include "base/threading/thread_task_runner_handle.h"
33 #include "build/build_config.h" 34 #include "build/build_config.h"
34 #include "chrome/test/chromedriver/logging.h" 35 #include "chrome/test/chromedriver/logging.h"
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 CHECK(io_thread.StartWithOptions( 201 CHECK(io_thread.StartWithOptions(
201 base::Thread::Options(base::MessageLoop::TYPE_IO, 0))); 202 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)));
202 203
203 base::MessageLoop cmd_loop; 204 base::MessageLoop cmd_loop;
204 base::RunLoop cmd_run_loop; 205 base::RunLoop cmd_run_loop;
205 HttpHandler handler(cmd_run_loop.QuitClosure(), io_thread.task_runner(), 206 HttpHandler handler(cmd_run_loop.QuitClosure(), io_thread.task_runner(),
206 url_base, adb_port, std::move(port_server)); 207 url_base, adb_port, std::move(port_server));
207 HttpRequestHandlerFunc handle_request_func = 208 HttpRequestHandlerFunc handle_request_func =
208 base::Bind(&HandleRequestOnCmdThread, &handler, whitelisted_ips); 209 base::Bind(&HandleRequestOnCmdThread, &handler, whitelisted_ips);
209 210
210 io_thread.message_loop()->PostTask( 211 io_thread.message_loop()->task_runner()->PostTask(
211 FROM_HERE, 212 FROM_HERE,
212 base::Bind(&StartServerOnIOThread, port, allow_remote, 213 base::Bind(&StartServerOnIOThread, port, allow_remote,
213 base::Bind(&HandleRequestOnIOThread, cmd_loop.task_runner(), 214 base::Bind(&HandleRequestOnIOThread, cmd_loop.task_runner(),
214 handle_request_func))); 215 handle_request_func)));
215 // Run the command loop. This loop is quit after the response for a shutdown 216 // Run the command loop. This loop is quit after the response for a shutdown
216 // request is posted to the IO loop. After the command loop quits, a task 217 // request is posted to the IO loop. After the command loop quits, a task
217 // is posted to the IO loop to stop the server. Lastly, the IO thread is 218 // is posted to the IO loop to stop the server. Lastly, the IO thread is
218 // destroyed, which waits until all pending tasks have been completed. 219 // destroyed, which waits until all pending tasks have been completed.
219 // This assumes the response is sent synchronously as part of the IO task. 220 // This assumes the response is sent synchronously as part of the IO task.
220 cmd_run_loop.Run(); 221 cmd_run_loop.Run();
221 io_thread.message_loop() 222 io_thread.message_loop()->task_runner()->PostTask(
222 ->PostTask(FROM_HERE, base::Bind(&StopServerOnIOThread)); 223 FROM_HERE, base::Bind(&StopServerOnIOThread));
223 } 224 }
224 225
225 } // namespace 226 } // namespace
226 227
227 int main(int argc, char *argv[]) { 228 int main(int argc, char *argv[]) {
228 base::CommandLine::Init(argc, argv); 229 base::CommandLine::Init(argc, argv);
229 230
230 base::AtExitManager at_exit; 231 base::AtExitManager at_exit;
231 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); 232 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess();
232 233
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 } 331 }
331 332
332 if (!InitLogging()) { 333 if (!InitLogging()) {
333 printf("Unable to initialize logging. Exiting...\n"); 334 printf("Unable to initialize logging. Exiting...\n");
334 return 1; 335 return 1;
335 } 336 }
336 RunServer(port, allow_remote, whitelisted_ips, url_base, adb_port, 337 RunServer(port, allow_remote, whitelisted_ips, url_base, adb_port,
337 std::move(port_server)); 338 std::move(port_server));
338 return 0; 339 return 0;
339 } 340 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698