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