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