| 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 //---------------------------------------------------------------------------- |
| 66 // PassiveLogCollector | 51 // PassiveLogCollector |
| 67 //---------------------------------------------------------------------------- | 52 //---------------------------------------------------------------------------- |
| 68 | 53 |
| 69 PassiveLogCollector::PassiveLogCollector() | 54 PassiveLogCollector::PassiveLogCollector() |
| 70 : Observer(net::NetLog::LOG_BASIC), | 55 : ThreadSafeObserver(net::NetLog::LOG_BASIC), |
| 71 ALLOW_THIS_IN_INITIALIZER_LIST(connect_job_tracker_(this)), | 56 ALLOW_THIS_IN_INITIALIZER_LIST(connect_job_tracker_(this)), |
| 72 ALLOW_THIS_IN_INITIALIZER_LIST(url_request_tracker_(this)), | 57 ALLOW_THIS_IN_INITIALIZER_LIST(url_request_tracker_(this)), |
| 73 ALLOW_THIS_IN_INITIALIZER_LIST(socket_stream_tracker_(this)), | 58 ALLOW_THIS_IN_INITIALIZER_LIST(socket_stream_tracker_(this)), |
| 74 num_events_seen_(0) { | 59 num_events_seen_(0) { |
| 75 | 60 |
| 76 // Define the mapping between source types and the tracker objects. | 61 // Define the mapping between source types and the tracker objects. |
| 77 memset(&trackers_[0], 0, sizeof(trackers_)); | 62 memset(&trackers_[0], 0, sizeof(trackers_)); |
| 78 trackers_[net::NetLog::SOURCE_NONE] = &global_source_tracker_; | 63 trackers_[net::NetLog::SOURCE_NONE] = &global_source_tracker_; |
| 79 trackers_[net::NetLog::SOURCE_URL_REQUEST] = &url_request_tracker_; | 64 trackers_[net::NetLog::SOURCE_URL_REQUEST] = &url_request_tracker_; |
| 80 trackers_[net::NetLog::SOURCE_SOCKET_STREAM] = &socket_stream_tracker_; | 65 trackers_[net::NetLog::SOURCE_SOCKET_STREAM] = &socket_stream_tracker_; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 93 | 78 |
| 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) { |
| 88 AssertNetLogLockAcquired(); |
| 103 // Package the parameters into a single struct for convenience. | 89 // Package the parameters into a single struct for convenience. |
| 104 Entry entry(num_events_seen_++, type, time, source, phase, params); | 90 ChromeNetLog::Entry entry(num_events_seen_++, type, time, source, phase, |
| 91 params); |
| 105 | 92 |
| 106 SourceTrackerInterface* tracker = GetTrackerForSourceType(entry.source.type); | 93 SourceTrackerInterface* tracker = GetTrackerForSourceType_(entry.source.type); |
| 107 if (tracker) | 94 if (tracker) |
| 108 tracker->OnAddEntry(entry); | 95 tracker->OnAddEntry(entry); |
| 109 } | 96 } |
| 110 | 97 |
| 98 void PassiveLogCollector::Clear() { |
| 99 AssertNetLogLockAcquired(); |
| 100 for (size_t i = 0; i < arraysize(trackers_); ++i) |
| 101 trackers_[i]->Clear(); |
| 102 } |
| 103 |
| 111 PassiveLogCollector::SourceTrackerInterface* | 104 PassiveLogCollector::SourceTrackerInterface* |
| 112 PassiveLogCollector::GetTrackerForSourceType( | 105 PassiveLogCollector::GetTrackerForSourceType_( |
| 113 net::NetLog::SourceType source_type) { | 106 net::NetLog::SourceType source_type) { |
| 114 DCHECK_LE(source_type, static_cast<int>(arraysize(trackers_))); | 107 DCHECK_LE(source_type, static_cast<int>(arraysize(trackers_))); |
| 115 DCHECK_GE(source_type, 0); | 108 DCHECK_GE(source_type, 0); |
| 116 return trackers_[source_type]; | 109 return trackers_[source_type]; |
| 117 } | 110 } |
| 118 | 111 |
| 119 void PassiveLogCollector::Clear() { | 112 void PassiveLogCollector::GetAllCapturedEvents( |
| 120 for (size_t i = 0; i < arraysize(trackers_); ++i) | 113 ChromeNetLog::EntryList* out) const { |
| 121 trackers_[i]->Clear(); | 114 AssertNetLogLockAcquired(); |
| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 } | 329 } |
| 338 } | 330 } |
| 339 } | 331 } |
| 340 | 332 |
| 341 void PassiveLogCollector::SourceTracker::AddReferenceToSourceDependency( | 333 void PassiveLogCollector::SourceTracker::AddReferenceToSourceDependency( |
| 342 const net::NetLog::Source& source, SourceInfo* info) { | 334 const net::NetLog::Source& source, SourceInfo* info) { |
| 343 // Find the tracker which should be holding |source|. | 335 // Find the tracker which should be holding |source|. |
| 344 DCHECK(parent_); | 336 DCHECK(parent_); |
| 345 DCHECK_NE(source.type, net::NetLog::SOURCE_NONE); | 337 DCHECK_NE(source.type, net::NetLog::SOURCE_NONE); |
| 346 SourceTracker* tracker = static_cast<SourceTracker*>( | 338 SourceTracker* tracker = static_cast<SourceTracker*>( |
| 347 parent_->GetTrackerForSourceType(source.type)); | 339 parent_->GetTrackerForSourceType_(source.type)); |
| 348 DCHECK(tracker); | 340 DCHECK(tracker); |
| 349 | 341 |
| 350 // Tell the owning tracker to increment the reference count of |source|. | 342 // Tell the owning tracker to increment the reference count of |source|. |
| 351 tracker->AdjustReferenceCountForSource(1, source.id); | 343 tracker->AdjustReferenceCountForSource(1, source.id); |
| 352 | 344 |
| 353 // Make a note to release this reference once |info| is destroyed. | 345 // Make a note to release this reference once |info| is destroyed. |
| 354 info->dependencies.push_back(source); | 346 info->dependencies.push_back(source); |
| 355 } | 347 } |
| 356 | 348 |
| 357 void | 349 void |
| 358 PassiveLogCollector::SourceTracker::ReleaseAllReferencesToDependencies( | 350 PassiveLogCollector::SourceTracker::ReleaseAllReferencesToDependencies( |
| 359 SourceInfo* info) { | 351 SourceInfo* info) { |
| 360 // Release all references |info| was holding to other sources. | 352 // Release all references |info| was holding to other sources. |
| 361 for (SourceDependencyList::const_iterator it = info->dependencies.begin(); | 353 for (SourceDependencyList::const_iterator it = info->dependencies.begin(); |
| 362 it != info->dependencies.end(); ++it) { | 354 it != info->dependencies.end(); ++it) { |
| 363 const net::NetLog::Source& source = *it; | 355 const net::NetLog::Source& source = *it; |
| 364 | 356 |
| 365 // Find the tracker which should be holding |source|. | 357 // Find the tracker which should be holding |source|. |
| 366 DCHECK(parent_); | 358 DCHECK(parent_); |
| 367 DCHECK_NE(source.type, net::NetLog::SOURCE_NONE); | 359 DCHECK_NE(source.type, net::NetLog::SOURCE_NONE); |
| 368 SourceTracker* tracker = static_cast<SourceTracker*>( | 360 SourceTracker* tracker = static_cast<SourceTracker*>( |
| 369 parent_->GetTrackerForSourceType(source.type)); | 361 parent_->GetTrackerForSourceType_(source.type)); |
| 370 DCHECK(tracker); | 362 DCHECK(tracker); |
| 371 | 363 |
| 372 // Tell the owning tracker to decrement the reference count of |source|. | 364 // Tell the owning tracker to decrement the reference count of |source|. |
| 373 tracker->AdjustReferenceCountForSource(-1, source.id); | 365 tracker->AdjustReferenceCountForSource(-1, source.id); |
| 374 } | 366 } |
| 375 | 367 |
| 376 info->dependencies.clear(); | 368 info->dependencies.clear(); |
| 377 } | 369 } |
| 378 | 370 |
| 379 //---------------------------------------------------------------------------- | 371 //---------------------------------------------------------------------------- |
| 380 // ConnectJobTracker | 372 // ConnectJobTracker |
| 381 //---------------------------------------------------------------------------- | 373 //---------------------------------------------------------------------------- |
| 382 | 374 |
| 383 const size_t PassiveLogCollector::ConnectJobTracker::kMaxNumSources = 100; | 375 const size_t PassiveLogCollector::ConnectJobTracker::kMaxNumSources = 100; |
| 384 const size_t PassiveLogCollector::ConnectJobTracker::kMaxGraveyardSize = 15; | 376 const size_t PassiveLogCollector::ConnectJobTracker::kMaxGraveyardSize = 15; |
| 385 | 377 |
| 386 PassiveLogCollector::ConnectJobTracker::ConnectJobTracker( | 378 PassiveLogCollector::ConnectJobTracker::ConnectJobTracker( |
| 387 PassiveLogCollector* parent) | 379 PassiveLogCollector* parent) |
| 388 : SourceTracker(kMaxNumSources, kMaxGraveyardSize, parent) { | 380 : SourceTracker(kMaxNumSources, kMaxGraveyardSize, parent) { |
| 389 } | 381 } |
| 390 | 382 |
| 391 PassiveLogCollector::SourceTracker::Action | 383 PassiveLogCollector::SourceTracker::Action |
| 392 PassiveLogCollector::ConnectJobTracker::DoAddEntry(const Entry& entry, | 384 PassiveLogCollector::ConnectJobTracker::DoAddEntry( |
| 393 SourceInfo* out_info) { | 385 const ChromeNetLog::Entry& entry, SourceInfo* out_info) { |
| 394 AddEntryToSourceInfo(entry, out_info); | 386 AddEntryToSourceInfo(entry, out_info); |
| 395 | 387 |
| 396 if (entry.type == net::NetLog::TYPE_CONNECT_JOB_SET_SOCKET) { | 388 if (entry.type == net::NetLog::TYPE_CONNECT_JOB_SET_SOCKET) { |
| 397 const net::NetLog::Source& source_dependency = | 389 const net::NetLog::Source& source_dependency = |
| 398 static_cast<net::NetLogSourceParameter*>(entry.params.get())->value(); | 390 static_cast<net::NetLogSourceParameter*>(entry.params.get())->value(); |
| 399 AddReferenceToSourceDependency(source_dependency, out_info); | 391 AddReferenceToSourceDependency(source_dependency, out_info); |
| 400 } | 392 } |
| 401 | 393 |
| 402 // If this is the end of the connect job, move the source to the graveyard. | 394 // If this is the end of the connect job, move the source to the graveyard. |
| 403 if (entry.type == net::NetLog::TYPE_SOCKET_POOL_CONNECT_JOB && | 395 if (entry.type == net::NetLog::TYPE_SOCKET_POOL_CONNECT_JOB && |
| 404 entry.phase == net::NetLog::PHASE_END) { | 396 entry.phase == net::NetLog::PHASE_END) { |
| 405 return ACTION_MOVE_TO_GRAVEYARD; | 397 return ACTION_MOVE_TO_GRAVEYARD; |
| 406 } | 398 } |
| 407 | 399 |
| 408 return ACTION_NONE; | 400 return ACTION_NONE; |
| 409 } | 401 } |
| 410 | 402 |
| 411 //---------------------------------------------------------------------------- | 403 //---------------------------------------------------------------------------- |
| 412 // SocketTracker | 404 // SocketTracker |
| 413 //---------------------------------------------------------------------------- | 405 //---------------------------------------------------------------------------- |
| 414 | 406 |
| 415 const size_t PassiveLogCollector::SocketTracker::kMaxNumSources = 200; | 407 const size_t PassiveLogCollector::SocketTracker::kMaxNumSources = 200; |
| 416 const size_t PassiveLogCollector::SocketTracker::kMaxGraveyardSize = 15; | 408 const size_t PassiveLogCollector::SocketTracker::kMaxGraveyardSize = 15; |
| 417 | 409 |
| 418 PassiveLogCollector::SocketTracker::SocketTracker() | 410 PassiveLogCollector::SocketTracker::SocketTracker() |
| 419 : SourceTracker(kMaxNumSources, kMaxGraveyardSize, NULL) { | 411 : SourceTracker(kMaxNumSources, kMaxGraveyardSize, NULL) { |
| 420 } | 412 } |
| 421 | 413 |
| 422 PassiveLogCollector::SourceTracker::Action | 414 PassiveLogCollector::SourceTracker::Action |
| 423 PassiveLogCollector::SocketTracker::DoAddEntry(const Entry& entry, | 415 PassiveLogCollector::SocketTracker::DoAddEntry(const ChromeNetLog::Entry& entry, |
| 424 SourceInfo* out_info) { | 416 SourceInfo* out_info) { |
| 425 // TODO(eroman): aggregate the byte counts once truncation starts to happen, | 417 // TODO(eroman): aggregate the byte counts once truncation starts to happen, |
| 426 // to summarize transaction read/writes for each SOCKET_IN_USE | 418 // to summarize transaction read/writes for each SOCKET_IN_USE |
| 427 // section. | 419 // section. |
| 428 if (entry.type == net::NetLog::TYPE_SOCKET_BYTES_SENT || | 420 if (entry.type == net::NetLog::TYPE_SOCKET_BYTES_SENT || |
| 429 entry.type == net::NetLog::TYPE_SOCKET_BYTES_RECEIVED) { | 421 entry.type == net::NetLog::TYPE_SOCKET_BYTES_RECEIVED) { |
| 430 return ACTION_NONE; | 422 return ACTION_NONE; |
| 431 } | 423 } |
| 432 | 424 |
| 433 AddEntryToSourceInfo(entry, out_info); | 425 AddEntryToSourceInfo(entry, out_info); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 445 //---------------------------------------------------------------------------- | 437 //---------------------------------------------------------------------------- |
| 446 | 438 |
| 447 const size_t PassiveLogCollector::RequestTracker::kMaxNumSources = 100; | 439 const size_t PassiveLogCollector::RequestTracker::kMaxNumSources = 100; |
| 448 const size_t PassiveLogCollector::RequestTracker::kMaxGraveyardSize = 25; | 440 const size_t PassiveLogCollector::RequestTracker::kMaxGraveyardSize = 25; |
| 449 | 441 |
| 450 PassiveLogCollector::RequestTracker::RequestTracker(PassiveLogCollector* parent) | 442 PassiveLogCollector::RequestTracker::RequestTracker(PassiveLogCollector* parent) |
| 451 : SourceTracker(kMaxNumSources, kMaxGraveyardSize, parent) { | 443 : SourceTracker(kMaxNumSources, kMaxGraveyardSize, parent) { |
| 452 } | 444 } |
| 453 | 445 |
| 454 PassiveLogCollector::SourceTracker::Action | 446 PassiveLogCollector::SourceTracker::Action |
| 455 PassiveLogCollector::RequestTracker::DoAddEntry(const Entry& entry, | 447 PassiveLogCollector::RequestTracker::DoAddEntry( |
| 456 SourceInfo* out_info) { | 448 const ChromeNetLog::Entry& entry, SourceInfo* out_info) { |
| 457 if (entry.type == net::NetLog::TYPE_SOCKET_POOL_BOUND_TO_CONNECT_JOB || | 449 if (entry.type == net::NetLog::TYPE_SOCKET_POOL_BOUND_TO_CONNECT_JOB || |
| 458 entry.type == net::NetLog::TYPE_SOCKET_POOL_BOUND_TO_SOCKET) { | 450 entry.type == net::NetLog::TYPE_SOCKET_POOL_BOUND_TO_SOCKET) { |
| 459 const net::NetLog::Source& source_dependency = | 451 const net::NetLog::Source& source_dependency = |
| 460 static_cast<net::NetLogSourceParameter*>(entry.params.get())->value(); | 452 static_cast<net::NetLogSourceParameter*>(entry.params.get())->value(); |
| 461 AddReferenceToSourceDependency(source_dependency, out_info); | 453 AddReferenceToSourceDependency(source_dependency, out_info); |
| 462 } | 454 } |
| 463 | 455 |
| 464 AddEntryToSourceInfo(entry, out_info); | 456 AddEntryToSourceInfo(entry, out_info); |
| 465 | 457 |
| 466 // If the request has ended, move it to the graveyard. | 458 // If the request has ended, move it to the graveyard. |
| (...skipping 17 matching lines...) Expand all Loading... |
| 484 const size_t PassiveLogCollector::InitProxyResolverTracker::kMaxNumSources = 20; | 476 const size_t PassiveLogCollector::InitProxyResolverTracker::kMaxNumSources = 20; |
| 485 const size_t PassiveLogCollector::InitProxyResolverTracker::kMaxGraveyardSize = | 477 const size_t PassiveLogCollector::InitProxyResolverTracker::kMaxGraveyardSize = |
| 486 3; | 478 3; |
| 487 | 479 |
| 488 PassiveLogCollector::InitProxyResolverTracker::InitProxyResolverTracker() | 480 PassiveLogCollector::InitProxyResolverTracker::InitProxyResolverTracker() |
| 489 : SourceTracker(kMaxNumSources, kMaxGraveyardSize, NULL) { | 481 : SourceTracker(kMaxNumSources, kMaxGraveyardSize, NULL) { |
| 490 } | 482 } |
| 491 | 483 |
| 492 PassiveLogCollector::SourceTracker::Action | 484 PassiveLogCollector::SourceTracker::Action |
| 493 PassiveLogCollector::InitProxyResolverTracker::DoAddEntry( | 485 PassiveLogCollector::InitProxyResolverTracker::DoAddEntry( |
| 494 const Entry& entry, SourceInfo* out_info) { | 486 const ChromeNetLog::Entry& entry, SourceInfo* out_info) { |
| 495 AddEntryToSourceInfo(entry, out_info); | 487 AddEntryToSourceInfo(entry, out_info); |
| 496 if (entry.type == net::NetLog::TYPE_INIT_PROXY_RESOLVER && | 488 if (entry.type == net::NetLog::TYPE_INIT_PROXY_RESOLVER && |
| 497 entry.phase == net::NetLog::PHASE_END) { | 489 entry.phase == net::NetLog::PHASE_END) { |
| 498 return ACTION_MOVE_TO_GRAVEYARD; | 490 return ACTION_MOVE_TO_GRAVEYARD; |
| 499 } else { | 491 } else { |
| 500 return ACTION_NONE; | 492 return ACTION_NONE; |
| 501 } | 493 } |
| 502 } | 494 } |
| 503 | 495 |
| 504 //---------------------------------------------------------------------------- | 496 //---------------------------------------------------------------------------- |
| 505 // SpdySessionTracker | 497 // SpdySessionTracker |
| 506 //---------------------------------------------------------------------------- | 498 //---------------------------------------------------------------------------- |
| 507 | 499 |
| 508 const size_t PassiveLogCollector::SpdySessionTracker::kMaxNumSources = 50; | 500 const size_t PassiveLogCollector::SpdySessionTracker::kMaxNumSources = 50; |
| 509 const size_t PassiveLogCollector::SpdySessionTracker::kMaxGraveyardSize = 10; | 501 const size_t PassiveLogCollector::SpdySessionTracker::kMaxGraveyardSize = 10; |
| 510 | 502 |
| 511 PassiveLogCollector::SpdySessionTracker::SpdySessionTracker() | 503 PassiveLogCollector::SpdySessionTracker::SpdySessionTracker() |
| 512 : SourceTracker(kMaxNumSources, kMaxGraveyardSize, NULL) { | 504 : SourceTracker(kMaxNumSources, kMaxGraveyardSize, NULL) { |
| 513 } | 505 } |
| 514 | 506 |
| 515 PassiveLogCollector::SourceTracker::Action | 507 PassiveLogCollector::SourceTracker::Action |
| 516 PassiveLogCollector::SpdySessionTracker::DoAddEntry(const Entry& entry, | 508 PassiveLogCollector::SpdySessionTracker::DoAddEntry( |
| 517 SourceInfo* out_info) { | 509 const ChromeNetLog::Entry& entry, SourceInfo* out_info) { |
| 518 AddEntryToSourceInfo(entry, out_info); | 510 AddEntryToSourceInfo(entry, out_info); |
| 519 if (entry.type == net::NetLog::TYPE_SPDY_SESSION && | 511 if (entry.type == net::NetLog::TYPE_SPDY_SESSION && |
| 520 entry.phase == net::NetLog::PHASE_END) { | 512 entry.phase == net::NetLog::PHASE_END) { |
| 521 return ACTION_MOVE_TO_GRAVEYARD; | 513 return ACTION_MOVE_TO_GRAVEYARD; |
| 522 } else { | 514 } else { |
| 523 return ACTION_NONE; | 515 return ACTION_NONE; |
| 524 } | 516 } |
| 525 } | 517 } |
| 526 | 518 |
| 527 //---------------------------------------------------------------------------- | 519 //---------------------------------------------------------------------------- |
| 528 // DNSRequestTracker | 520 // DNSRequestTracker |
| 529 //---------------------------------------------------------------------------- | 521 //---------------------------------------------------------------------------- |
| 530 | 522 |
| 531 const size_t PassiveLogCollector::DNSRequestTracker::kMaxNumSources = 200; | 523 const size_t PassiveLogCollector::DNSRequestTracker::kMaxNumSources = 200; |
| 532 const size_t PassiveLogCollector::DNSRequestTracker::kMaxGraveyardSize = 20; | 524 const size_t PassiveLogCollector::DNSRequestTracker::kMaxGraveyardSize = 20; |
| 533 | 525 |
| 534 PassiveLogCollector::DNSRequestTracker::DNSRequestTracker() | 526 PassiveLogCollector::DNSRequestTracker::DNSRequestTracker() |
| 535 : SourceTracker(kMaxNumSources, kMaxGraveyardSize, NULL) { | 527 : SourceTracker(kMaxNumSources, kMaxGraveyardSize, NULL) { |
| 536 } | 528 } |
| 537 | 529 |
| 538 PassiveLogCollector::SourceTracker::Action | 530 PassiveLogCollector::SourceTracker::Action |
| 539 PassiveLogCollector::DNSRequestTracker::DoAddEntry(const Entry& entry, | 531 PassiveLogCollector::DNSRequestTracker::DoAddEntry( |
| 540 SourceInfo* out_info) { | 532 const ChromeNetLog::Entry& entry, SourceInfo* out_info) { |
| 541 AddEntryToSourceInfo(entry, out_info); | 533 AddEntryToSourceInfo(entry, out_info); |
| 542 if (entry.type == net::NetLog::TYPE_HOST_RESOLVER_IMPL_REQUEST && | 534 if (entry.type == net::NetLog::TYPE_HOST_RESOLVER_IMPL_REQUEST && |
| 543 entry.phase == net::NetLog::PHASE_END) { | 535 entry.phase == net::NetLog::PHASE_END) { |
| 544 return ACTION_MOVE_TO_GRAVEYARD; | 536 return ACTION_MOVE_TO_GRAVEYARD; |
| 545 } else { | 537 } else { |
| 546 return ACTION_NONE; | 538 return ACTION_NONE; |
| 547 } | 539 } |
| 548 } | 540 } |
| 549 | 541 |
| 550 //---------------------------------------------------------------------------- | 542 //---------------------------------------------------------------------------- |
| 551 // DNSJobTracker | 543 // DNSJobTracker |
| 552 //---------------------------------------------------------------------------- | 544 //---------------------------------------------------------------------------- |
| 553 | 545 |
| 554 const size_t PassiveLogCollector::DNSJobTracker::kMaxNumSources = 100; | 546 const size_t PassiveLogCollector::DNSJobTracker::kMaxNumSources = 100; |
| 555 const size_t PassiveLogCollector::DNSJobTracker::kMaxGraveyardSize = 15; | 547 const size_t PassiveLogCollector::DNSJobTracker::kMaxGraveyardSize = 15; |
| 556 | 548 |
| 557 PassiveLogCollector::DNSJobTracker::DNSJobTracker() | 549 PassiveLogCollector::DNSJobTracker::DNSJobTracker() |
| 558 : SourceTracker(kMaxNumSources, kMaxGraveyardSize, NULL) { | 550 : SourceTracker(kMaxNumSources, kMaxGraveyardSize, NULL) { |
| 559 } | 551 } |
| 560 | 552 |
| 561 PassiveLogCollector::SourceTracker::Action | 553 PassiveLogCollector::SourceTracker::Action |
| 562 PassiveLogCollector::DNSJobTracker::DoAddEntry(const Entry& entry, | 554 PassiveLogCollector::DNSJobTracker::DoAddEntry(const ChromeNetLog::Entry& entry, |
| 563 SourceInfo* out_info) { | 555 SourceInfo* out_info) { |
| 564 AddEntryToSourceInfo(entry, out_info); | 556 AddEntryToSourceInfo(entry, out_info); |
| 565 if (entry.type == net::NetLog::TYPE_HOST_RESOLVER_IMPL_JOB && | 557 if (entry.type == net::NetLog::TYPE_HOST_RESOLVER_IMPL_JOB && |
| 566 entry.phase == net::NetLog::PHASE_END) { | 558 entry.phase == net::NetLog::PHASE_END) { |
| 567 return ACTION_MOVE_TO_GRAVEYARD; | 559 return ACTION_MOVE_TO_GRAVEYARD; |
| 568 } else { | 560 } else { |
| 569 return ACTION_NONE; | 561 return ACTION_NONE; |
| 570 } | 562 } |
| 571 } | 563 } |
| OLD | NEW |