Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(32)

Side by Side Diff: chrome/test/chromedriver/server/http_handler.h

Issue 18419003: [chromedriver] Remove dll build target. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
11 #include "base/compiler_specific.h"
12 #include "base/gtest_prod_util.h"
11 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/threading/thread.h"
15 #include "chrome/test/chromedriver/command.h"
16 #include "chrome/test/chromedriver/element_commands.h"
17 #include "chrome/test/chromedriver/net/sync_websocket_factory.h"
18 #include "chrome/test/chromedriver/session_commands.h"
19 #include "chrome/test/chromedriver/session_map.h"
20 #include "chrome/test/chromedriver/window_commands.h"
12 21
13 namespace base { 22 namespace base {
14 class DictionaryValue; 23 class DictionaryValue;
15 } 24 }
16 25
17 class CommandExecutor; 26 class Adb;
27 class DeviceManager;
28 class Log;
18 class HttpResponse; 29 class HttpResponse;
19 class Log; 30 class URLRequestContextGetter;
20 31
21 enum HttpMethod { 32 enum HttpMethod {
22 kGet = 0, 33 kGet = 0,
23 kPost, 34 kPost,
24 kDelete, 35 kDelete,
25 }; 36 };
26 37
27 struct HttpRequest { 38 struct HttpRequest {
28 HttpRequest(HttpMethod method, 39 HttpRequest(HttpMethod method,
29 const std::string& path, 40 const std::string& path,
30 const std::string& body); 41 const std::string& body);
31 ~HttpRequest(); 42 ~HttpRequest();
32 43
33 HttpMethod method; 44 HttpMethod method;
34 std::string path; 45 std::string path;
35 std::string body; 46 std::string body;
36 }; 47 };
37 48
38 struct CommandMapping { 49 struct CommandMapping {
39 CommandMapping(HttpMethod method, 50 CommandMapping(HttpMethod method,
40 const std::string& path_pattern, 51 const std::string& path_pattern,
41 const std::string& name); 52 const Command& command);
42 ~CommandMapping(); 53 ~CommandMapping();
43 54
44 HttpMethod method; 55 HttpMethod method;
45 std::string path_pattern; 56 std::string path_pattern;
46 std::string name; 57 Command command;
47 }; 58 };
48 59
49 class HttpHandler { 60 class HttpHandler {
50 public: 61 public:
51 typedef std::vector<CommandMapping> CommandMap; 62 HttpHandler(Log* log, const std::string& url_base);
52 static scoped_ptr<CommandMap> CreateCommandMap();
53
54 HttpHandler(Log* log,
55 scoped_ptr<CommandExecutor> executor,
56 scoped_ptr<std::vector<CommandMapping> > commands,
57 const std::string& url_base);
58 ~HttpHandler(); 63 ~HttpHandler();
59 64
60 void Handle(const HttpRequest& request, 65 void Handle(const HttpRequest& request, HttpResponse* response);
61 HttpResponse* response);
62
63 bool ShouldShutdown(const HttpRequest& request); 66 bool ShouldShutdown(const HttpRequest& request);
64 67
65 private: 68 private:
66 void HandleInternal(const HttpRequest& request, 69 FRIEND_TEST_ALL_PREFIXES(HttpHandlerTest, HandleUnknownCommand);
67 HttpResponse* response); 70 FRIEND_TEST_ALL_PREFIXES(HttpHandlerTest, HandleNewSession);
71 FRIEND_TEST_ALL_PREFIXES(HttpHandlerTest, HandleInvalidPost);
72 FRIEND_TEST_ALL_PREFIXES(HttpHandlerTest, HandleUnimplementedCommand);
73 FRIEND_TEST_ALL_PREFIXES(HttpHandlerTest, HandleCommand);
74 typedef std::vector<CommandMapping> CommandMap;
75
76 Command WrapToCommand(const SessionCommand& session_command);
77 Command WrapToCommand(const WindowCommand& window_command);
78 Command WrapToCommand(const ElementCommand& element_command);
79 void HandleInternal(const HttpRequest& request, HttpResponse* response);
68 bool HandleWebDriverCommand( 80 bool HandleWebDriverCommand(
69 const HttpRequest& request, 81 const HttpRequest& request,
70 const std::string& trimmed_path, 82 const std::string& trimmed_path,
71 HttpResponse* response); 83 HttpResponse* response);
72 84
73 Log* log_; 85 Log* log_;
74 scoped_ptr<CommandExecutor> executor_; 86 base::Thread io_thread_;
87 std::string url_base_;
88 scoped_refptr<URLRequestContextGetter> context_getter_;
89 SyncWebSocketFactory socket_factory_;
90 SessionMap session_map_;
75 scoped_ptr<CommandMap> command_map_; 91 scoped_ptr<CommandMap> command_map_;
76 std::string url_base_; 92 scoped_ptr<Adb> adb_;
93 scoped_ptr<DeviceManager> device_manager_;
94
95 DISALLOW_COPY_AND_ASSIGN(HttpHandler);
77 }; 96 };
78 97
79 namespace internal { 98 namespace internal {
80 extern const char kNewSessionIdCommand[]; 99
100 extern const char kNewSessionPathPattern[];
101
81 bool MatchesCommand(HttpMethod method, 102 bool MatchesCommand(HttpMethod method,
82 const std::string& path, 103 const std::string& path,
83 const CommandMapping& command, 104 const CommandMapping& command,
84 std::string* session_id, 105 std::string* session_id,
85 base::DictionaryValue* out_params); 106 base::DictionaryValue* out_params);
107
86 } // namespace internal 108 } // namespace internal
87 109
88 #endif // CHROME_TEST_CHROMEDRIVER_SERVER_HTTP_HANDLER_H_ 110 #endif // CHROME_TEST_CHROMEDRIVER_SERVER_HTTP_HANDLER_H_
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/server/chromedriver_server.cc ('k') | chrome/test/chromedriver/server/http_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698