| OLD | NEW | 
|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <signal.h> | 5 #include <signal.h> | 
| 6 #include <stdlib.h> | 6 #include <stdlib.h> | 
| 7 | 7 | 
| 8 #if defined(OS_WIN) | 8 #if defined(OS_WIN) | 
| 9 #include <windows.h> | 9 #include <windows.h> | 
| 10 #endif | 10 #endif | 
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 201       std::cout << "Given Chrome directory is inaccessible or does not exist: " | 201       std::cout << "Given Chrome directory is inaccessible or does not exist: " | 
| 202                 << chrome_dir.value() << std::endl; | 202                 << chrome_dir.value() << std::endl; | 
| 203 #if defined(OS_WIN) | 203 #if defined(OS_WIN) | 
| 204       return ERROR_PATH_NOT_FOUND; | 204       return ERROR_PATH_NOT_FOUND; | 
| 205 #else | 205 #else | 
| 206       return ENOENT; | 206       return ENOENT; | 
| 207 #endif | 207 #endif | 
| 208     } | 208     } | 
| 209     manager->set_chrome_dir(chrome_dir); | 209     manager->set_chrome_dir(chrome_dir); | 
| 210   } | 210   } | 
|  | 211   if (cmd_line->HasSwitch("native-events")) | 
|  | 212     manager->set_use_native_events(true); | 
| 211 | 213 | 
| 212   // Initialize SHTTPD context. | 214   // Initialize SHTTPD context. | 
| 213   // Listen on port 9515 or port specified on command line. | 215   // Listen on port 9515 or port specified on command line. | 
| 214   // TODO(jmikhail) Maybe add port 9516 as a secure connection. | 216   // TODO(jmikhail) Maybe add port 9516 as a secure connection. | 
| 215   ctx = mg_start(); | 217   ctx = mg_start(); | 
| 216   if (!SetMongooseOptions(ctx, port, root)) { | 218   if (!SetMongooseOptions(ctx, port, root)) { | 
| 217     mg_stop(ctx); | 219     mg_stop(ctx); | 
| 218 #if defined(OS_WIN) | 220 #if defined(OS_WIN) | 
| 219     return WSAEADDRINUSE; | 221     return WSAEADDRINUSE; | 
| 220 #else | 222 #else | 
| 221     return EADDRINUSE; | 223     return EADDRINUSE; | 
| 222 #endif | 224 #endif | 
| 223   } | 225   } | 
| 224 | 226 | 
| 225   webdriver::Dispatcher dispatcher(ctx, url_base); | 227   webdriver::Dispatcher dispatcher(ctx, url_base); | 
| 226   webdriver::InitCallbacks(ctx, &dispatcher, &shutdown_event); | 228   webdriver::InitCallbacks(ctx, &dispatcher, &shutdown_event); | 
| 227 | 229 | 
| 228   // The tests depend on parsing the first line ChromeDriver outputs, | 230   // The tests depend on parsing the first line ChromeDriver outputs, | 
| 229   // so all other logging should happen after this. | 231   // so all other logging should happen after this. | 
| 230   std::cout << "Started ChromeDriver" << std::endl | 232   std::cout << "Started ChromeDriver" << std::endl | 
| 231             << "port=" << port << std::endl; | 233             << "port=" << port << std::endl; | 
|  | 234   if (manager->use_native_events()) { | 
|  | 235     std::cout << "Using native events" << std::endl; | 
|  | 236   } | 
| 232 | 237 | 
| 233   if (root.length()) { | 238   if (root.length()) { | 
| 234     VLOG(1) << "Serving files from the current working directory"; | 239     VLOG(1) << "Serving files from the current working directory"; | 
| 235   } | 240   } | 
| 236   if (!chrome_dir.empty()) { | 241   if (!chrome_dir.empty()) { | 
| 237     VLOG(1) << "Using Chrome inside directory: " << chrome_dir.value(); | 242     VLOG(1) << "Using Chrome inside directory: " << chrome_dir.value(); | 
| 238   } | 243   } | 
| 239 | 244 | 
| 240   // Run until we receive command to shutdown. | 245   // Run until we receive command to shutdown. | 
| 241   shutdown_event.Wait(); | 246   shutdown_event.Wait(); | 
| 242 | 247 | 
| 243   // We should not reach here since the service should never quit. | 248   // We should not reach here since the service should never quit. | 
| 244   // TODO(jmikhail): register a listener for SIGTERM and break the | 249   // TODO(jmikhail): register a listener for SIGTERM and break the | 
| 245   // message loop gracefully. | 250   // message loop gracefully. | 
| 246   mg_stop(ctx); | 251   mg_stop(ctx); | 
| 247   return (EXIT_SUCCESS); | 252   return (EXIT_SUCCESS); | 
| 248 } | 253 } | 
| OLD | NEW | 
|---|