| 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 #ifndef _WIN32 | 7 #ifndef _WIN32 |
| 8 #include <sys/time.h> | 8 #include <sys/time.h> |
| 9 #include <sys/types.h> | 9 #include <sys/types.h> |
| 10 #include <sys/wait.h> | 10 #include <sys/wait.h> |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "chrome/test/webdriver/utility_functions.h" | 31 #include "chrome/test/webdriver/utility_functions.h" |
| 32 #include "chrome/test/webdriver/commands/cookie_commands.h" | 32 #include "chrome/test/webdriver/commands/cookie_commands.h" |
| 33 #include "chrome/test/webdriver/commands/create_session.h" | 33 #include "chrome/test/webdriver/commands/create_session.h" |
| 34 #include "chrome/test/webdriver/commands/execute_command.h" | 34 #include "chrome/test/webdriver/commands/execute_command.h" |
| 35 #include "chrome/test/webdriver/commands/find_element_commands.h" | 35 #include "chrome/test/webdriver/commands/find_element_commands.h" |
| 36 #include "chrome/test/webdriver/commands/implicit_wait_command.h" | 36 #include "chrome/test/webdriver/commands/implicit_wait_command.h" |
| 37 #include "chrome/test/webdriver/commands/navigate_commands.h" | 37 #include "chrome/test/webdriver/commands/navigate_commands.h" |
| 38 #include "chrome/test/webdriver/commands/session_with_id.h" | 38 #include "chrome/test/webdriver/commands/session_with_id.h" |
| 39 #include "chrome/test/webdriver/commands/source_command.h" | 39 #include "chrome/test/webdriver/commands/source_command.h" |
| 40 #include "chrome/test/webdriver/commands/speed_command.h" | 40 #include "chrome/test/webdriver/commands/speed_command.h" |
| 41 #include "chrome/test/webdriver/commands/target_locator_commands.h" |
| 41 #include "chrome/test/webdriver/commands/title_command.h" | 42 #include "chrome/test/webdriver/commands/title_command.h" |
| 42 #include "chrome/test/webdriver/commands/url_command.h" | 43 #include "chrome/test/webdriver/commands/url_command.h" |
| 43 #include "chrome/test/webdriver/commands/webelement_commands.h" | 44 #include "chrome/test/webdriver/commands/webelement_commands.h" |
| 44 #include "third_party/mongoose/mongoose.h" | 45 #include "third_party/mongoose/mongoose.h" |
| 45 | 46 |
| 46 // Make sure we have ho zombies from CGIs. | 47 // Make sure we have ho zombies from CGIs. |
| 47 static void | 48 static void |
| 48 signal_handler(int sig_num) { | 49 signal_handler(int sig_num) { |
| 49 switch (sig_num) { | 50 switch (sig_num) { |
| 50 #ifdef OS_POSIX | 51 #ifdef OS_POSIX |
| (...skipping 21 matching lines...) Expand all Loading... |
| 72 | 73 |
| 73 template <typename CommandType> | 74 template <typename CommandType> |
| 74 void SetCallback(struct mg_context* ctx, const char* pattern) { | 75 void SetCallback(struct mg_context* ctx, const char* pattern) { |
| 75 mg_set_uri_callback(ctx, pattern, &Dispatch<CommandType>, NULL); | 76 mg_set_uri_callback(ctx, pattern, &Dispatch<CommandType>, NULL); |
| 76 } | 77 } |
| 77 | 78 |
| 78 void InitCallbacks(struct mg_context* ctx, | 79 void InitCallbacks(struct mg_context* ctx, |
| 79 base::WaitableEvent* shutdown_event) { | 80 base::WaitableEvent* shutdown_event) { |
| 80 mg_set_uri_callback(ctx, "/shutdown", &Shutdown, shutdown_event); | 81 mg_set_uri_callback(ctx, "/shutdown", &Shutdown, shutdown_event); |
| 81 | 82 |
| 82 SetCallback<CreateSession>(ctx, "/session"); | 83 SetCallback<CreateSession>(ctx, "/session"); |
| 83 SetCallback<BackCommand>(ctx, "/session/*/back"); | 84 SetCallback<BackCommand>(ctx, "/session/*/back"); |
| 84 SetCallback<ExecuteCommand>(ctx, "/session/*/execute"); | 85 SetCallback<ExecuteCommand>(ctx, "/session/*/execute"); |
| 85 SetCallback<ForwardCommand>(ctx, "/session/*/forward"); | 86 SetCallback<ForwardCommand>(ctx, "/session/*/forward"); |
| 86 SetCallback<RefreshCommand>(ctx, "/session/*/refresh"); | 87 SetCallback<RefreshCommand>(ctx, "/session/*/refresh"); |
| 87 SetCallback<SourceCommand>(ctx, "/session/*/source"); | 88 SetCallback<SourceCommand>(ctx, "/session/*/source"); |
| 88 SetCallback<TitleCommand>(ctx, "/session/*/title"); | 89 SetCallback<TitleCommand>(ctx, "/session/*/title"); |
| 89 SetCallback<URLCommand>(ctx, "/session/*/url"); | 90 SetCallback<URLCommand>(ctx, "/session/*/url"); |
| 90 SetCallback<SpeedCommand>(ctx, "/session/*/speed"); | 91 SetCallback<SpeedCommand>(ctx, "/session/*/speed"); |
| 91 SetCallback<ImplicitWaitCommand>(ctx, "/session/*/timeouts/implicit_wait"); | 92 SetCallback<ImplicitWaitCommand>(ctx, "/session/*/timeouts/implicit_wait"); |
| 93 SetCallback<WindowHandleCommand>(ctx, "/session/*/window_handle"); |
| 94 SetCallback<WindowHandlesCommand>(ctx, "/session/*/window_handles"); |
| 95 SetCallback<WindowCommand>(ctx, "/session/*/window"); |
| 96 SetCallback<SwitchFrameCommand>(ctx, "/session/*/frame"); |
| 92 | 97 |
| 93 // Cookie functions. | 98 // Cookie functions. |
| 94 SetCallback<CookieCommand>(ctx, "/session/*/cookie"); | 99 SetCallback<CookieCommand>(ctx, "/session/*/cookie"); |
| 95 SetCallback<NamedCookieCommand>(ctx, "/session/*/cookie/*"); | 100 SetCallback<NamedCookieCommand>(ctx, "/session/*/cookie/*"); |
| 96 | 101 |
| 97 // WebElement commands | 102 // WebElement commands |
| 98 SetCallback<FindOneElementCommand>(ctx, "/session/*/element"); | 103 SetCallback<FindOneElementCommand>(ctx, "/session/*/element"); |
| 99 SetCallback<FindManyElementsCommand>(ctx, "/session/*/elements"); | 104 SetCallback<FindManyElementsCommand>(ctx, "/session/*/elements"); |
| 100 SetCallback<FindOneElementCommand>(ctx, "/session/*/element/*/element"); | 105 SetCallback<FindOneElementCommand>(ctx, "/session/*/element/*/element"); |
| 101 SetCallback<FindManyElementsCommand>(ctx, "/session/*/elements/*/elements"); | 106 SetCallback<FindManyElementsCommand>(ctx, "/session/*/elements/*/elements"); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 | 190 |
| 186 // Run until we receive command to shutdown. | 191 // Run until we receive command to shutdown. |
| 187 shutdown_event.Wait(); | 192 shutdown_event.Wait(); |
| 188 | 193 |
| 189 // We should not reach here since the service should never quit. | 194 // We should not reach here since the service should never quit. |
| 190 // TODO(jmikhail): register a listener for SIGTERM and break the | 195 // TODO(jmikhail): register a listener for SIGTERM and break the |
| 191 // message loop gracefully. | 196 // message loop gracefully. |
| 192 mg_stop(ctx); | 197 mg_stop(ctx); |
| 193 return (EXIT_SUCCESS); | 198 return (EXIT_SUCCESS); |
| 194 } | 199 } |
| OLD | NEW |