OLD | NEW |
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 "content/browser/devtools/devtools_netlog_observer.h" | 5 #include "content/browser/devtools/devtools_netlog_observer.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 request_to_info_.erase(entry.source().id); | 71 request_to_info_.erase(entry.source().id); |
72 return; | 72 return; |
73 } | 73 } |
74 | 74 |
75 ResourceInfo* info = GetResourceInfo(entry.source().id); | 75 ResourceInfo* info = GetResourceInfo(entry.source().id); |
76 if (!info) | 76 if (!info) |
77 return; | 77 return; |
78 | 78 |
79 switch (entry.type()) { | 79 switch (entry.type()) { |
80 case net::NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST_HEADERS: { | 80 case net::NetLog::TYPE_HTTP_TRANSACTION_SEND_REQUEST_HEADERS: { |
81 scoped_ptr<base::Value> event_params(entry.ParametersToValue()); | 81 std::unique_ptr<base::Value> event_params(entry.ParametersToValue()); |
82 std::string request_line; | 82 std::string request_line; |
83 net::HttpRequestHeaders request_headers; | 83 net::HttpRequestHeaders request_headers; |
84 | 84 |
85 if (!net::HttpRequestHeaders::FromNetLogParam(event_params.get(), | 85 if (!net::HttpRequestHeaders::FromNetLogParam(event_params.get(), |
86 &request_headers, | 86 &request_headers, |
87 &request_line)) { | 87 &request_line)) { |
88 NOTREACHED(); | 88 NOTREACHED(); |
89 } | 89 } |
90 | 90 |
91 // We need to clear headers in case the same url_request is reused for | 91 // We need to clear headers in case the same url_request is reused for |
92 // several http requests (e.g. see http://crbug.com/80157). | 92 // several http requests (e.g. see http://crbug.com/80157). |
93 info->request_headers.clear(); | 93 info->request_headers.clear(); |
94 | 94 |
95 for (net::HttpRequestHeaders::Iterator it(request_headers); | 95 for (net::HttpRequestHeaders::Iterator it(request_headers); |
96 it.GetNext();) { | 96 it.GetNext();) { |
97 info->request_headers.push_back(std::make_pair(it.name(), it.value())); | 97 info->request_headers.push_back(std::make_pair(it.name(), it.value())); |
98 } | 98 } |
99 info->request_headers_text = request_line + request_headers.ToString(); | 99 info->request_headers_text = request_line + request_headers.ToString(); |
100 break; | 100 break; |
101 } | 101 } |
102 case net::NetLog::TYPE_HTTP_TRANSACTION_HTTP2_SEND_REQUEST_HEADERS: { | 102 case net::NetLog::TYPE_HTTP_TRANSACTION_HTTP2_SEND_REQUEST_HEADERS: { |
103 scoped_ptr<base::Value> event_params(entry.ParametersToValue()); | 103 std::unique_ptr<base::Value> event_params(entry.ParametersToValue()); |
104 net::SpdyHeaderBlock request_headers; | 104 net::SpdyHeaderBlock request_headers; |
105 | 105 |
106 if (!net::SpdyHeaderBlockFromNetLogParam(event_params.get(), | 106 if (!net::SpdyHeaderBlockFromNetLogParam(event_params.get(), |
107 &request_headers)) { | 107 &request_headers)) { |
108 NOTREACHED(); | 108 NOTREACHED(); |
109 } | 109 } |
110 | 110 |
111 // We need to clear headers in case the same url_request is reused for | 111 // We need to clear headers in case the same url_request is reused for |
112 // several http requests (e.g. see http://crbug.com/80157). | 112 // several http requests (e.g. see http://crbug.com/80157). |
113 info->request_headers.clear(); | 113 info->request_headers.clear(); |
114 | 114 |
115 for (net::SpdyHeaderBlock::const_iterator it = request_headers.begin(); | 115 for (net::SpdyHeaderBlock::const_iterator it = request_headers.begin(); |
116 it != request_headers.end(); ++it) { | 116 it != request_headers.end(); ++it) { |
117 info->request_headers.push_back( | 117 info->request_headers.push_back( |
118 std::make_pair(it->first.as_string(), it->second.as_string())); | 118 std::make_pair(it->first.as_string(), it->second.as_string())); |
119 } | 119 } |
120 info->request_headers_text = ""; | 120 info->request_headers_text = ""; |
121 break; | 121 break; |
122 } | 122 } |
123 case net::NetLog::TYPE_HTTP_TRANSACTION_READ_RESPONSE_HEADERS: { | 123 case net::NetLog::TYPE_HTTP_TRANSACTION_READ_RESPONSE_HEADERS: { |
124 scoped_ptr<base::Value> event_params(entry.ParametersToValue()); | 124 std::unique_ptr<base::Value> event_params(entry.ParametersToValue()); |
125 | 125 |
126 scoped_refptr<net::HttpResponseHeaders> response_headers; | 126 scoped_refptr<net::HttpResponseHeaders> response_headers; |
127 | 127 |
128 if (!net::HttpResponseHeaders::FromNetLogParam(event_params.get(), | 128 if (!net::HttpResponseHeaders::FromNetLogParam(event_params.get(), |
129 &response_headers)) { | 129 &response_headers)) { |
130 NOTREACHED(); | 130 NOTREACHED(); |
131 } | 131 } |
132 | 132 |
133 info->http_status_code = response_headers->response_code(); | 133 info->http_status_code = response_headers->response_code(); |
134 info->http_status_text = response_headers->GetStatusText(); | 134 info->http_status_text = response_headers->GetStatusText(); |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 uint32_t source_id = request->net_log().source().id; | 198 uint32_t source_id = request->net_log().source().id; |
199 DevToolsNetLogObserver* dev_tools_net_log_observer = | 199 DevToolsNetLogObserver* dev_tools_net_log_observer = |
200 DevToolsNetLogObserver::GetInstance(); | 200 DevToolsNetLogObserver::GetInstance(); |
201 if (dev_tools_net_log_observer == NULL) | 201 if (dev_tools_net_log_observer == NULL) |
202 return; | 202 return; |
203 response->head.devtools_info = | 203 response->head.devtools_info = |
204 dev_tools_net_log_observer->GetResourceInfo(source_id); | 204 dev_tools_net_log_observer->GetResourceInfo(source_id); |
205 } | 205 } |
206 | 206 |
207 } // namespace content | 207 } // namespace content |
OLD | NEW |