summaryrefslogtreecommitdiffstats
path: root/base/string_util.cc
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-23 02:25:03 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-23 02:25:03 +0000
commita6b4150dd637f4b6986a58da63cc0c7192af3cc6 (patch)
treefae5bcad1ec3ab2681e01930fd700c640fe2c3f7 /base/string_util.cc
parent270a0c24f933fb8297389b98efdd035040c6def3 (diff)
downloadchromium_src-a6b4150dd637f4b6986a58da63cc0c7192af3cc6.zip
chromium_src-a6b4150dd637f4b6986a58da63cc0c7192af3cc6.tar.gz
chromium_src-a6b4150dd637f4b6986a58da63cc0c7192af3cc6.tar.bz2
HttpRequestHeaders refactor.
* Create HttpRequestHeaders. * Switch HttpNetworkTransaction to build request headers. TODO: Change extra_headers to use HttpRequestHeaders. BUG=22588 Review URL: http://codereview.chromium.org/1039001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42300 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/string_util.cc')
-rw-r--r--base/string_util.cc48
1 files changed, 48 insertions, 0 deletions
diff --git a/base/string_util.cc b/base/string_util.cc
index 19c1735..494d09d 100644
--- a/base/string_util.cc
+++ b/base/string_util.cc
@@ -1324,6 +1324,54 @@ void SplitStringDontTrim(const std::string& str,
SplitStringT(str, s, false, r);
}
+template <typename STR>
+static void SplitStringUsingSubstrT(const STR& str,
+ const STR& s,
+ std::vector<STR>* r) {
+ typename STR::size_type begin_index = 0;
+ while (true) {
+ const typename STR::size_type end_index = str.find(s, begin_index);
+ if (end_index == STR::npos) {
+ const STR term = str.substr(begin_index);
+ STR tmp;
+ TrimWhitespace(term, TRIM_ALL, &tmp);
+ r->push_back(tmp);
+ return;
+ }
+ const STR term = str.substr(begin_index, end_index - begin_index);
+ STR tmp;
+ TrimWhitespace(term, TRIM_ALL, &tmp);
+ r->push_back(tmp);
+ begin_index = end_index + s.size();
+ }
+}
+
+void SplitStringUsingSubstr(const string16& str,
+ const string16& s,
+ std::vector<string16>* r) {
+ SplitStringUsingSubstrT(str, s, r);
+}
+
+void SplitStringUsingSubstr(const std::string& str,
+ const std::string& s,
+ std::vector<std::string>* r) {
+ SplitStringUsingSubstrT(str, s, r);
+}
+
+std::vector<string16> SplitStringUsingSubstr(const string16& str,
+ const string16& s) {
+ std::vector<string16> result;
+ SplitStringUsingSubstr(str, s, &result);
+ return result;
+}
+
+std::vector<std::string> SplitStringUsingSubstr(const std::string& str,
+ const std::string& s) {
+ std::vector<std::string> result;
+ SplitStringUsingSubstr(str, s, &result);
+ return result;
+}
+
template<typename STR>
static size_t TokenizeT(const STR& str,
const STR& delimiters,