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

Side by Side Diff: chrome/test/webdriver/dispatch.h

Issue 7259019: Move base/values.h into the base namespace. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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
« no previous file with comments | « chrome/test/webdriver/commands/webelement_commands.h ('k') | chrome/test/webdriver/session.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "chrome/test/webdriver/commands/response.h" 13 #include "chrome/test/webdriver/commands/response.h"
14 #include "third_party/mongoose/mongoose.h" 14 #include "third_party/mongoose/mongoose.h"
15 15
16 namespace base {
16 class DictionaryValue; 17 class DictionaryValue;
17
18 namespace base {
19 class WaitableEvent; 18 class WaitableEvent;
20 } 19 }
21 20
22 namespace webdriver { 21 namespace webdriver {
23 22
24 class Command; 23 class Command;
25 class HttpResponse; 24 class HttpResponse;
26 25
27 namespace internal { 26 namespace internal {
28 27
29 // Converts a |Response| into a |HttpResponse| to be returned to the client. 28 // Converts a |Response| into a |HttpResponse| to be returned to the client.
30 // This function is exposed for testing. 29 // This function is exposed for testing.
31 void PrepareHttpResponse(const Response& command_response, 30 void PrepareHttpResponse(const Response& command_response,
32 HttpResponse* const http_response); 31 HttpResponse* const http_response);
33 32
34 // Sends a |response| to a WebDriver command back to the client. 33 // Sends a |response| to a WebDriver command back to the client.
35 // |connection| is the communication pipe to the HTTP server and 34 // |connection| is the communication pipe to the HTTP server and
36 // |request_info| contains any data sent by the user. 35 // |request_info| contains any data sent by the user.
37 void SendResponse(struct mg_connection* const connection, 36 void SendResponse(struct mg_connection* const connection,
38 const std::string& request_method, 37 const std::string& request_method,
39 const Response& response); 38 const Response& response);
40 39
41 // Parses the request info and returns whether parsing was successful. If not, 40 // Parses the request info and returns whether parsing was successful. If not,
42 // |response| has been modified with the error. 41 // |response| has been modified with the error.
43 bool ParseRequestInfo(const struct mg_request_info* const request_info, 42 bool ParseRequestInfo(const struct mg_request_info* const request_info,
44 std::string* method, 43 std::string* method,
45 std::vector<std::string>* path_segments, 44 std::vector<std::string>* path_segments,
46 DictionaryValue** parameters, 45 base::DictionaryValue** parameters,
47 Response* const response); 46 Response* const response);
48 47
49 // Allows the bulk of the implementation of |Dispatch| to be moved out of this 48 // Allows the bulk of the implementation of |Dispatch| to be moved out of this
50 // header file. Takes ownership of |command|. 49 // header file. Takes ownership of |command|.
51 void DispatchHelper(Command* const command, 50 void DispatchHelper(Command* const command,
52 const std::string& method, 51 const std::string& method,
53 Response* const response); 52 Response* const response);
54 53
55 } // namespace internal 54 } // namespace internal
56 55
57 // Template function for dispatching commands sent to the WebDriver REST 56 // Template function for dispatching commands sent to the WebDriver REST
58 // service. |CommandType| must be a subtype of |webdriver::Command|. 57 // service. |CommandType| must be a subtype of |webdriver::Command|.
59 template<typename CommandType> 58 template<typename CommandType>
60 void Dispatch(struct mg_connection* connection, 59 void Dispatch(struct mg_connection* connection,
61 const struct mg_request_info* request_info, 60 const struct mg_request_info* request_info,
62 void* user_data) { 61 void* user_data) {
63 std::string method; 62 std::string method;
64 std::vector<std::string> path_segments; 63 std::vector<std::string> path_segments;
65 DictionaryValue* parameters = NULL; 64 base::DictionaryValue* parameters = NULL;
66 Response response; 65 Response response;
67 if (internal::ParseRequestInfo(request_info, 66 if (internal::ParseRequestInfo(request_info,
68 &method, 67 &method,
69 &path_segments, 68 &path_segments,
70 &parameters, 69 &parameters,
71 &response)) { 70 &response)) {
72 std::string post_data(request_info->post_data, request_info->post_data_len); 71 std::string post_data(request_info->post_data, request_info->post_data_len);
73 LOG(INFO) << "Received command, url: " << request_info->uri 72 LOG(INFO) << "Received command, url: " << request_info->uri
74 << ", method: " << request_info->request_method 73 << ", method: " << request_info->request_method
75 << ", postd data: " << post_data; 74 << ", postd data: " << post_data;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 129
131 template <typename CommandType> 130 template <typename CommandType>
132 void Dispatcher::Add(const std::string& pattern) { 131 void Dispatcher::Add(const std::string& pattern) {
133 mg_set_uri_callback(context_, (root_ + pattern).c_str(), 132 mg_set_uri_callback(context_, (root_ + pattern).c_str(),
134 &Dispatch<CommandType>, NULL); 133 &Dispatch<CommandType>, NULL);
135 } 134 }
136 135
137 } // namespace webdriver 136 } // namespace webdriver
138 137
139 #endif // CHROME_TEST_WEBDRIVER_DISPATCH_H_ 138 #endif // CHROME_TEST_WEBDRIVER_DISPATCH_H_
OLDNEW
« no previous file with comments | « chrome/test/webdriver/commands/webelement_commands.h ('k') | chrome/test/webdriver/session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698