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

Side by Side Diff: net/http/http_request_headers.cc

Issue 2899723003: Remove raw base::DictionaryValue::Set in //net (Closed)
Patch Set: Rebase Created 3 years, 6 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 | « net/dns/dns_config_service.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/http/http_request_headers.h" 5 #include "net/http/http_request_headers.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/ptr_util.h"
10 #include "base/strings/string_split.h" 11 #include "base/strings/string_split.h"
11 #include "base/strings/string_util.h" 12 #include "base/strings/string_util.h"
12 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
13 #include "base/values.h" 14 #include "base/values.h"
14 #include "net/base/escape.h" 15 #include "net/base/escape.h"
15 #include "net/http/http_log_util.h" 16 #include "net/http/http_log_util.h"
16 #include "net/http/http_util.h" 17 #include "net/http/http_util.h"
17 #include "net/log/net_log_capture_mode.h" 18 #include "net/log/net_log_capture_mode.h"
18 19
19 namespace net { 20 namespace net {
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 base::StringAppendF(&output, "%s:\r\n", it->key.c_str()); 184 base::StringAppendF(&output, "%s:\r\n", it->key.c_str());
184 } 185 }
185 } 186 }
186 output.append("\r\n"); 187 output.append("\r\n");
187 return output; 188 return output;
188 } 189 }
189 190
190 std::unique_ptr<base::Value> HttpRequestHeaders::NetLogCallback( 191 std::unique_ptr<base::Value> HttpRequestHeaders::NetLogCallback(
191 const std::string* request_line, 192 const std::string* request_line,
192 NetLogCaptureMode capture_mode) const { 193 NetLogCaptureMode capture_mode) const {
193 std::unique_ptr<base::DictionaryValue> dict(new base::DictionaryValue()); 194 auto dict = base::MakeUnique<base::DictionaryValue>();
194 dict->SetString("line", EscapeNonASCII(*request_line)); 195 dict->SetString("line", EscapeNonASCII(*request_line));
195 base::ListValue* headers = new base::ListValue(); 196 auto headers = base::MakeUnique<base::ListValue>();
196 for (HeaderVector::const_iterator it = headers_.begin(); it != headers_.end(); 197 for (HeaderVector::const_iterator it = headers_.begin(); it != headers_.end();
197 ++it) { 198 ++it) {
198 std::string log_value = 199 std::string log_value =
199 ElideHeaderValueForNetLog(capture_mode, it->key, it->value); 200 ElideHeaderValueForNetLog(capture_mode, it->key, it->value);
200 std::string escaped_name = EscapeNonASCII(it->key); 201 std::string escaped_name = EscapeNonASCII(it->key);
201 std::string escaped_value = EscapeNonASCII(log_value); 202 std::string escaped_value = EscapeNonASCII(log_value);
202 headers->AppendString(base::StringPrintf("%s: %s", escaped_name.c_str(), 203 headers->AppendString(base::StringPrintf("%s: %s", escaped_name.c_str(),
203 escaped_value.c_str())); 204 escaped_value.c_str()));
204 } 205 }
205 dict->Set("headers", headers); 206 dict->Set("headers", std::move(headers));
206 return std::move(dict); 207 return std::move(dict);
207 } 208 }
208 209
209 // static 210 // static
210 bool HttpRequestHeaders::FromNetLogParam(const base::Value* event_param, 211 bool HttpRequestHeaders::FromNetLogParam(const base::Value* event_param,
211 HttpRequestHeaders* headers, 212 HttpRequestHeaders* headers,
212 std::string* request_line) { 213 std::string* request_line) {
213 headers->Clear(); 214 headers->Clear();
214 *request_line = ""; 215 *request_line = "";
215 216
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 for (HeaderVector::const_iterator it = headers_.begin(); 254 for (HeaderVector::const_iterator it = headers_.begin();
254 it != headers_.end(); ++it) { 255 it != headers_.end(); ++it) {
255 if (base::EqualsCaseInsensitiveASCII(key, it->key)) 256 if (base::EqualsCaseInsensitiveASCII(key, it->key))
256 return it; 257 return it;
257 } 258 }
258 259
259 return headers_.end(); 260 return headers_.end();
260 } 261 }
261 262
262 } // namespace net 263 } // namespace net
OLDNEW
« no previous file with comments | « net/dns/dns_config_service.cc ('k') | net/http/http_response_headers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698