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

Unified Diff: net/http/http_response_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_response_headers.h ('k') | net/http/http_response_headers_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_response_headers.cc
===================================================================
--- net/http/http_response_headers.cc (revision 141317)
+++ net/http/http_response_headers.cc (working copy)
@@ -14,10 +14,12 @@
#include "base/logging.h"
#include "base/metrics/histogram.h"
#include "base/pickle.h"
+#include "base/stringprintf.h"
#include "base/string_number_conversions.h"
#include "base/string_piece.h"
#include "base/string_util.h"
#include "base/time.h"
+#include "base/values.h"
#include "net/base/escape.h"
#include "net/http/http_util.h"
@@ -1306,6 +1308,55 @@
return true;
}
+Value* HttpResponseHeaders::NetLogCallback(
+ NetLog::LogLevel /* log_level */) const {
+ DictionaryValue* dict = new DictionaryValue();
+ ListValue* headers = new ListValue();
+ headers->Append(new StringValue(GetStatusLine()));
+ void* iterator = NULL;
+ std::string name;
+ std::string value;
+ while (EnumerateHeaderLines(&iterator, &name, &value)) {
+ headers->Append(
+ new StringValue(base::StringPrintf("%s: %s",
+ name.c_str(),
+ value.c_str())));
+ }
+ dict->Set("headers", headers);
+ return dict;
+}
+
+// static
+bool HttpResponseHeaders::FromNetLogParam(
+ const base::Value* event_param,
+ scoped_refptr<HttpResponseHeaders>* http_response_headers) {
+ http_response_headers->release();
+
+ const base::DictionaryValue* dict;
+ base::ListValue* header_list;
+
+ if (!event_param ||
+ !event_param->GetAsDictionary(&dict) ||
+ !dict->GetList("headers", &header_list)) {
+ return false;
+ }
+
+ std::string raw_headers;
+ for (base::ListValue::const_iterator it = header_list->begin();
+ it != header_list->end();
+ ++it) {
+ std::string header_line;
+ if (!(*it)->GetAsString(&header_line))
+ return false;
+
+ raw_headers.append(header_line);
+ raw_headers.push_back('\0');
+ }
+ raw_headers.push_back('\0');
+ *http_response_headers = new HttpResponseHeaders(raw_headers);
+ return true;
+}
+
bool HttpResponseHeaders::IsChunkEncoded() const {
// Ignore spurious chunked responses from HTTP/1.0 servers and proxies.
return GetHttpVersion() >= HttpVersion(1, 1) &&
« no previous file with comments | « net/http/http_response_headers.h ('k') | net/http/http_response_headers_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698