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

Side by Side Diff: net/base/net_util.cc

Issue 4366001: base: Move CaseInsensitiveCompare traits into the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 10 years, 1 month 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_frame/test_utils.cc ('k') | net/http/http_response_headers.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 #include "net/base/net_util.h" 5 #include "net/base/net_util.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 #include <unicode/regex.h> 9 #include <unicode/regex.h>
10 #include <unicode/ucnv.h> 10 #include <unicode/ucnv.h>
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 if (headers.empty()) 169 if (headers.empty())
170 return STR(); 170 return STR();
171 171
172 STR match; 172 STR match;
173 match.push_back('\n'); 173 match.push_back('\n');
174 match.append(name); 174 match.append(name);
175 match.push_back(':'); 175 match.push_back(':');
176 176
177 typename STR::const_iterator begin = 177 typename STR::const_iterator begin =
178 search(headers.begin(), headers.end(), match.begin(), match.end(), 178 search(headers.begin(), headers.end(), match.begin(), match.end(),
179 CaseInsensitiveCompareASCII<typename STR::value_type>()); 179 base::CaseInsensitiveCompareASCII<typename STR::value_type>());
180 180
181 if (begin == headers.end()) 181 if (begin == headers.end())
182 return STR(); 182 return STR();
183 183
184 begin += match.length(); 184 begin += match.length();
185 185
186 typename STR::const_iterator end = find(begin, headers.end(), '\n'); 186 typename STR::const_iterator end = find(begin, headers.end(), '\n');
187 187
188 STR ret; 188 STR ret;
189 TrimWhitespace(STR(begin, end), TRIM_ALL, &ret); 189 TrimWhitespace(STR(begin, end), TRIM_ALL, &ret);
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 return true; 417 return true;
418 } 418 }
419 419
420 // TODO(mpcomplete): This is a quick and dirty implementation for now. I'm 420 // TODO(mpcomplete): This is a quick and dirty implementation for now. I'm
421 // sure this doesn't properly handle all (most?) cases. 421 // sure this doesn't properly handle all (most?) cases.
422 template<typename STR> 422 template<typename STR>
423 STR GetHeaderParamValueT(const STR& header, const STR& param_name) { 423 STR GetHeaderParamValueT(const STR& header, const STR& param_name) {
424 // This assumes args are formatted exactly like "bla; arg1=value; arg2=value". 424 // This assumes args are formatted exactly like "bla; arg1=value; arg2=value".
425 typename STR::const_iterator param_begin = 425 typename STR::const_iterator param_begin =
426 search(header.begin(), header.end(), param_name.begin(), param_name.end(), 426 search(header.begin(), header.end(), param_name.begin(), param_name.end(),
427 CaseInsensitiveCompareASCII<typename STR::value_type>()); 427 base::CaseInsensitiveCompareASCII<typename STR::value_type>());
428 428
429 if (param_begin == header.end()) 429 if (param_begin == header.end())
430 return STR(); 430 return STR();
431 param_begin += param_name.length(); 431 param_begin += param_name.length();
432 432
433 STR whitespace; 433 STR whitespace;
434 whitespace.push_back(' '); 434 whitespace.push_back(' ');
435 whitespace.push_back('\t'); 435 whitespace.push_back('\t');
436 const typename STR::size_type equals_offset = 436 const typename STR::size_type equals_offset =
437 header.find_first_not_of(whitespace, param_begin - header.begin()); 437 header.find_first_not_of(whitespace, param_begin - header.begin());
(...skipping 1552 matching lines...) Expand 10 before | Expand all | Expand 10 after
1990 } 1990 }
1991 1991
1992 int GetPortFromAddrinfo(const struct addrinfo* info) { 1992 int GetPortFromAddrinfo(const struct addrinfo* info) {
1993 uint16* port_field = GetPortFieldFromAddrinfo(info); 1993 uint16* port_field = GetPortFieldFromAddrinfo(info);
1994 if (!port_field) 1994 if (!port_field)
1995 return -1; 1995 return -1;
1996 return ntohs(*port_field); 1996 return ntohs(*port_field);
1997 } 1997 }
1998 1998
1999 } // namespace net 1999 } // namespace net
OLDNEW
« no previous file with comments | « chrome_frame/test_utils.cc ('k') | net/http/http_response_headers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698