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

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

Issue 1240183002: Update SplitString calls in chrome. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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
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 #include "chrome/test/chromedriver/server/http_handler.h" 5 #include "chrome/test/chromedriver/server/http_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 } 735 }
736 736
737 bool MatchesCommand(const std::string& method, 737 bool MatchesCommand(const std::string& method,
738 const std::string& path, 738 const std::string& path,
739 const CommandMapping& command, 739 const CommandMapping& command,
740 std::string* session_id, 740 std::string* session_id,
741 base::DictionaryValue* out_params) { 741 base::DictionaryValue* out_params) {
742 if (!MatchesMethod(command.method, method)) 742 if (!MatchesMethod(command.method, method))
743 return false; 743 return false;
744 744
745 std::vector<std::string> path_parts; 745 std::vector<std::string> path_parts = base::SplitString(
746 base::SplitString(path, '/', &path_parts); 746 path, "/", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
747 std::vector<std::string> command_path_parts; 747 std::vector<std::string> command_path_parts = base::SplitString(
748 base::SplitString(command.path_pattern, '/', &command_path_parts); 748 command.path_pattern, "/", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
749 if (path_parts.size() != command_path_parts.size()) 749 if (path_parts.size() != command_path_parts.size())
750 return false; 750 return false;
751 751
752 base::DictionaryValue params; 752 base::DictionaryValue params;
753 for (size_t i = 0; i < path_parts.size(); ++i) { 753 for (size_t i = 0; i < path_parts.size(); ++i) {
754 CHECK(command_path_parts[i].length()); 754 CHECK(command_path_parts[i].length());
755 if (command_path_parts[i][0] == ':') { 755 if (command_path_parts[i][0] == ':') {
756 std::string name = command_path_parts[i]; 756 std::string name = command_path_parts[i];
757 name.erase(0, 1); 757 name.erase(0, 1);
758 CHECK(name.length()); 758 CHECK(name.length());
759 if (name == "sessionId") 759 if (name == "sessionId")
760 *session_id = path_parts[i]; 760 *session_id = path_parts[i];
761 else 761 else
762 params.SetString(name, path_parts[i]); 762 params.SetString(name, path_parts[i]);
763 } else if (command_path_parts[i] != path_parts[i]) { 763 } else if (command_path_parts[i] != path_parts[i]) {
764 return false; 764 return false;
765 } 765 }
766 } 766 }
767 out_params->MergeDictionary(&params); 767 out_params->MergeDictionary(&params);
768 return true; 768 return true;
769 } 769 }
770 770
771 } // namespace internal 771 } // namespace internal
OLDNEW
« no previous file with comments | « chrome/test/chromedriver/server/chromedriver_server.cc ('k') | chrome/tools/convert_dict/aff_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698