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..4666c5901dd0db1c242954d86d0422a19981ab4c 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, |
@@ -38,51 +49,62 @@ struct HttpRequest { |
struct CommandMapping { |
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 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 WrapToCommand(const SessionCommand& session_command); |
+ Command WrapToCommand(const WindowCommand& window_command); |
+ Command WrapToCommand(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_ |