| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_TEST_WEBDRIVER_DISPATCH_H_ | 5 #ifndef CHROME_TEST_WEBDRIVER_DISPATCH_H_ |
| 6 #define CHROME_TEST_WEBDRIVER_DISPATCH_H_ | 6 #define CHROME_TEST_WEBDRIVER_DISPATCH_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 void Add(const std::string& pattern); | 93 void Add(const std::string& pattern); |
| 94 | 94 |
| 95 // Registers a callback that will shutdown the server. When any HTTP request | 95 // Registers a callback that will shutdown the server. When any HTTP request |
| 96 // is received at this URL |pattern|, the |shutdown_event| will be signaled. | 96 // is received at this URL |pattern|, the |shutdown_event| will be signaled. |
| 97 void AddShutdown(const std::string& pattern, | 97 void AddShutdown(const std::string& pattern, |
| 98 base::WaitableEvent* shutdown_event); | 98 base::WaitableEvent* shutdown_event); |
| 99 | 99 |
| 100 // Registers a callback for the given pattern that will return a simple | 100 // Registers a callback for the given pattern that will return a simple |
| 101 // "HTTP/1.1 200 OK" message with "ok" in the body. Used for checking the | 101 // "HTTP/1.1 200 OK" message with "ok" in the body. Used for checking the |
| 102 // status of the server. | 102 // status of the server. |
| 103 void AddStatus(const std::string& pattern); | 103 void AddHealthz(const std::string& pattern); |
| 104 |
| 105 // Registers a callback for the given pattern that will return the current |
| 106 // WebDriver log contents. |
| 107 void AddLog(const std::string& pattern); |
| 104 | 108 |
| 105 // Registers a callback that will always respond with a | 109 // Registers a callback that will always respond with a |
| 106 // "HTTP/1.1 501 Not Implemented" message. | 110 // "HTTP/1.1 501 Not Implemented" message. |
| 107 void SetNotImplemented(const std::string& pattern); | 111 void SetNotImplemented(const std::string& pattern); |
| 108 | 112 |
| 109 // Registers a callback that will respond for all other requests with a | 113 // Registers a callback that will respond for all other requests with a |
| 110 // "HTTP/1.1 403 Forbidden" message. Should be called only after registering | 114 // "HTTP/1.1 403 Forbidden" message. Should be called only after registering |
| 111 // other callbacks. | 115 // other callbacks. |
| 112 void ForbidAllOtherRequests(); | 116 void ForbidAllOtherRequests(); |
| 113 | 117 |
| 114 private: | 118 private: |
| 115 struct mg_context* context_; | 119 struct mg_context* context_; |
| 116 const std::string root_; | 120 const std::string root_; |
| 117 | 121 |
| 118 DISALLOW_COPY_AND_ASSIGN(Dispatcher); | 122 DISALLOW_COPY_AND_ASSIGN(Dispatcher); |
| 119 }; | 123 }; |
| 120 | 124 |
| 121 | 125 |
| 122 template <typename CommandType> | 126 template <typename CommandType> |
| 123 void Dispatcher::Add(const std::string& pattern) { | 127 void Dispatcher::Add(const std::string& pattern) { |
| 124 mg_set_uri_callback(context_, (root_ + pattern).c_str(), | 128 mg_set_uri_callback(context_, (root_ + pattern).c_str(), |
| 125 &Dispatch<CommandType>, NULL); | 129 &Dispatch<CommandType>, NULL); |
| 126 } | 130 } |
| 127 | 131 |
| 128 } // namespace webdriver | 132 } // namespace webdriver |
| 129 | 133 |
| 130 #endif // CHROME_TEST_WEBDRIVER_DISPATCH_H_ | 134 #endif // CHROME_TEST_WEBDRIVER_DISPATCH_H_ |
| OLD | NEW |