Chromium Code Reviews| Index: chrome/test/chromedriver/server/http_handler.h |
| diff --git a/chrome/test/chromedriver/server/http_handler.h b/chrome/test/chromedriver/server/http_handler.h |
| index b7ff044c9336787e7f7493ecc327d6fa10a7617f..020110bd1dde261232592a8ab415879ccf1766ec 100644 |
| --- a/chrome/test/chromedriver/server/http_handler.h |
| +++ b/chrome/test/chromedriver/server/http_handler.h |
| @@ -8,15 +8,26 @@ |
| #include <string> |
| #include <vector> |
| +#include "base/compiler_specific.h" |
| +#include "base/gtest_prod_util.h" |
| #include "base/memory/scoped_ptr.h" |
| +#include "base/threading/thread.h" |
| +#include "chrome/test/chromedriver/command.h" |
| +#include "chrome/test/chromedriver/element_commands.h" |
| +#include "chrome/test/chromedriver/net/sync_websocket_factory.h" |
| +#include "chrome/test/chromedriver/session_commands.h" |
| +#include "chrome/test/chromedriver/session_map.h" |
| +#include "chrome/test/chromedriver/window_commands.h" |
| namespace base { |
| class DictionaryValue; |
| } |
| -class CommandExecutor; |
| -class HttpResponse; |
| +class Adb; |
| +class DeviceManager; |
| class Log; |
| +class HttpResponse; |
| +class URLRequestContextGetter; |
| enum HttpMethod { |
| kGet = 0, |
| @@ -36,53 +47,66 @@ struct HttpRequest { |
| }; |
| struct CommandMapping { |
| + CommandMapping(); |
|
chrisgao (Use stgao instead)
2013/07/02 01:31:40
remove
chrisgao (Use stgao instead)
2013/07/02 18:13:04
Done.
|
| CommandMapping(HttpMethod method, |
| const std::string& path_pattern, |
| - const std::string& name); |
| + const Command& command); |
| ~CommandMapping(); |
| HttpMethod method; |
| std::string path_pattern; |
| - std::string name; |
| + Command command; |
| }; |
| class HttpHandler { |
| public: |
| - typedef std::vector<CommandMapping> CommandMap; |
| - static scoped_ptr<CommandMap> CreateCommandMap(); |
| - |
| - HttpHandler(Log* log, |
| - scoped_ptr<CommandExecutor> executor, |
| - scoped_ptr<std::vector<CommandMapping> > commands, |
| - const std::string& url_base); |
| + HttpHandler(Log* log, const std::string& url_base); |
| ~HttpHandler(); |
| - void Handle(const HttpRequest& request, |
| - HttpResponse* response); |
| - |
| + void Init(); |
|
kkania
2013/07/02 01:57:08
can we remove the init and just do in the construc
chrisgao (Use stgao instead)
2013/07/02 18:13:04
Done.
|
| + void Handle(const HttpRequest& request, HttpResponse* response); |
| bool ShouldShutdown(const HttpRequest& request); |
| private: |
| - void HandleInternal(const HttpRequest& request, |
| - HttpResponse* response); |
| + FRIEND_TEST_ALL_PREFIXES(HttpHandlerTest, HandleUnknownCommand); |
| + FRIEND_TEST_ALL_PREFIXES(HttpHandlerTest, HandleNewSession); |
| + FRIEND_TEST_ALL_PREFIXES(HttpHandlerTest, HandleInvalidPost); |
| + FRIEND_TEST_ALL_PREFIXES(HttpHandlerTest, HandleUnimplementedCommand); |
| + FRIEND_TEST_ALL_PREFIXES(HttpHandlerTest, HandleCommand); |
| + typedef std::vector<CommandMapping> CommandMap; |
| + |
| + Command WrapToNonSessionCommand(const SessionCommand& session_command); |
| + Command WrapToNonSessionCommand(const WindowCommand& window_command); |
| + Command WrapToNonSessionCommand(const ElementCommand& element_command); |
| + void HandleInternal(const HttpRequest& request, HttpResponse* response); |
| bool HandleWebDriverCommand( |
| const HttpRequest& request, |
| const std::string& trimmed_path, |
| HttpResponse* response); |
| Log* log_; |
| - scoped_ptr<CommandExecutor> executor_; |
| - scoped_ptr<CommandMap> command_map_; |
| + base::Thread io_thread_; |
| std::string url_base_; |
| + scoped_refptr<URLRequestContextGetter> context_getter_; |
| + SyncWebSocketFactory socket_factory_; |
| + SessionMap session_map_; |
| + scoped_ptr<CommandMap> command_map_; |
| + scoped_ptr<Adb> adb_; |
| + scoped_ptr<DeviceManager> device_manager_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(HttpHandler); |
| }; |
| namespace internal { |
| -extern const char kNewSessionIdCommand[]; |
| + |
| +extern const char kNewSessionPathPattern[]; |
| + |
| bool MatchesCommand(HttpMethod method, |
| const std::string& path, |
| const CommandMapping& command, |
| std::string* session_id, |
| base::DictionaryValue* out_params); |
| + |
| } // namespace internal |
| #endif // CHROME_TEST_CHROMEDRIVER_SERVER_HTTP_HANDLER_H_ |