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

Unified Diff: net/http/http_request_headers.cc

Issue 10399083: Make NetLog take in callbacks that return Values (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fix merge error Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/http_request_headers.h ('k') | net/http/http_request_headers_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_request_headers.cc
===================================================================
--- net/http/http_request_headers.cc (revision 141317)
+++ net/http/http_request_headers.cc (working copy)
@@ -8,6 +8,7 @@
#include "base/stringprintf.h"
#include "base/string_split.h"
#include "base/string_util.h"
+#include "base/values.h"
#include "net/http/http_util.h"
namespace net {
@@ -182,6 +183,54 @@
return output;
}
+Value* HttpRequestHeaders::NetLogCallback(
+ const std::string* request_line,
+ NetLog::LogLevel /* log_level */) const {
+ DictionaryValue* dict = new DictionaryValue();
+ dict->SetString("line", *request_line);
+ ListValue* headers = new ListValue();
+ for (HeaderVector::const_iterator it = headers_.begin();
+ it != headers_.end(); ++it) {
+ headers->Append(
+ new StringValue(base::StringPrintf("%s: %s",
+ it->key.c_str(),
+ it->value.c_str())));
+ }
+ dict->Set("headers", headers);
+ return dict;
+}
+
+// static
+bool HttpRequestHeaders::FromNetLogParam(const base::Value* event_param,
+ HttpRequestHeaders* headers,
+ std::string* request_line) {
+ headers->Clear();
+ *request_line = "";
+
+ const base::DictionaryValue* dict;
+ base::ListValue* header_list;
+
+ if (!event_param ||
+ !event_param->GetAsDictionary(&dict) ||
+ !dict->GetList("headers", &header_list) ||
+ !dict->GetString("line", request_line)) {
+ return false;
+ }
+
+ for (base::ListValue::const_iterator it = header_list->begin();
+ it != header_list->end();
+ ++it) {
+ std::string header_line;
+ if (!(*it)->GetAsString(&header_line)) {
+ headers->Clear();
+ *request_line = "";
+ return false;
+ }
+ headers->AddHeaderFromString(header_line);
+ }
+ return true;
+}
+
HttpRequestHeaders::HeaderVector::iterator
HttpRequestHeaders::FindHeader(const base::StringPiece& key) {
for (HeaderVector::iterator it = headers_.begin();
« no previous file with comments | « net/http/http_request_headers.h ('k') | net/http/http_request_headers_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698