| OLD | NEW |
| 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 <stdio.h> | 5 #include <stdio.h> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/at_exit.h" | 9 #include "base/at_exit.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 16 #include "base/synchronization/waitable_event.h" | 16 #include "base/synchronization/waitable_event.h" |
| 17 #include "chrome/test/chromedriver/chrome/log.h" | 17 #include "chrome/test/chromedriver/chrome/log.h" |
| 18 #include "chrome/test/chromedriver/chrome/version.h" | 18 #include "chrome/test/chromedriver/chrome/version.h" |
| 19 #include "chrome/test/chromedriver/command_executor_impl.h" | |
| 20 #include "chrome/test/chromedriver/server/http_handler.h" | 19 #include "chrome/test/chromedriver/server/http_handler.h" |
| 21 #include "chrome/test/chromedriver/server/http_response.h" | 20 #include "chrome/test/chromedriver/server/http_response.h" |
| 22 #include "third_party/mongoose/mongoose.h" | 21 #include "third_party/mongoose/mongoose.h" |
| 23 | 22 |
| 24 #if defined(OS_POSIX) | 23 #if defined(OS_POSIX) |
| 25 #include <fcntl.h> | 24 #include <fcntl.h> |
| 26 #include <unistd.h> | 25 #include <unistd.h> |
| 27 #endif | 26 #endif |
| 28 | 27 |
| 29 namespace { | 28 namespace { |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 PLOG(ERROR) << "Unable to initialize logging"; | 173 PLOG(ERROR) << "Unable to initialize logging"; |
| 175 } | 174 } |
| 176 logging::SetLogItems(false, // enable_process_id | 175 logging::SetLogItems(false, // enable_process_id |
| 177 false, // enable_thread_id | 176 false, // enable_thread_id |
| 178 false, // enable_timestamp | 177 false, // enable_timestamp |
| 179 false); // enable_tickcount | 178 false); // enable_tickcount |
| 180 if (!cmd_line->HasSwitch("verbose")) | 179 if (!cmd_line->HasSwitch("verbose")) |
| 181 logging::SetMinLogLevel(logging::LOG_FATAL); | 180 logging::SetMinLogLevel(logging::LOG_FATAL); |
| 182 | 181 |
| 183 scoped_ptr<Log> log(new Logger(log_level)); | 182 scoped_ptr<Log> log(new Logger(log_level)); |
| 184 scoped_ptr<CommandExecutor> executor(new CommandExecutorImpl(log.get())); | 183 HttpHandler handler(log.get(), url_base); |
| 185 HttpHandler handler( | |
| 186 log.get(), executor.Pass(), HttpHandler::CreateCommandMap(), url_base); | |
| 187 base::WaitableEvent shutdown_event(false, false); | 184 base::WaitableEvent shutdown_event(false, false); |
| 188 MongooseUserData user_data = { &handler, &shutdown_event }; | 185 MongooseUserData user_data = { &handler, &shutdown_event }; |
| 189 | 186 |
| 190 std::vector<std::string> args; | 187 std::vector<std::string> args; |
| 191 MakeMongooseOptions(port, http_threads, &args); | 188 MakeMongooseOptions(port, http_threads, &args); |
| 192 scoped_ptr<const char*[]> options(new const char*[args.size() + 1]); | 189 scoped_ptr<const char*[]> options(new const char*[args.size() + 1]); |
| 193 for (size_t i = 0; i < args.size(); ++i) { | 190 for (size_t i = 0; i < args.size(); ++i) { |
| 194 options[i] = args[i].c_str(); | 191 options[i] = args[i].c_str(); |
| 195 } | 192 } |
| 196 options[args.size()] = NULL; | 193 options[args.size()] = NULL; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 214 // Close stderr on exec, so that Chrome log spew doesn't confuse users. | 211 // Close stderr on exec, so that Chrome log spew doesn't confuse users. |
| 215 fcntl(STDERR_FILENO, F_SETFD, FD_CLOEXEC); | 212 fcntl(STDERR_FILENO, F_SETFD, FD_CLOEXEC); |
| 216 } | 213 } |
| 217 #endif | 214 #endif |
| 218 | 215 |
| 219 // Run until we receive command to shutdown. | 216 // Run until we receive command to shutdown. |
| 220 shutdown_event.Wait(); | 217 shutdown_event.Wait(); |
| 221 | 218 |
| 222 return 0; | 219 return 0; |
| 223 } | 220 } |
| OLD | NEW |