| 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/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/lock.h" |
| 10 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 11 #include "base/format_macros.h" | 12 #include "base/format_macros.h" |
| 12 #include "chrome/browser/browser_thread.h" | 13 #include "chrome/browser/browser_thread.h" |
| 13 #include "net/url_request/url_request_netlog_params.h" | 14 #include "net/url_request/url_request_netlog_params.h" |
| 14 | 15 |
| 15 namespace { | 16 namespace { |
| 16 | 17 |
| 17 // TODO(eroman): Do something with the truncation count. | 18 // TODO(eroman): Do something with the truncation count. |
| 18 | 19 |
| 19 const size_t kMaxNumEntriesPerLog = 30; | 20 const size_t kMaxNumEntriesPerLog = 30; |
| 20 | 21 |
| 21 void AddEntryToSourceInfo(const PassiveLogCollector::Entry& entry, | 22 void AddEntryToSourceInfo(const ChromeNetLog::Entry& entry, |
| 22 PassiveLogCollector::SourceInfo* out_info) { | 23 PassiveLogCollector::SourceInfo* out_info) { |
| 23 // Start dropping new entries when the log has gotten too big. | 24 // Start dropping new entries when the log has gotten too big. |
| 24 if (out_info->entries.size() + 1 <= kMaxNumEntriesPerLog) { | 25 if (out_info->entries.size() + 1 <= kMaxNumEntriesPerLog) { |
| 25 out_info->entries.push_back(entry); | 26 out_info->entries.push_back(entry); |
| 26 } else { | 27 } else { |
| 27 out_info->num_entries_truncated += 1; | 28 out_info->num_entries_truncated += 1; |
| 28 out_info->entries[kMaxNumEntriesPerLog - 1] = entry; | 29 out_info->entries[kMaxNumEntriesPerLog - 1] = entry; |
| 29 } | 30 } |
| 30 } | 31 } |
| 31 | 32 |
| 32 // Comparator to sort entries by their |order| property, ascending. | 33 // Comparator to sort entries by their |order| property, ascending. |
| 33 bool SortByOrderComparator(const PassiveLogCollector::Entry& a, | 34 bool SortByOrderComparator(const ChromeNetLog::Entry& a, |
| 34 const PassiveLogCollector::Entry& b) { | 35 const ChromeNetLog::Entry& b) { |
| 35 return a.order < b.order; | 36 return a.order < b.order; |
| 36 } | 37 } |
| 37 | 38 |
| 38 } // namespace | 39 } // namespace |
| 39 | 40 |
| 40 PassiveLogCollector::Entry::Entry(uint32 order, | |
| 41 net::NetLog::EventType type, | |
| 42 const base::TimeTicks& time, | |
| 43 net::NetLog::Source source, | |
| 44 net::NetLog::EventPhase phase, | |
| 45 net::NetLog::EventParameters* params) | |
| 46 : order(order), | |
| 47 type(type), | |
| 48 time(time), | |
| 49 source(source), | |
| 50 phase(phase), | |
| 51 params(params) { | |
| 52 } | |
| 53 | |
| 54 PassiveLogCollector::Entry::~Entry() {} | |
| 55 | |
| 56 PassiveLogCollector::SourceInfo::SourceInfo() | 41 PassiveLogCollector::SourceInfo::SourceInfo() |
| 57 : source_id(net::NetLog::Source::kInvalidId), | 42 : source_id(net::NetLog::Source::kInvalidId), |
| 58 num_entries_truncated(0), | 43 num_entries_truncated(0), |
| 59 reference_count(0), | 44 reference_count(0), |
| 60 is_alive(true) { | 45 is_alive(true) { |
| 61 } | 46 } |
| 62 | 47 |
| 63 PassiveLogCollector::SourceInfo::~SourceInfo() {} | 48 PassiveLogCollector::SourceInfo::~SourceInfo() {} |
| 64 | 49 |
| 65 //---------------------------------------------------------------------------- | 50 //---------------------------------------------------------------------------- |
| (...skipping 28 matching lines...) Expand all Loading... |
| 94 PassiveLogCollector::~PassiveLogCollector() { | 79 PassiveLogCollector::~PassiveLogCollector() { |
| 95 } | 80 } |
| 96 | 81 |
| 97 void PassiveLogCollector::OnAddEntry( | 82 void PassiveLogCollector::OnAddEntry( |
| 98 net::NetLog::EventType type, | 83 net::NetLog::EventType type, |
| 99 const base::TimeTicks& time, | 84 const base::TimeTicks& time, |
| 100 const net::NetLog::Source& source, | 85 const net::NetLog::Source& source, |
| 101 net::NetLog::EventPhase phase, | 86 net::NetLog::EventPhase phase, |
| 102 net::NetLog::EventParameters* params) { | 87 net::NetLog::EventParameters* params) { |
| 103 // Package the parameters into a single struct for convenience. | 88 // Package the parameters into a single struct for convenience. |
| 104 Entry entry(num_events_seen_++, type, time, source, phase, params); | 89 ChromeNetLog::Entry entry(num_events_seen_++, type, time, source, phase, |
| 90 params); |
| 105 | 91 |
| 106 SourceTrackerInterface* tracker = GetTrackerForSourceType(entry.source.type); | 92 SourceTrackerInterface* tracker = GetTrackerForSourceType_(entry.source.type); |
| 107 if (tracker) | 93 if (tracker) { |
| 94 AutoLock lock(lock_); |
| 108 tracker->OnAddEntry(entry); | 95 tracker->OnAddEntry(entry); |
| 96 } |
| 97 } |
| 98 |
| 99 void PassiveLogCollector::Clear() { |
| 100 AutoLock lock(lock_); |
| 101 for (size_t i = 0; i < arraysize(trackers_); ++i) |
| 102 trackers_[i]->Clear(); |
| 109 } | 103 } |
| 110 | 104 |
| 111 PassiveLogCollector::SourceTrackerInterface* | 105 PassiveLogCollector::SourceTrackerInterface* |
| 112 PassiveLogCollector::GetTrackerForSourceType( | 106 PassiveLogCollector::GetTrackerForSourceType_( |
| 113 net::NetLog::SourceType source_type) { | 107 net::NetLog::SourceType source_type) { |
| 114 DCHECK_LE(source_type, static_cast<int>(arraysize(trackers_))); | 108 DCHECK_LE(source_type, static_cast<int>(arraysize(trackers_))); |
| 115 DCHECK_GE(source_type, 0); | 109 DCHECK_GE(source_type, 0); |
| 116 return trackers_[source_type]; | 110 return trackers_[source_type]; |
| 117 } | 111 } |
| 118 | 112 |
| 119 void PassiveLogCollector::Clear() { | 113 void PassiveLogCollector::GetAllCapturedEvents( |
| 120 for (size_t i = 0; i < arraysize(trackers_); ++i) | 114 ChromeNetLog::EntryList* out) const { |
| 121 trackers_[i]->Clear(); | |
| 122 } | |
| 123 | |
| 124 void PassiveLogCollector::GetAllCapturedEvents(EntryList* out) const { | |
| 125 out->clear(); | 115 out->clear(); |
| 126 | 116 |
| 127 // Append all of the captured entries held by the various trackers to | 117 // Append all of the captured entries held by the various trackers to |
| 128 // |out|. | 118 // |out|. |
| 129 for (size_t i = 0; i < arraysize(trackers_); ++i) | 119 for (size_t i = 0; i < arraysize(trackers_); ++i) |
| 130 trackers_[i]->AppendAllEntries(out); | 120 trackers_[i]->AppendAllEntries(out); |
| 131 | 121 |
| 132 // Now sort the list of entries by their insertion time (ascending). | 122 // Now sort the list of entries by their insertion time (ascending). |
| 133 std::sort(out->begin(), out->end(), &SortByOrderComparator); | 123 std::sort(out->begin(), out->end(), &SortByOrderComparator); |
| 134 } | 124 } |
| 135 | 125 |
| 136 std::string PassiveLogCollector::SourceInfo::GetURL() const { | 126 std::string PassiveLogCollector::SourceInfo::GetURL() const { |
| 137 // Note: we look at the first *two* entries, since the outer REQUEST_ALIVE | 127 // Note: we look at the first *two* entries, since the outer REQUEST_ALIVE |
| 138 // doesn't actually contain any data. | 128 // doesn't actually contain any data. |
| 139 for (size_t i = 0; i < 2 && i < entries.size(); ++i) { | 129 for (size_t i = 0; i < 2 && i < entries.size(); ++i) { |
| 140 const PassiveLogCollector::Entry& entry = entries[i]; | 130 const ChromeNetLog::Entry& entry = entries[i]; |
| 141 if (entry.phase == net::NetLog::PHASE_BEGIN && entry.params) { | 131 if (entry.phase == net::NetLog::PHASE_BEGIN && entry.params) { |
| 142 switch (entry.type) { | 132 switch (entry.type) { |
| 143 case net::NetLog::TYPE_URL_REQUEST_START_JOB: | 133 case net::NetLog::TYPE_URL_REQUEST_START_JOB: |
| 144 return static_cast<URLRequestStartEventParameters*>( | 134 return static_cast<URLRequestStartEventParameters*>( |
| 145 entry.params.get())->url().possibly_invalid_spec(); | 135 entry.params.get())->url().possibly_invalid_spec(); |
| 146 case net::NetLog::TYPE_SOCKET_STREAM_CONNECT: | 136 case net::NetLog::TYPE_SOCKET_STREAM_CONNECT: |
| 147 return static_cast<net::NetLogStringParameter*>( | 137 return static_cast<net::NetLogStringParameter*>( |
| 148 entry.params.get())->value(); | 138 entry.params.get())->value(); |
| 149 default: | 139 default: |
| 150 break; | 140 break; |
| 151 } | 141 } |
| 152 } | 142 } |
| 153 } | 143 } |
| 154 return std::string(); | 144 return std::string(); |
| 155 } | 145 } |
| 156 | 146 |
| 157 //---------------------------------------------------------------------------- | 147 //---------------------------------------------------------------------------- |
| 158 // GlobalSourceTracker | 148 // GlobalSourceTracker |
| 159 //---------------------------------------------------------------------------- | 149 //---------------------------------------------------------------------------- |
| 160 | 150 |
| 161 PassiveLogCollector::GlobalSourceTracker::GlobalSourceTracker() {} | 151 PassiveLogCollector::GlobalSourceTracker::GlobalSourceTracker() {} |
| 162 PassiveLogCollector::GlobalSourceTracker::~GlobalSourceTracker() {} | 152 PassiveLogCollector::GlobalSourceTracker::~GlobalSourceTracker() {} |
| 163 | 153 |
| 164 void PassiveLogCollector::GlobalSourceTracker::OnAddEntry(const Entry& entry) { | 154 void PassiveLogCollector::GlobalSourceTracker::OnAddEntry( |
| 155 const ChromeNetLog::Entry& entry) { |
| 165 const size_t kMaxEntries = 30u; | 156 const size_t kMaxEntries = 30u; |
| 166 entries_.push_back(entry); | 157 entries_.push_back(entry); |
| 167 if (entries_.size() > kMaxEntries) | 158 if (entries_.size() > kMaxEntries) |
| 168 entries_.pop_front(); | 159 entries_.pop_front(); |
| 169 } | 160 } |
| 170 | 161 |
| 171 void PassiveLogCollector::GlobalSourceTracker::Clear() { | 162 void PassiveLogCollector::GlobalSourceTracker::Clear() { |
| 172 entries_.clear(); | 163 entries_.clear(); |
| 173 } | 164 } |
| 174 | 165 |
| 175 void PassiveLogCollector::GlobalSourceTracker::AppendAllEntries( | 166 void PassiveLogCollector::GlobalSourceTracker::AppendAllEntries( |
| 176 EntryList* out) const { | 167 ChromeNetLog::EntryList* out) const { |
| 177 out->insert(out->end(), entries_.begin(), entries_.end()); | 168 out->insert(out->end(), entries_.begin(), entries_.end()); |
| 178 } | 169 } |
| 179 | 170 |
| 180 //---------------------------------------------------------------------------- | 171 //---------------------------------------------------------------------------- |
| 181 // SourceTracker | 172 // SourceTracker |
| 182 //---------------------------------------------------------------------------- | 173 //---------------------------------------------------------------------------- |
| 183 | 174 |
| 184 PassiveLogCollector::SourceTracker::SourceTracker( | 175 PassiveLogCollector::SourceTracker::SourceTracker( |
| 185 size_t max_num_sources, | 176 size_t max_num_sources, |
| 186 size_t max_graveyard_size, | 177 size_t max_graveyard_size, |
| 187 PassiveLogCollector* parent) | 178 PassiveLogCollector* parent) |
| 188 : max_num_sources_(max_num_sources), | 179 : max_num_sources_(max_num_sources), |
| 189 max_graveyard_size_(max_graveyard_size), | 180 max_graveyard_size_(max_graveyard_size), |
| 190 parent_(parent) { | 181 parent_(parent) { |
| 191 } | 182 } |
| 192 | 183 |
| 193 PassiveLogCollector::SourceTracker::~SourceTracker() {} | 184 PassiveLogCollector::SourceTracker::~SourceTracker() {} |
| 194 | 185 |
| 195 void PassiveLogCollector::SourceTracker::OnAddEntry(const Entry& entry) { | 186 void PassiveLogCollector::SourceTracker::OnAddEntry( |
| 187 const ChromeNetLog::Entry& entry) { |
| 196 // Lookup or insert a new entry into the bounded map. | 188 // Lookup or insert a new entry into the bounded map. |
| 197 SourceIDToInfoMap::iterator it = sources_.find(entry.source.id); | 189 SourceIDToInfoMap::iterator it = sources_.find(entry.source.id); |
| 198 if (it == sources_.end()) { | 190 if (it == sources_.end()) { |
| 199 if (sources_.size() >= max_num_sources_) { | 191 if (sources_.size() >= max_num_sources_) { |
| 200 LOG(WARNING) << "The passive log data has grown larger " | 192 LOG(WARNING) << "The passive log data has grown larger " |
| 201 "than expected, resetting"; | 193 "than expected, resetting"; |
| 202 Clear(); | 194 Clear(); |
| 203 } | 195 } |
| 204 it = sources_.insert( | 196 it = sources_.insert( |
| 205 SourceIDToInfoMap::value_type(entry.source.id, SourceInfo())).first; | 197 SourceIDToInfoMap::value_type(entry.source.id, SourceInfo())).first; |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 // Release all references held to dependent sources. | 244 // Release all references held to dependent sources. |
| 253 for (SourceIDToInfoMap::iterator it = sources_.begin(); | 245 for (SourceIDToInfoMap::iterator it = sources_.begin(); |
| 254 it != sources_.end(); | 246 it != sources_.end(); |
| 255 ++it) { | 247 ++it) { |
| 256 ReleaseAllReferencesToDependencies(&(it->second)); | 248 ReleaseAllReferencesToDependencies(&(it->second)); |
| 257 } | 249 } |
| 258 sources_.clear(); | 250 sources_.clear(); |
| 259 } | 251 } |
| 260 | 252 |
| 261 void PassiveLogCollector::SourceTracker::AppendAllEntries( | 253 void PassiveLogCollector::SourceTracker::AppendAllEntries( |
| 262 EntryList* out) const { | 254 ChromeNetLog::EntryList* out) const { |
| 263 // Append all of the entries for each of the sources. | 255 // Append all of the entries for each of the sources. |
| 264 for (SourceIDToInfoMap::const_iterator it = sources_.begin(); | 256 for (SourceIDToInfoMap::const_iterator it = sources_.begin(); |
| 265 it != sources_.end(); | 257 it != sources_.end(); |
| 266 ++it) { | 258 ++it) { |
| 267 const SourceInfo& info = it->second; | 259 const SourceInfo& info = it->second; |
| 268 out->insert(out->end(), info.entries.begin(), info.entries.end()); | 260 out->insert(out->end(), info.entries.begin(), info.entries.end()); |
| 269 } | 261 } |
| 270 } | 262 } |
| 271 | 263 |
| 272 void PassiveLogCollector::SourceTracker::AddToDeletionQueue( | 264 void PassiveLogCollector::SourceTracker::AddToDeletionQueue( |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 } | 321 } |
| 330 } | 322 } |
| 331 } | 323 } |
| 332 | 324 |
| 333 void PassiveLogCollector::SourceTracker::AddReferenceToSourceDependency( | 325 void PassiveLogCollector::SourceTracker::AddReferenceToSourceDependency( |
| 334 const net::NetLog::Source& source, SourceInfo* info) { | 326 const net::NetLog::Source& source, SourceInfo* info) { |
| 335 // Find the tracker which should be holding |source|. | 327 // Find the tracker which should be holding |source|. |
| 336 DCHECK(parent_); | 328 DCHECK(parent_); |
| 337 DCHECK_NE(source.type, net::NetLog::SOURCE_NONE); | 329 DCHECK_NE(source.type, net::NetLog::SOURCE_NONE); |
| 338 SourceTracker* tracker = static_cast<SourceTracker*>( | 330 SourceTracker* tracker = static_cast<SourceTracker*>( |
| 339 parent_->GetTrackerForSourceType(source.type)); | 331 parent_->GetTrackerForSourceType_(source.type)); |
| 340 DCHECK(tracker); | 332 DCHECK(tracker); |
| 341 | 333 |
| 342 // Tell the owning tracker to increment the reference count of |source|. | 334 // Tell the owning tracker to increment the reference count of |source|. |
| 343 tracker->AdjustReferenceCountForSource(1, source.id); | 335 tracker->AdjustReferenceCountForSource(1, source.id); |
| 344 | 336 |
| 345 // Make a note to release this reference once |info| is destroyed. | 337 // Make a note to release this reference once |info| is destroyed. |
| 346 info->dependencies.push_back(source); | 338 info->dependencies.push_back(source); |
| 347 } | 339 } |
| 348 | 340 |
| 349 void | 341 void |
| 350 PassiveLogCollector::SourceTracker::ReleaseAllReferencesToDependencies( | 342 PassiveLogCollector::SourceTracker::ReleaseAllReferencesToDependencies( |
| 351 SourceInfo* info) { | 343 SourceInfo* info) { |
| 352 // Release all references |info| was holding to other sources. | 344 // Release all references |info| was holding to other sources. |
| 353 for (SourceDependencyList::const_iterator it = info->dependencies.begin(); | 345 for (SourceDependencyList::const_iterator it = info->dependencies.begin(); |
| 354 it != info->dependencies.end(); ++it) { | 346 it != info->dependencies.end(); ++it) { |
| 355 const net::NetLog::Source& source = *it; | 347 const net::NetLog::Source& source = *it; |
| 356 | 348 |
| 357 // Find the tracker which should be holding |source|. | 349 // Find the tracker which should be holding |source|. |
| 358 DCHECK(parent_); | 350 DCHECK(parent_); |
| 359 DCHECK_NE(source.type, net::NetLog::SOURCE_NONE); | 351 DCHECK_NE(source.type, net::NetLog::SOURCE_NONE); |
| 360 SourceTracker* tracker = static_cast<SourceTracker*>( | 352 SourceTracker* tracker = static_cast<SourceTracker*>( |
| 361 parent_->GetTrackerForSourceType(source.type)); | 353 parent_->GetTrackerForSourceType_(source.type)); |
| 362 DCHECK(tracker); | 354 DCHECK(tracker); |
| 363 | 355 |
| 364 // Tell the owning tracker to decrement the reference count of |source|. | 356 // Tell the owning tracker to decrement the reference count of |source|. |
| 365 tracker->AdjustReferenceCountForSource(-1, source.id); | 357 tracker->AdjustReferenceCountForSource(-1, source.id); |
| 366 } | 358 } |
| 367 | 359 |
| 368 info->dependencies.clear(); | 360 info->dependencies.clear(); |
| 369 } | 361 } |
| 370 | 362 |
| 371 //---------------------------------------------------------------------------- | 363 //---------------------------------------------------------------------------- |
| 372 // ConnectJobTracker | 364 // ConnectJobTracker |
| 373 //---------------------------------------------------------------------------- | 365 //---------------------------------------------------------------------------- |
| 374 | 366 |
| 375 const size_t PassiveLogCollector::ConnectJobTracker::kMaxNumSources = 100; | 367 const size_t PassiveLogCollector::ConnectJobTracker::kMaxNumSources = 100; |
| 376 const size_t PassiveLogCollector::ConnectJobTracker::kMaxGraveyardSize = 15; | 368 const size_t PassiveLogCollector::ConnectJobTracker::kMaxGraveyardSize = 15; |
| 377 | 369 |
| 378 PassiveLogCollector::ConnectJobTracker::ConnectJobTracker( | 370 PassiveLogCollector::ConnectJobTracker::ConnectJobTracker( |
| 379 PassiveLogCollector* parent) | 371 PassiveLogCollector* parent) |
| 380 : SourceTracker(kMaxNumSources, kMaxGraveyardSize, parent) { | 372 : SourceTracker(kMaxNumSources, kMaxGraveyardSize, parent) { |
| 381 } | 373 } |
| 382 | 374 |
| 383 PassiveLogCollector::SourceTracker::Action | 375 PassiveLogCollector::SourceTracker::Action |
| 384 PassiveLogCollector::ConnectJobTracker::DoAddEntry(const Entry& entry, | 376 PassiveLogCollector::ConnectJobTracker::DoAddEntry( |
| 385 SourceInfo* out_info) { | 377 const ChromeNetLog::Entry& entry, SourceInfo* out_info) { |
| 386 AddEntryToSourceInfo(entry, out_info); | 378 AddEntryToSourceInfo(entry, out_info); |
| 387 | 379 |
| 388 if (entry.type == net::NetLog::TYPE_CONNECT_JOB_SET_SOCKET) { | 380 if (entry.type == net::NetLog::TYPE_CONNECT_JOB_SET_SOCKET) { |
| 389 const net::NetLog::Source& source_dependency = | 381 const net::NetLog::Source& source_dependency = |
| 390 static_cast<net::NetLogSourceParameter*>(entry.params.get())->value(); | 382 static_cast<net::NetLogSourceParameter*>(entry.params.get())->value(); |
| 391 AddReferenceToSourceDependency(source_dependency, out_info); | 383 AddReferenceToSourceDependency(source_dependency, out_info); |
| 392 } | 384 } |
| 393 | 385 |
| 394 // If this is the end of the connect job, move the source to the graveyard. | 386 // If this is the end of the connect job, move the source to the graveyard. |
| 395 if (entry.type == net::NetLog::TYPE_SOCKET_POOL_CONNECT_JOB && | 387 if (entry.type == net::NetLog::TYPE_SOCKET_POOL_CONNECT_JOB && |
| 396 entry.phase == net::NetLog::PHASE_END) { | 388 entry.phase == net::NetLog::PHASE_END) { |
| 397 return ACTION_MOVE_TO_GRAVEYARD; | 389 return ACTION_MOVE_TO_GRAVEYARD; |
| 398 } | 390 } |
| 399 | 391 |
| 400 return ACTION_NONE; | 392 return ACTION_NONE; |
| 401 } | 393 } |
| 402 | 394 |
| 403 //---------------------------------------------------------------------------- | 395 //---------------------------------------------------------------------------- |
| 404 // SocketTracker | 396 // SocketTracker |
| 405 //---------------------------------------------------------------------------- | 397 //---------------------------------------------------------------------------- |
| 406 | 398 |
| 407 const size_t PassiveLogCollector::SocketTracker::kMaxNumSources = 200; | 399 const size_t PassiveLogCollector::SocketTracker::kMaxNumSources = 200; |
| 408 const size_t PassiveLogCollector::SocketTracker::kMaxGraveyardSize = 15; | 400 const size_t PassiveLogCollector::SocketTracker::kMaxGraveyardSize = 15; |
| 409 | 401 |
| 410 PassiveLogCollector::SocketTracker::SocketTracker() | 402 PassiveLogCollector::SocketTracker::SocketTracker() |
| 411 : SourceTracker(kMaxNumSources, kMaxGraveyardSize, NULL) { | 403 : SourceTracker(kMaxNumSources, kMaxGraveyardSize, NULL) { |
| 412 } | 404 } |
| 413 | 405 |
| 414 PassiveLogCollector::SourceTracker::Action | 406 PassiveLogCollector::SourceTracker::Action |
| 415 PassiveLogCollector::SocketTracker::DoAddEntry(const Entry& entry, | 407 PassiveLogCollector::SocketTracker::DoAddEntry(const ChromeNetLog::Entry& entry, |
| 416 SourceInfo* out_info) { | 408 SourceInfo* out_info) { |
| 417 // TODO(eroman): aggregate the byte counts once truncation starts to happen, | 409 // TODO(eroman): aggregate the byte counts once truncation starts to happen, |
| 418 // to summarize transaction read/writes for each SOCKET_IN_USE | 410 // to summarize transaction read/writes for each SOCKET_IN_USE |
| 419 // section. | 411 // section. |
| 420 if (entry.type == net::NetLog::TYPE_SOCKET_BYTES_SENT || | 412 if (entry.type == net::NetLog::TYPE_SOCKET_BYTES_SENT || |
| 421 entry.type == net::NetLog::TYPE_SOCKET_BYTES_RECEIVED) { | 413 entry.type == net::NetLog::TYPE_SOCKET_BYTES_RECEIVED) { |
| 422 return ACTION_NONE; | 414 return ACTION_NONE; |
| 423 } | 415 } |
| 424 | 416 |
| 425 AddEntryToSourceInfo(entry, out_info); | 417 AddEntryToSourceInfo(entry, out_info); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 437 //---------------------------------------------------------------------------- | 429 //---------------------------------------------------------------------------- |
| 438 | 430 |
| 439 const size_t PassiveLogCollector::RequestTracker::kMaxNumSources = 100; | 431 const size_t PassiveLogCollector::RequestTracker::kMaxNumSources = 100; |
| 440 const size_t PassiveLogCollector::RequestTracker::kMaxGraveyardSize = 25; | 432 const size_t PassiveLogCollector::RequestTracker::kMaxGraveyardSize = 25; |
| 441 | 433 |
| 442 PassiveLogCollector::RequestTracker::RequestTracker(PassiveLogCollector* parent) | 434 PassiveLogCollector::RequestTracker::RequestTracker(PassiveLogCollector* parent) |
| 443 : SourceTracker(kMaxNumSources, kMaxGraveyardSize, parent) { | 435 : SourceTracker(kMaxNumSources, kMaxGraveyardSize, parent) { |
| 444 } | 436 } |
| 445 | 437 |
| 446 PassiveLogCollector::SourceTracker::Action | 438 PassiveLogCollector::SourceTracker::Action |
| 447 PassiveLogCollector::RequestTracker::DoAddEntry(const Entry& entry, | 439 PassiveLogCollector::RequestTracker::DoAddEntry( |
| 448 SourceInfo* out_info) { | 440 const ChromeNetLog::Entry& entry, SourceInfo* out_info) { |
| 449 if (entry.type == net::NetLog::TYPE_SOCKET_POOL_BOUND_TO_CONNECT_JOB || | 441 if (entry.type == net::NetLog::TYPE_SOCKET_POOL_BOUND_TO_CONNECT_JOB || |
| 450 entry.type == net::NetLog::TYPE_SOCKET_POOL_BOUND_TO_SOCKET) { | 442 entry.type == net::NetLog::TYPE_SOCKET_POOL_BOUND_TO_SOCKET) { |
| 451 const net::NetLog::Source& source_dependency = | 443 const net::NetLog::Source& source_dependency = |
| 452 static_cast<net::NetLogSourceParameter*>(entry.params.get())->value(); | 444 static_cast<net::NetLogSourceParameter*>(entry.params.get())->value(); |
| 453 AddReferenceToSourceDependency(source_dependency, out_info); | 445 AddReferenceToSourceDependency(source_dependency, out_info); |
| 454 } | 446 } |
| 455 | 447 |
| 456 AddEntryToSourceInfo(entry, out_info); | 448 AddEntryToSourceInfo(entry, out_info); |
| 457 | 449 |
| 458 // If the request has ended, move it to the graveyard. | 450 // If the request has ended, move it to the graveyard. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 476 const size_t PassiveLogCollector::InitProxyResolverTracker::kMaxNumSources = 20; | 468 const size_t PassiveLogCollector::InitProxyResolverTracker::kMaxNumSources = 20; |
| 477 const size_t PassiveLogCollector::InitProxyResolverTracker::kMaxGraveyardSize = | 469 const size_t PassiveLogCollector::InitProxyResolverTracker::kMaxGraveyardSize = |
| 478 3; | 470 3; |
| 479 | 471 |
| 480 PassiveLogCollector::InitProxyResolverTracker::InitProxyResolverTracker() | 472 PassiveLogCollector::InitProxyResolverTracker::InitProxyResolverTracker() |
| 481 : SourceTracker(kMaxNumSources, kMaxGraveyardSize, NULL) { | 473 : SourceTracker(kMaxNumSources, kMaxGraveyardSize, NULL) { |
| 482 } | 474 } |
| 483 | 475 |
| 484 PassiveLogCollector::SourceTracker::Action | 476 PassiveLogCollector::SourceTracker::Action |
| 485 PassiveLogCollector::InitProxyResolverTracker::DoAddEntry( | 477 PassiveLogCollector::InitProxyResolverTracker::DoAddEntry( |
| 486 const Entry& entry, SourceInfo* out_info) { | 478 const ChromeNetLog::Entry& entry, SourceInfo* out_info) { |
| 487 AddEntryToSourceInfo(entry, out_info); | 479 AddEntryToSourceInfo(entry, out_info); |
| 488 if (entry.type == net::NetLog::TYPE_INIT_PROXY_RESOLVER && | 480 if (entry.type == net::NetLog::TYPE_INIT_PROXY_RESOLVER && |
| 489 entry.phase == net::NetLog::PHASE_END) { | 481 entry.phase == net::NetLog::PHASE_END) { |
| 490 return ACTION_MOVE_TO_GRAVEYARD; | 482 return ACTION_MOVE_TO_GRAVEYARD; |
| 491 } else { | 483 } else { |
| 492 return ACTION_NONE; | 484 return ACTION_NONE; |
| 493 } | 485 } |
| 494 } | 486 } |
| 495 | 487 |
| 496 //---------------------------------------------------------------------------- | 488 //---------------------------------------------------------------------------- |
| 497 // SpdySessionTracker | 489 // SpdySessionTracker |
| 498 //---------------------------------------------------------------------------- | 490 //---------------------------------------------------------------------------- |
| 499 | 491 |
| 500 const size_t PassiveLogCollector::SpdySessionTracker::kMaxNumSources = 50; | 492 const size_t PassiveLogCollector::SpdySessionTracker::kMaxNumSources = 50; |
| 501 const size_t PassiveLogCollector::SpdySessionTracker::kMaxGraveyardSize = 10; | 493 const size_t PassiveLogCollector::SpdySessionTracker::kMaxGraveyardSize = 10; |
| 502 | 494 |
| 503 PassiveLogCollector::SpdySessionTracker::SpdySessionTracker() | 495 PassiveLogCollector::SpdySessionTracker::SpdySessionTracker() |
| 504 : SourceTracker(kMaxNumSources, kMaxGraveyardSize, NULL) { | 496 : SourceTracker(kMaxNumSources, kMaxGraveyardSize, NULL) { |
| 505 } | 497 } |
| 506 | 498 |
| 507 PassiveLogCollector::SourceTracker::Action | 499 PassiveLogCollector::SourceTracker::Action |
| 508 PassiveLogCollector::SpdySessionTracker::DoAddEntry(const Entry& entry, | 500 PassiveLogCollector::SpdySessionTracker::DoAddEntry( |
| 509 SourceInfo* out_info) { | 501 const ChromeNetLog::Entry& entry, SourceInfo* out_info) { |
| 510 AddEntryToSourceInfo(entry, out_info); | 502 AddEntryToSourceInfo(entry, out_info); |
| 511 if (entry.type == net::NetLog::TYPE_SPDY_SESSION && | 503 if (entry.type == net::NetLog::TYPE_SPDY_SESSION && |
| 512 entry.phase == net::NetLog::PHASE_END) { | 504 entry.phase == net::NetLog::PHASE_END) { |
| 513 return ACTION_MOVE_TO_GRAVEYARD; | 505 return ACTION_MOVE_TO_GRAVEYARD; |
| 514 } else { | 506 } else { |
| 515 return ACTION_NONE; | 507 return ACTION_NONE; |
| 516 } | 508 } |
| 517 } | 509 } |
| 518 | 510 |
| 519 //---------------------------------------------------------------------------- | 511 //---------------------------------------------------------------------------- |
| 520 // DNSRequestTracker | 512 // DNSRequestTracker |
| 521 //---------------------------------------------------------------------------- | 513 //---------------------------------------------------------------------------- |
| 522 | 514 |
| 523 const size_t PassiveLogCollector::DNSRequestTracker::kMaxNumSources = 200; | 515 const size_t PassiveLogCollector::DNSRequestTracker::kMaxNumSources = 200; |
| 524 const size_t PassiveLogCollector::DNSRequestTracker::kMaxGraveyardSize = 20; | 516 const size_t PassiveLogCollector::DNSRequestTracker::kMaxGraveyardSize = 20; |
| 525 | 517 |
| 526 PassiveLogCollector::DNSRequestTracker::DNSRequestTracker() | 518 PassiveLogCollector::DNSRequestTracker::DNSRequestTracker() |
| 527 : SourceTracker(kMaxNumSources, kMaxGraveyardSize, NULL) { | 519 : SourceTracker(kMaxNumSources, kMaxGraveyardSize, NULL) { |
| 528 } | 520 } |
| 529 | 521 |
| 530 PassiveLogCollector::SourceTracker::Action | 522 PassiveLogCollector::SourceTracker::Action |
| 531 PassiveLogCollector::DNSRequestTracker::DoAddEntry(const Entry& entry, | 523 PassiveLogCollector::DNSRequestTracker::DoAddEntry( |
| 532 SourceInfo* out_info) { | 524 const ChromeNetLog::Entry& entry, SourceInfo* out_info) { |
| 533 AddEntryToSourceInfo(entry, out_info); | 525 AddEntryToSourceInfo(entry, out_info); |
| 534 if (entry.type == net::NetLog::TYPE_HOST_RESOLVER_IMPL_REQUEST && | 526 if (entry.type == net::NetLog::TYPE_HOST_RESOLVER_IMPL_REQUEST && |
| 535 entry.phase == net::NetLog::PHASE_END) { | 527 entry.phase == net::NetLog::PHASE_END) { |
| 536 return ACTION_MOVE_TO_GRAVEYARD; | 528 return ACTION_MOVE_TO_GRAVEYARD; |
| 537 } else { | 529 } else { |
| 538 return ACTION_NONE; | 530 return ACTION_NONE; |
| 539 } | 531 } |
| 540 } | 532 } |
| 541 | 533 |
| 542 //---------------------------------------------------------------------------- | 534 //---------------------------------------------------------------------------- |
| 543 // DNSJobTracker | 535 // DNSJobTracker |
| 544 //---------------------------------------------------------------------------- | 536 //---------------------------------------------------------------------------- |
| 545 | 537 |
| 546 const size_t PassiveLogCollector::DNSJobTracker::kMaxNumSources = 100; | 538 const size_t PassiveLogCollector::DNSJobTracker::kMaxNumSources = 100; |
| 547 const size_t PassiveLogCollector::DNSJobTracker::kMaxGraveyardSize = 15; | 539 const size_t PassiveLogCollector::DNSJobTracker::kMaxGraveyardSize = 15; |
| 548 | 540 |
| 549 PassiveLogCollector::DNSJobTracker::DNSJobTracker() | 541 PassiveLogCollector::DNSJobTracker::DNSJobTracker() |
| 550 : SourceTracker(kMaxNumSources, kMaxGraveyardSize, NULL) { | 542 : SourceTracker(kMaxNumSources, kMaxGraveyardSize, NULL) { |
| 551 } | 543 } |
| 552 | 544 |
| 553 PassiveLogCollector::SourceTracker::Action | 545 PassiveLogCollector::SourceTracker::Action |
| 554 PassiveLogCollector::DNSJobTracker::DoAddEntry(const Entry& entry, | 546 PassiveLogCollector::DNSJobTracker::DoAddEntry(const ChromeNetLog::Entry& entry, |
| 555 SourceInfo* out_info) { | 547 SourceInfo* out_info) { |
| 556 AddEntryToSourceInfo(entry, out_info); | 548 AddEntryToSourceInfo(entry, out_info); |
| 557 if (entry.type == net::NetLog::TYPE_HOST_RESOLVER_IMPL_JOB && | 549 if (entry.type == net::NetLog::TYPE_HOST_RESOLVER_IMPL_JOB && |
| 558 entry.phase == net::NetLog::PHASE_END) { | 550 entry.phase == net::NetLog::PHASE_END) { |
| 559 return ACTION_MOVE_TO_GRAVEYARD; | 551 return ACTION_MOVE_TO_GRAVEYARD; |
| 560 } else { | 552 } else { |
| 561 return ACTION_NONE; | 553 return ACTION_NONE; |
| 562 } | 554 } |
| 563 } | 555 } |
| OLD | NEW |