| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_CHROMEDRIVER_SERVER_HTTP_HANDLER_H_ | 5 #ifndef CHROME_TEST_CHROMEDRIVER_SERVER_HTTP_HANDLER_H_ |
| 6 #define CHROME_TEST_CHROMEDRIVER_SERVER_HTTP_HANDLER_H_ | 6 #define CHROME_TEST_CHROMEDRIVER_SERVER_HTTP_HANDLER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 class SingleThreadTaskRunner; | 28 class SingleThreadTaskRunner; |
| 29 } | 29 } |
| 30 | 30 |
| 31 namespace net { | 31 namespace net { |
| 32 class HttpServerRequestInfo; | 32 class HttpServerRequestInfo; |
| 33 class HttpServerResponseInfo; | 33 class HttpServerResponseInfo; |
| 34 } | 34 } |
| 35 | 35 |
| 36 class Adb; | 36 class Adb; |
| 37 class DeviceManager; | 37 class DeviceManager; |
| 38 class Log; | |
| 39 class URLRequestContextGetter; | 38 class URLRequestContextGetter; |
| 40 | 39 |
| 41 enum HttpMethod { | 40 enum HttpMethod { |
| 42 kGet, | 41 kGet, |
| 43 kPost, | 42 kPost, |
| 44 kDelete, | 43 kDelete, |
| 45 }; | 44 }; |
| 46 | 45 |
| 47 struct CommandMapping { | 46 struct CommandMapping { |
| 48 CommandMapping(HttpMethod method, | 47 CommandMapping(HttpMethod method, |
| 49 const std::string& path_pattern, | 48 const std::string& path_pattern, |
| 50 const Command& command); | 49 const Command& command); |
| 51 ~CommandMapping(); | 50 ~CommandMapping(); |
| 52 | 51 |
| 53 HttpMethod method; | 52 HttpMethod method; |
| 54 std::string path_pattern; | 53 std::string path_pattern; |
| 55 Command command; | 54 Command command; |
| 56 }; | 55 }; |
| 57 | 56 |
| 58 typedef base::Callback<void(scoped_ptr<net::HttpServerResponseInfo>)> | 57 typedef base::Callback<void(scoped_ptr<net::HttpServerResponseInfo>)> |
| 59 HttpResponseSenderFunc; | 58 HttpResponseSenderFunc; |
| 60 | 59 |
| 61 class HttpHandler { | 60 class HttpHandler { |
| 62 public: | 61 public: |
| 63 HttpHandler(Log* log, const std::string& url_base); | 62 explicit HttpHandler(const std::string& url_base); |
| 64 HttpHandler(const base::Closure& quit_func, | 63 HttpHandler(const base::Closure& quit_func, |
| 65 const scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, | 64 const scoped_refptr<base::SingleThreadTaskRunner> io_task_runner, |
| 66 Log* log, | |
| 67 const std::string& url_base, | 65 const std::string& url_base, |
| 68 int adb_port); | 66 int adb_port); |
| 69 ~HttpHandler(); | 67 ~HttpHandler(); |
| 70 | 68 |
| 71 void Handle(const net::HttpServerRequestInfo& request, | 69 void Handle(const net::HttpServerRequestInfo& request, |
| 72 const HttpResponseSenderFunc& send_response_func); | 70 const HttpResponseSenderFunc& send_response_func); |
| 73 | 71 |
| 74 private: | 72 private: |
| 75 FRIEND_TEST_ALL_PREFIXES(HttpHandlerTest, HandleUnknownCommand); | 73 FRIEND_TEST_ALL_PREFIXES(HttpHandlerTest, HandleUnknownCommand); |
| 76 FRIEND_TEST_ALL_PREFIXES(HttpHandlerTest, HandleNewSession); | 74 FRIEND_TEST_ALL_PREFIXES(HttpHandlerTest, HandleNewSession); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 91 scoped_ptr<base::Value> value, | 89 scoped_ptr<base::Value> value, |
| 92 const std::string& session_id); | 90 const std::string& session_id); |
| 93 scoped_ptr<net::HttpServerResponseInfo> PrepareResponseHelper( | 91 scoped_ptr<net::HttpServerResponseInfo> PrepareResponseHelper( |
| 94 const std::string& trimmed_path, | 92 const std::string& trimmed_path, |
| 95 const Status& status, | 93 const Status& status, |
| 96 scoped_ptr<base::Value> value, | 94 scoped_ptr<base::Value> value, |
| 97 const std::string& session_id); | 95 const std::string& session_id); |
| 98 | 96 |
| 99 base::ThreadChecker thread_checker_; | 97 base::ThreadChecker thread_checker_; |
| 100 base::Closure quit_func_; | 98 base::Closure quit_func_; |
| 101 Log* log_; | |
| 102 std::string url_base_; | 99 std::string url_base_; |
| 103 bool received_shutdown_; | 100 bool received_shutdown_; |
| 104 scoped_refptr<URLRequestContextGetter> context_getter_; | 101 scoped_refptr<URLRequestContextGetter> context_getter_; |
| 105 SyncWebSocketFactory socket_factory_; | 102 SyncWebSocketFactory socket_factory_; |
| 106 SessionThreadMap session_thread_map_; | 103 SessionThreadMap session_thread_map_; |
| 107 scoped_ptr<CommandMap> command_map_; | 104 scoped_ptr<CommandMap> command_map_; |
| 108 scoped_ptr<Adb> adb_; | 105 scoped_ptr<Adb> adb_; |
| 109 scoped_ptr<DeviceManager> device_manager_; | 106 scoped_ptr<DeviceManager> device_manager_; |
| 110 | 107 |
| 111 base::WeakPtrFactory<HttpHandler> weak_ptr_factory_; | 108 base::WeakPtrFactory<HttpHandler> weak_ptr_factory_; |
| 112 | 109 |
| 113 DISALLOW_COPY_AND_ASSIGN(HttpHandler); | 110 DISALLOW_COPY_AND_ASSIGN(HttpHandler); |
| 114 }; | 111 }; |
| 115 | 112 |
| 116 namespace internal { | 113 namespace internal { |
| 117 | 114 |
| 118 extern const char kNewSessionPathPattern[]; | 115 extern const char kNewSessionPathPattern[]; |
| 119 | 116 |
| 120 bool MatchesCommand(const std::string& method, | 117 bool MatchesCommand(const std::string& method, |
| 121 const std::string& path, | 118 const std::string& path, |
| 122 const CommandMapping& command, | 119 const CommandMapping& command, |
| 123 std::string* session_id, | 120 std::string* session_id, |
| 124 base::DictionaryValue* out_params); | 121 base::DictionaryValue* out_params); |
| 125 | 122 |
| 126 } // namespace internal | 123 } // namespace internal |
| 127 | 124 |
| 128 #endif // CHROME_TEST_CHROMEDRIVER_SERVER_HTTP_HANDLER_H_ | 125 #endif // CHROME_TEST_CHROMEDRIVER_SERVER_HTTP_HANDLER_H_ |
| OLD | NEW |