| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef NET_HTTP_HTTP_NET_LOG_PARAMS_H_ | 5 #ifndef NET_HTTP_HTTP_NET_LOG_PARAMS_H_ |
| 6 #define NET_HTTP_HTTP_NET_LOG_PARAMS_H_ | 6 #define NET_HTTP_HTTP_NET_LOG_PARAMS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 class NetLogHttpRequestParameter : public NetLog::EventParameters { | 21 class NetLogHttpRequestParameter : public NetLog::EventParameters { |
| 22 public: | 22 public: |
| 23 NetLogHttpRequestParameter(const std::string& line, | 23 NetLogHttpRequestParameter(const std::string& line, |
| 24 const HttpRequestHeaders& headers) | 24 const HttpRequestHeaders& headers) |
| 25 : line_(line) { | 25 : line_(line) { |
| 26 headers_.CopyFrom(headers); | 26 headers_.CopyFrom(headers); |
| 27 } | 27 } |
| 28 | 28 |
| 29 Value* ToValue() const { | 29 Value* ToValue() const { |
| 30 DictionaryValue* dict = new DictionaryValue(); | 30 DictionaryValue* dict = new DictionaryValue(); |
| 31 dict->SetString(L"line", line_); | 31 dict->SetString("line", line_); |
| 32 ListValue* headers = new ListValue(); | 32 ListValue* headers = new ListValue(); |
| 33 HttpRequestHeaders::Iterator iterator(headers_); | 33 HttpRequestHeaders::Iterator iterator(headers_); |
| 34 while (iterator.GetNext()) { | 34 while (iterator.GetNext()) { |
| 35 headers->Append( | 35 headers->Append( |
| 36 new StringValue(StringPrintf("%s: %s", | 36 new StringValue(StringPrintf("%s: %s", |
| 37 iterator.name().c_str(), | 37 iterator.name().c_str(), |
| 38 iterator.value().c_str()))); | 38 iterator.value().c_str()))); |
| 39 } | 39 } |
| 40 dict->Set(L"headers", headers); | 40 dict->Set("headers", headers); |
| 41 return dict; | 41 return dict; |
| 42 } | 42 } |
| 43 | 43 |
| 44 private: | 44 private: |
| 45 ~NetLogHttpRequestParameter() {} | 45 ~NetLogHttpRequestParameter() {} |
| 46 | 46 |
| 47 const std::string line_; | 47 const std::string line_; |
| 48 HttpRequestHeaders headers_; | 48 HttpRequestHeaders headers_; |
| 49 | 49 |
| 50 DISALLOW_COPY_AND_ASSIGN(NetLogHttpRequestParameter); | 50 DISALLOW_COPY_AND_ASSIGN(NetLogHttpRequestParameter); |
| 51 }; | 51 }; |
| 52 | 52 |
| 53 class NetLogHttpResponseParameter : public NetLog::EventParameters { | 53 class NetLogHttpResponseParameter : public NetLog::EventParameters { |
| 54 public: | 54 public: |
| 55 explicit NetLogHttpResponseParameter( | 55 explicit NetLogHttpResponseParameter( |
| 56 const scoped_refptr<HttpResponseHeaders>& headers) | 56 const scoped_refptr<HttpResponseHeaders>& headers) |
| 57 : headers_(headers) {} | 57 : headers_(headers) {} |
| 58 | 58 |
| 59 Value* ToValue() const { | 59 Value* ToValue() const { |
| 60 DictionaryValue* dict = new DictionaryValue(); | 60 DictionaryValue* dict = new DictionaryValue(); |
| 61 ListValue* headers = new ListValue(); | 61 ListValue* headers = new ListValue(); |
| 62 headers->Append(new StringValue(headers_->GetStatusLine())); | 62 headers->Append(new StringValue(headers_->GetStatusLine())); |
| 63 void* iterator = NULL; | 63 void* iterator = NULL; |
| 64 std::string name; | 64 std::string name; |
| 65 std::string value; | 65 std::string value; |
| 66 while (headers_->EnumerateHeaderLines(&iterator, &name, &value)) { | 66 while (headers_->EnumerateHeaderLines(&iterator, &name, &value)) { |
| 67 headers->Append( | 67 headers->Append( |
| 68 new StringValue(StringPrintf("%s: %s", name.c_str(), value.c_str()))); | 68 new StringValue(StringPrintf("%s: %s", name.c_str(), value.c_str()))); |
| 69 } | 69 } |
| 70 dict->Set(L"headers", headers); | 70 dict->Set("headers", headers); |
| 71 return dict; | 71 return dict; |
| 72 } | 72 } |
| 73 | 73 |
| 74 private: | 74 private: |
| 75 ~NetLogHttpResponseParameter() {} | 75 ~NetLogHttpResponseParameter() {} |
| 76 | 76 |
| 77 const scoped_refptr<HttpResponseHeaders> headers_; | 77 const scoped_refptr<HttpResponseHeaders> headers_; |
| 78 | 78 |
| 79 DISALLOW_COPY_AND_ASSIGN(NetLogHttpResponseParameter); | 79 DISALLOW_COPY_AND_ASSIGN(NetLogHttpResponseParameter); |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 } // namespace net | 82 } // namespace net |
| 83 | 83 |
| 84 #endif // NET_HTTP_HTTP_NET_LOG_PARAMS_H_ | 84 #endif // NET_HTTP_HTTP_NET_LOG_PARAMS_H_ |
| 85 | 85 |
| OLD | NEW |