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 "chrome/browser/chrome_thread.h" | 10 #include "chrome/browser/chrome_thread.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 switch (entry.source.type) { | 58 switch (entry.source.type) { |
59 case net::NetLog::SOURCE_URL_REQUEST: | 59 case net::NetLog::SOURCE_URL_REQUEST: |
60 url_request_tracker_.OnAddEntry(entry); | 60 url_request_tracker_.OnAddEntry(entry); |
61 break; | 61 break; |
62 case net::NetLog::SOURCE_SOCKET_STREAM: | 62 case net::NetLog::SOURCE_SOCKET_STREAM: |
63 socket_stream_tracker_.OnAddEntry(entry); | 63 socket_stream_tracker_.OnAddEntry(entry); |
64 break; | 64 break; |
65 case net::NetLog::SOURCE_CONNECT_JOB: | 65 case net::NetLog::SOURCE_CONNECT_JOB: |
66 connect_job_tracker_.OnAddEntry(entry); | 66 connect_job_tracker_.OnAddEntry(entry); |
67 break; | 67 break; |
| 68 case net::NetLog::SOURCE_INIT_PROXY_RESOLVER: |
| 69 init_proxy_resolver_tracker_.OnAddEntry(entry); |
| 70 break; |
68 default: | 71 default: |
69 // Drop all other logged events. | 72 // Drop all other logged events. |
70 break; | 73 break; |
71 } | 74 } |
72 } | 75 } |
73 | 76 |
74 void PassiveLogCollector::Clear() { | 77 void PassiveLogCollector::Clear() { |
75 connect_job_tracker_.Clear(); | 78 connect_job_tracker_.Clear(); |
76 url_request_tracker_.Clear(); | 79 url_request_tracker_.Clear(); |
77 socket_stream_tracker_.Clear(); | 80 socket_stream_tracker_.Clear(); |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 AppendToRequestInfo(*connect_job_info, is_unbounded(), live_entry); | 312 AppendToRequestInfo(*connect_job_info, is_unbounded(), live_entry); |
310 } else { | 313 } else { |
311 // If we couldn't find the information for the ConnectJob, append a | 314 // If we couldn't find the information for the ConnectJob, append a |
312 // generic message instead. | 315 // generic message instead. |
313 net::NetLog::Entry e(entry); | 316 net::NetLog::Entry e(entry); |
314 e.type = net::NetLog::Entry::TYPE_STRING; | 317 e.type = net::NetLog::Entry::TYPE_STRING; |
315 e.string = StringPrintf("Used ConnectJob id=%d", connect_job_id); | 318 e.string = StringPrintf("Used ConnectJob id=%d", connect_job_id); |
316 AddEntryToRequestInfo(e, is_unbounded(), live_entry); | 319 AddEntryToRequestInfo(e, is_unbounded(), live_entry); |
317 } | 320 } |
318 } | 321 } |
| 322 |
| 323 //---------------------------------------------------------------------------- |
| 324 // InitProxyResolverTracker |
| 325 //---------------------------------------------------------------------------- |
| 326 |
| 327 PassiveLogCollector::InitProxyResolverTracker::InitProxyResolverTracker() {} |
| 328 |
| 329 void PassiveLogCollector::InitProxyResolverTracker::OnAddEntry( |
| 330 const net::NetLog::Entry& entry) { |
| 331 if (entry.type == net::NetLog::Entry::TYPE_EVENT && |
| 332 entry.event.type == net::NetLog::TYPE_INIT_PROXY_RESOLVER && |
| 333 entry.event.phase == net::NetLog::PHASE_BEGIN) { |
| 334 // If this is the start of a new InitProxyResolver, overwrite the old data. |
| 335 entries_.clear(); |
| 336 entries_.push_back(entry); |
| 337 } else { |
| 338 // Otherwise append it to the log for the latest InitProxyResolver. |
| 339 if (!entries_.empty() && entries_[0].source.id != entry.source.id) { |
| 340 // If this entry doesn't match what we think was the latest |
| 341 // InitProxyResolver, drop it. (This shouldn't happen, but we will guard |
| 342 // against it). |
| 343 return; |
| 344 } |
| 345 entries_.push_back(entry); |
| 346 } |
| 347 |
| 348 // Safety net: INIT_PROXY_RESOLVER shouldn't generate many messages, but in |
| 349 // case something goes wrong, avoid exploding the memory usage. |
| 350 if (entries_.size() > kMaxNumEntriesPerLog) |
| 351 entries_.clear(); |
| 352 } |
| 353 |
OLD | NEW |