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

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

Issue 255333003: Renamed namespaces in src/net. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Tue 04/29/2014 19:22:06.75 Created 6 years, 7 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 | « net/base/url_util.h ('k') | net/cert/cert_verify_proc.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 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 "net/base/url_util.h" 5 #include "net/base/url_util.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/string_piece.h" 10 #include "base/strings/string_piece.h"
(...skipping 18 matching lines...) Expand all
29 } 29 }
30 30
31 GURL AppendOrReplaceQueryParameter(const GURL& url, 31 GURL AppendOrReplaceQueryParameter(const GURL& url,
32 const std::string& name, 32 const std::string& name,
33 const std::string& value) { 33 const std::string& value) {
34 bool replaced = false; 34 bool replaced = false;
35 std::string param_name = EscapeQueryParamValue(name, true); 35 std::string param_name = EscapeQueryParamValue(name, true);
36 std::string param_value = EscapeQueryParamValue(value, true); 36 std::string param_value = EscapeQueryParamValue(value, true);
37 37
38 const std::string input = url.query(); 38 const std::string input = url.query();
39 url_parse::Component cursor(0, input.size()); 39 url::Component cursor(0, input.size());
40 std::string output; 40 std::string output;
41 url_parse::Component key_range, value_range; 41 url::Component key_range, value_range;
42 while (url_parse::ExtractQueryKeyValue( 42 while (url::ExtractQueryKeyValue(input.data(), &cursor, &key_range,
43 input.data(), &cursor, &key_range, &value_range)) { 43 &value_range)) {
44 const base::StringPiece key( 44 const base::StringPiece key(
45 input.data() + key_range.begin, key_range.len); 45 input.data() + key_range.begin, key_range.len);
46 const base::StringPiece value( 46 const base::StringPiece value(
47 input.data() + value_range.begin, value_range.len); 47 input.data() + value_range.begin, value_range.len);
48 std::string key_value_pair; 48 std::string key_value_pair;
49 // Check |replaced| as only the first pair should be replaced. 49 // Check |replaced| as only the first pair should be replaced.
50 if (!replaced && key == param_name) { 50 if (!replaced && key == param_name) {
51 replaced = true; 51 replaced = true;
52 key_value_pair = (param_name + "=" + param_value); 52 key_value_pair = (param_name + "=" + param_value);
53 } else { 53 } else {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 111
112 bool QueryIterator::IsAtEnd() const { 112 bool QueryIterator::IsAtEnd() const {
113 return at_end_; 113 return at_end_;
114 } 114 }
115 115
116 void QueryIterator::Advance() { 116 void QueryIterator::Advance() {
117 DCHECK (!at_end_); 117 DCHECK (!at_end_);
118 key_.reset(); 118 key_.reset();
119 value_.reset(); 119 value_.reset();
120 unescaped_value_.clear(); 120 unescaped_value_.clear();
121 at_end_ = !url_parse::ExtractQueryKeyValue(url_.spec().c_str(), 121 at_end_ =
122 &query_, 122 !url::ExtractQueryKeyValue(url_.spec().c_str(), &query_, &key_, &value_);
123 &key_,
124 &value_);
125 } 123 }
126 124
127 bool GetValueForKeyInQuery(const GURL& url, 125 bool GetValueForKeyInQuery(const GURL& url,
128 const std::string& search_key, 126 const std::string& search_key,
129 std::string* out_value) { 127 std::string* out_value) {
130 for (QueryIterator it(url); !it.IsAtEnd(); it.Advance()) { 128 for (QueryIterator it(url); !it.IsAtEnd(); it.Advance()) {
131 if (it.GetKey() == search_key) { 129 if (it.GetKey() == search_key) {
132 *out_value = it.GetUnescapedValue(); 130 *out_value = it.GetUnescapedValue();
133 return true; 131 return true;
134 } 132 }
135 } 133 }
136 return false; 134 return false;
137 } 135 }
138 136
139 } // namespace net 137 } // namespace net
OLDNEW
« no previous file with comments | « net/base/url_util.h ('k') | net/cert/cert_verify_proc.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698