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 #include "chrome/browser/net/passive_log_collector.h" | 5 #include "chrome/browser/net/passive_log_collector.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
11 #include "chrome/browser/chrome_thread.h" | 11 #include "chrome/browser/chrome_thread.h" |
| 12 #include "net/url_request/url_request_netlog_params.h" |
12 | 13 |
13 namespace { | 14 namespace { |
14 | 15 |
15 const size_t kMaxNumEntriesPerLog = 50; | 16 const size_t kMaxNumEntriesPerLog = 50; |
16 const size_t kMaxConnectJobGraveyardSize = 3; | 17 const size_t kMaxConnectJobGraveyardSize = 3; |
17 const size_t kMaxRequestGraveyardSize = 25; | 18 const size_t kMaxRequestGraveyardSize = 25; |
18 const size_t kMaxLiveRequests = 200; | 19 const size_t kMaxLiveRequests = 200; |
19 | 20 |
20 // Sort function on source ID. | 21 // Sort function on source ID. |
21 bool OrderBySourceID(const PassiveLogCollector::RequestInfo& a, | 22 bool OrderBySourceID(const PassiveLogCollector::RequestInfo& a, |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 } | 143 } |
143 | 144 |
144 std::string PassiveLogCollector::RequestInfo::GetURL() const { | 145 std::string PassiveLogCollector::RequestInfo::GetURL() const { |
145 // Note: we look at the first *two* entries, since the outer REQUEST_ALIVE | 146 // Note: we look at the first *two* entries, since the outer REQUEST_ALIVE |
146 // doesn't actually contain any data. | 147 // doesn't actually contain any data. |
147 for (size_t i = 0; i < 2 && i < entries.size(); ++i) { | 148 for (size_t i = 0; i < 2 && i < entries.size(); ++i) { |
148 const PassiveLogCollector::Entry& entry = entries[i]; | 149 const PassiveLogCollector::Entry& entry = entries[i]; |
149 if (entry.phase == net::NetLog::PHASE_BEGIN && entry.params) { | 150 if (entry.phase == net::NetLog::PHASE_BEGIN && entry.params) { |
150 switch (entry.type) { | 151 switch (entry.type) { |
151 case net::NetLog::TYPE_URL_REQUEST_START: | 152 case net::NetLog::TYPE_URL_REQUEST_START: |
| 153 return static_cast<URLRequestStartEventParameters*>( |
| 154 entry.params.get())->url().possibly_invalid_spec(); |
152 case net::NetLog::TYPE_SOCKET_STREAM_CONNECT: | 155 case net::NetLog::TYPE_SOCKET_STREAM_CONNECT: |
153 return static_cast<net::NetLogStringParameter*>( | 156 return static_cast<net::NetLogStringParameter*>( |
154 entry.params.get())->value(); | 157 entry.params.get())->value(); |
155 default: | 158 default: |
156 break; | 159 break; |
157 } | 160 } |
158 } | 161 } |
159 } | 162 } |
160 return std::string(); | 163 return std::string(); |
161 } | 164 } |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 } | 549 } |
547 entries_.push_back(entry); | 550 entries_.push_back(entry); |
548 } | 551 } |
549 | 552 |
550 // Safety net: INIT_PROXY_RESOLVER shouldn't generate many messages, but in | 553 // Safety net: INIT_PROXY_RESOLVER shouldn't generate many messages, but in |
551 // case something goes wrong, avoid exploding the memory usage. | 554 // case something goes wrong, avoid exploding the memory usage. |
552 if (entries_.size() > kMaxNumEntriesPerLog) | 555 if (entries_.size() > kMaxNumEntriesPerLog) |
553 entries_.clear(); | 556 entries_.clear(); |
554 } | 557 } |
555 | 558 |
OLD | NEW |