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

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

Issue 3750001: base: Move SplitString functions into the base namespace and update the callers. (Closed) Base URL: git://git.chromium.org/chromium.git
Patch Set: brett review, reverted changes in o3d due to it's using an old base revision Created 10 years, 2 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
« no previous file with comments | « chrome/test/ui/ui_test.cc ('k') | chrome/tools/convert_dict/aff_reader.cc » ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <sstream> 8 #include <sstream>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 template<typename CommandType> 42 template<typename CommandType>
43 void Dispatch(struct mg_connection* connection, 43 void Dispatch(struct mg_connection* connection,
44 const struct mg_request_info* request_info, 44 const struct mg_request_info* request_info,
45 void* user_data) { 45 void* user_data) {
46 Response response; 46 Response response;
47 47
48 std::string method(request_info->request_method); 48 std::string method(request_info->request_method);
49 49
50 std::vector<std::string> path_segments; 50 std::vector<std::string> path_segments;
51 std::string uri(request_info->uri); 51 std::string uri(request_info->uri);
52 SplitString(uri, '/', &path_segments); 52 base::SplitString(uri, '/', &path_segments);
53 53
54 DictionaryValue* parameters = NULL; 54 DictionaryValue* parameters = NULL;
55 if ((method == "POST" || method == "PUT") && 55 if ((method == "POST" || method == "PUT") &&
56 request_info->post_data_len > 0) { 56 request_info->post_data_len > 0) {
57 LOG(INFO) << "...parsing request body"; 57 LOG(INFO) << "...parsing request body";
58 std::string json(request_info->post_data, request_info->post_data_len); 58 std::string json(request_info->post_data, request_info->post_data_len);
59 std::string error; 59 std::string error;
60 if (!ParseJSONDictionary(json, &parameters, &error)) { 60 if (!ParseJSONDictionary(json, &parameters, &error)) {
61 response.set_value(Value::CreateStringValue( 61 response.set_value(Value::CreateStringValue(
62 "Failed to parse command data: " + error + "\n Data: " + json)); 62 "Failed to parse command data: " + error + "\n Data: " + json));
63 response.set_status(kBadRequest); 63 response.set_status(kBadRequest);
64 SendResponse(connection, request_info, response); 64 SendResponse(connection, request_info, response);
65 return; 65 return;
66 } 66 }
67 } 67 }
68 68
69 LOG(INFO) << "Dispatching " << method << " " << uri 69 LOG(INFO) << "Dispatching " << method << " " << uri
70 << std::string(request_info->post_data, 70 << std::string(request_info->post_data,
71 request_info->post_data_len) << std::endl; 71 request_info->post_data_len) << std::endl;
72 scoped_ptr<CommandType> ptr(new CommandType(path_segments, parameters)); 72 scoped_ptr<CommandType> ptr(new CommandType(path_segments, parameters));
73 DispatchCommand(ptr.get(), method, &response); 73 DispatchCommand(ptr.get(), method, &response);
74 SendResponse(connection, request_info, response); 74 SendResponse(connection, request_info, response);
75 } 75 }
76 76
77 } // namespace webdriver 77 } // namespace webdriver
78 78
79 #endif // CHROME_TEST_WEBDRIVER_DISPATCH_H_ 79 #endif // CHROME_TEST_WEBDRIVER_DISPATCH_H_
80 80
OLDNEW
« no previous file with comments | « chrome/test/ui/ui_test.cc ('k') | chrome/tools/convert_dict/aff_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698