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

Side by Side Diff: net/http/http_net_log_params.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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/http/http_net_log_params.h ('k') | net/http/http_network_transaction.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "net/http/http_net_log_params.h"
6
7 #include "base/stringprintf.h"
8 #include "base/values.h"
9 #include "net/http/http_response_headers.h"
10
11 namespace net {
12
13 NetLogHttpRequestParameter::NetLogHttpRequestParameter(
14 const std::string& line,
15 const HttpRequestHeaders& headers)
16 : line_(line) {
17 headers_.CopyFrom(headers);
18 }
19
20 Value* NetLogHttpRequestParameter::ToValue() const {
21 DictionaryValue* dict = new DictionaryValue();
22 dict->SetString("line", line_);
23 ListValue* headers = new ListValue();
24 HttpRequestHeaders::Iterator iterator(headers_);
25 while (iterator.GetNext()) {
26 headers->Append(
27 new StringValue(base::StringPrintf("%s: %s",
28 iterator.name().c_str(),
29 iterator.value().c_str())));
30 }
31 dict->Set("headers", headers);
32 return dict;
33 }
34
35 NetLogHttpRequestParameter::~NetLogHttpRequestParameter() {}
36
37 NetLogHttpResponseParameter::NetLogHttpResponseParameter(
38 const scoped_refptr<HttpResponseHeaders>& headers)
39 : headers_(headers) {}
40
41 Value* NetLogHttpResponseParameter::ToValue() const {
42 DictionaryValue* dict = new DictionaryValue();
43 ListValue* headers = new ListValue();
44 headers->Append(new StringValue(headers_->GetStatusLine()));
45 void* iterator = NULL;
46 std::string name;
47 std::string value;
48 while (headers_->EnumerateHeaderLines(&iterator, &name, &value)) {
49 headers->Append(
50 new StringValue(base::StringPrintf("%s: %s", name.c_str(),
51 value.c_str())));
52 }
53 dict->Set("headers", headers);
54 return dict;
55 }
56
57 NetLogHttpResponseParameter::~NetLogHttpResponseParameter() {}
58
59 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_net_log_params.h ('k') | net/http/http_network_transaction.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698