| 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/debugger/devtools_netlog_observer.h" | 5 #include "content/browser/debugger/devtools_netlog_observer.h" |
| 6 | 6 |
| 7 #include "base/string_tokenizer.h" | 7 #include "base/string_tokenizer.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| 11 #include "content/public/browser/content_browser_client.h" | 11 #include "content/public/browser/content_browser_client.h" |
| 12 #include "content/public/common/resource_response.h" | 12 #include "content/public/common/resource_response.h" |
| 13 #include "net/base/load_flags.h" | 13 #include "net/base/load_flags.h" |
| 14 #include "net/http/http_response_headers.h" | 14 #include "net/http/http_response_headers.h" |
| 15 #include "net/http/http_util.h" | 15 #include "net/http/http_util.h" |
| 16 #include "net/spdy/spdy_header_block.h" |
| 16 #include "net/url_request/url_request.h" | 17 #include "net/url_request/url_request.h" |
| 17 #include "net/url_request/url_request_netlog_params.h" | 18 #include "net/url_request/url_request_netlog_params.h" |
| 18 #include "webkit/glue/resource_loader_bridge.h" | 19 #include "webkit/glue/resource_loader_bridge.h" |
| 19 | 20 |
| 20 using content::BrowserThread; | 21 using content::BrowserThread; |
| 21 | 22 |
| 22 const size_t kMaxNumEntries = 1000; | 23 const size_t kMaxNumEntries = 1000; |
| 23 | 24 |
| 24 DevToolsNetLogObserver* DevToolsNetLogObserver::instance_ = NULL; | 25 DevToolsNetLogObserver* DevToolsNetLogObserver::instance_ = NULL; |
| 25 | 26 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 // several http requests (e.g. see http://crbug.com/80157). | 116 // several http requests (e.g. see http://crbug.com/80157). |
| 116 info->request_headers.clear(); | 117 info->request_headers.clear(); |
| 117 | 118 |
| 118 for (net::HttpRequestHeaders::Iterator it(request_headers); | 119 for (net::HttpRequestHeaders::Iterator it(request_headers); |
| 119 it.GetNext();) { | 120 it.GetNext();) { |
| 120 info->request_headers.push_back(std::make_pair(it.name(), it.value())); | 121 info->request_headers.push_back(std::make_pair(it.name(), it.value())); |
| 121 } | 122 } |
| 122 info->request_headers_text = request_line + request_headers.ToString(); | 123 info->request_headers_text = request_line + request_headers.ToString(); |
| 123 break; | 124 break; |
| 124 } | 125 } |
| 126 case net::NetLog::TYPE_HTTP_TRANSACTION_SPDY_SEND_REQUEST_HEADERS: { |
| 127 scoped_ptr<Value> event_params(entry.ParametersToValue()); |
| 128 net::SpdyHeaderBlock request_headers; |
| 129 |
| 130 if (!net::SpdyHeaderBlockFromNetLogParam(event_params.get(), |
| 131 &request_headers)) { |
| 132 NOTREACHED(); |
| 133 } |
| 134 |
| 135 // We need to clear headers in case the same url_request is reused for |
| 136 // several http requests (e.g. see http://crbug.com/80157). |
| 137 info->request_headers.clear(); |
| 138 |
| 139 for (net::SpdyHeaderBlock::const_iterator it = request_headers.begin(); |
| 140 it != request_headers.end(); ++it) { |
| 141 info->request_headers.push_back(std::make_pair(it->first, it->second)); |
| 142 } |
| 143 info->request_headers_text = ""; |
| 144 break; |
| 145 } |
| 125 case net::NetLog::TYPE_HTTP_TRANSACTION_READ_RESPONSE_HEADERS: { | 146 case net::NetLog::TYPE_HTTP_TRANSACTION_READ_RESPONSE_HEADERS: { |
| 126 scoped_ptr<Value> event_params(entry.ParametersToValue()); | 147 scoped_ptr<Value> event_params(entry.ParametersToValue()); |
| 127 | 148 |
| 128 scoped_refptr<net::HttpResponseHeaders> response_headers; | 149 scoped_refptr<net::HttpResponseHeaders> response_headers; |
| 129 | 150 |
| 130 if (!net::HttpResponseHeaders::FromNetLogParam(event_params.get(), | 151 if (!net::HttpResponseHeaders::FromNetLogParam(event_params.get(), |
| 131 &response_headers)) { | 152 &response_headers)) { |
| 132 NOTREACHED(); | 153 NOTREACHED(); |
| 133 } | 154 } |
| 134 | 155 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 | 319 |
| 299 RequestToEncodedDataLengthMap::iterator it = | 320 RequestToEncodedDataLengthMap::iterator it = |
| 300 dev_tools_net_log_observer->request_to_encoded_data_length_.find( | 321 dev_tools_net_log_observer->request_to_encoded_data_length_.find( |
| 301 source_id); | 322 source_id); |
| 302 if (it == dev_tools_net_log_observer->request_to_encoded_data_length_.end()) | 323 if (it == dev_tools_net_log_observer->request_to_encoded_data_length_.end()) |
| 303 return -1; | 324 return -1; |
| 304 int encoded_data_length = it->second; | 325 int encoded_data_length = it->second; |
| 305 it->second = 0; | 326 it->second = 0; |
| 306 return encoded_data_length; | 327 return encoded_data_length; |
| 307 } | 328 } |
| OLD | NEW |