diff options
author | mmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-18 20:08:10 +0000 |
---|---|---|
committer | mmenke@chromium.org <mmenke@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-18 20:08:10 +0000 |
commit | 8866f623dfd914c9f4c26ab96f90aecf4a372ef9 (patch) | |
tree | 4f45fa083309b6934e1888c27c9df2344cd391f0 /chrome | |
parent | def979a39bd25dfb24c80138699ffb359c495757 (diff) | |
download | chromium_src-8866f623dfd914c9f4c26ab96f90aecf4a372ef9.zip chromium_src-8866f623dfd914c9f4c26ab96f90aecf4a372ef9.tar.gz chromium_src-8866f623dfd914c9f4c26ab96f90aecf4a372ef9.tar.bz2 |
Add NetLog support to UDP sockets.
BUG=99508
TEST=UDPSocketTest.Connect
Review URL: http://codereview.chromium.org/8200011
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106109 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/net/passive_log_collector.cc | 31 | ||||
-rw-r--r-- | chrome/browser/net/passive_log_collector.h | 17 | ||||
-rw-r--r-- | chrome/browser/resources/net_internals/events_view.css | 8 | ||||
-rw-r--r-- | chrome/browser/resources/net_internals/source_entry.js | 30 | ||||
-rw-r--r-- | chrome/browser/resources/net_internals/source_tracker.js | 11 |
5 files changed, 90 insertions, 7 deletions
diff --git a/chrome/browser/net/passive_log_collector.cc b/chrome/browser/net/passive_log_collector.cc index 66950ad..db1736a 100644 --- a/chrome/browser/net/passive_log_collector.cc +++ b/chrome/browser/net/passive_log_collector.cc @@ -80,6 +80,7 @@ PassiveLogCollector::PassiveLogCollector() trackers_[net::NetLog::SOURCE_DNS_TRANSACTION] = &dns_transaction_tracker_; trackers_[net::NetLog::SOURCE_ASYNC_HOST_RESOLVER_REQUEST] = &async_host_resolver_request_tracker_; + trackers_[net::NetLog::SOURCE_UDP_SOCKET] = &udp_socket_tracker_; // Make sure our mapping is up-to-date. for (size_t i = 0; i < arraysize(trackers_); ++i) DCHECK(trackers_[i]) << "Unhandled SourceType: " << i; @@ -724,3 +725,33 @@ PassiveLogCollector::AsyncHostResolverRequestTracker::DoAddEntry( } return ACTION_NONE; } + +//---------------------------------------------------------------------------- +// UDPSocketTracker +//---------------------------------------------------------------------------- + +const size_t PassiveLogCollector::UDPSocketTracker::kMaxNumSources = 200; +const size_t PassiveLogCollector::UDPSocketTracker::kMaxGraveyardSize = 15; + +PassiveLogCollector::UDPSocketTracker::UDPSocketTracker() + : SourceTracker(kMaxNumSources, kMaxGraveyardSize, NULL) { +} + +PassiveLogCollector::UDPSocketTracker::Action +PassiveLogCollector::UDPSocketTracker::DoAddEntry( + const ChromeNetLog::Entry& entry, + SourceInfo* out_info) { + if (entry.type == net::NetLog::TYPE_UDP_BYTES_SENT || + entry.type == net::NetLog::TYPE_UDP_BYTES_RECEIVED) { + return ACTION_NONE; + } + + AddEntryToSourceInfo(entry, out_info); + + if (entry.type == net::NetLog::TYPE_SOCKET_ALIVE && + entry.phase == net::NetLog::PHASE_END) { + return ACTION_MOVE_TO_GRAVEYARD; + } + + return ACTION_NONE; +} diff --git a/chrome/browser/net/passive_log_collector.h b/chrome/browser/net/passive_log_collector.h index ae85f56..6da9734 100644 --- a/chrome/browser/net/passive_log_collector.h +++ b/chrome/browser/net/passive_log_collector.h @@ -384,6 +384,22 @@ class PassiveLogCollector : public ChromeNetLog::ThreadSafeObserverImpl { DISALLOW_COPY_AND_ASSIGN(AsyncHostResolverRequestTracker); }; + + // Tracks the log entries for the last seen SOURCE_UDP_SOCKET. + class UDPSocketTracker : public SourceTracker { + public: + static const size_t kMaxNumSources; + static const size_t kMaxGraveyardSize; + + UDPSocketTracker(); + + private: + virtual Action DoAddEntry(const ChromeNetLog::Entry& entry, + SourceInfo* out_info); + + DISALLOW_COPY_AND_ASSIGN(UDPSocketTracker); + }; + PassiveLogCollector(); virtual ~PassiveLogCollector(); @@ -426,6 +442,7 @@ class PassiveLogCollector : public ChromeNetLog::ThreadSafeObserverImpl { ExponentialBackoffThrottlingTracker exponential_backoff_throttling_tracker_; DnsTransactionTracker dns_transaction_tracker_; AsyncHostResolverRequestTracker async_host_resolver_request_tracker_; + UDPSocketTracker udp_socket_tracker_; // This array maps each NetLog::SourceType to one of the tracker instances // defined above. Use of this array avoid duplicating the list of trackers diff --git a/chrome/browser/resources/net_internals/events_view.css b/chrome/browser/resources/net_internals/events_view.css index 8bafc6b..ee89ec3 100644 --- a/chrome/browser/resources/net_internals/events_view.css +++ b/chrome/browser/resources/net_internals/events_view.css @@ -73,7 +73,9 @@ found in the LICENSE file. } #events-view-source-list-tbody .source_HOST_RESOLVER_IMPL_JOB, -#events-view-source-list-tbody .source_HOST_RESOLVER_IMPL_REQUEST { +#events-view-source-list-tbody .source_HOST_RESOLVER_IMPL_REQUEST, +#events-view-source-list-tbody .source_ASYNC_HOST_RESOLVER_REQUEST, +#events-view-source-list-tbody .source_DNS_TRANSACTION { color: #206060; } @@ -86,6 +88,10 @@ found in the LICENSE file. color: purple; } +#events-view-source-list-tbody .source_UDP_SOCKET { + color: #803030; +} + #events-view-source-list-tbody .source_INIT_PROXY_RESOLVER { color: green; } diff --git a/chrome/browser/resources/net_internals/source_entry.js b/chrome/browser/resources/net_internals/source_entry.js index db536ec..5505acb 100644 --- a/chrome/browser/resources/net_internals/source_entry.js +++ b/chrome/browser/resources/net_internals/source_entry.js @@ -99,12 +99,28 @@ var SourceEntry = (function() { this.description_ = e.params.host + ' (' + e.params.proxy + ')'; break; case LogSourceType.SOCKET: + // Use description of parent source, if any. if (e.params.source_dependency != undefined) { - var connectJobId = e.params.source_dependency.id; - var connectJob = - g_browser.sourceTracker.getSourceEntry(connectJobId); - if (connectJob) - this.description_ = connectJob.getDescription(); + var parentId = e.params.source_dependency.id; + this.description_ = + g_browser.sourceTracker.getDescription(parentId); + } + break; + case LogSourceType.UDP_SOCKET: + if (e.params.address != undefined) { + this.description_ = e.params.address; + // If the parent of |this| is a DNS_TRANSACTION, use + // '<DNS Server IP> [<DNS we're resolving>]'. + if (this.entries_[0].type == LogEventType.SOCKET_ALIVE && + this.entries_[0].params.source_dependency != undefined) { + var parentId = this.entries_[0].params.source_dependency.id; + var parent = g_browser.sourceTracker.getSourceEntry(parentId); + if (parent && + parent.getSourceType() == LogSourceType.DNS_TRANSACTION && + parent.getDescription().length > 0) { + this.description_ += ' [' + parent.getDescription() + ']'; + } + } } break; case LogSourceType.ASYNC_HOST_RESOLVER_REQUEST: @@ -137,8 +153,10 @@ var SourceEntry = (function() { return undefined; if (this.entries_.length >= 2) { if (this.entries_[0].type == LogEventType.REQUEST_ALIVE || - this.entries_[0].type == LogEventType.SOCKET_POOL_CONNECT_JOB) + this.entries_[0].type == LogEventType.SOCKET_POOL_CONNECT_JOB || + this.entries_[1].type == LogEventType.UDP_CONNECT) { return this.entries_[1]; + } } return this.entries_[0]; }, diff --git a/chrome/browser/resources/net_internals/source_tracker.js b/chrome/browser/resources/net_internals/source_tracker.js index 8be2393..09f7f1a 100644 --- a/chrome/browser/resources/net_internals/source_tracker.js +++ b/chrome/browser/resources/net_internals/source_tracker.js @@ -75,6 +75,17 @@ var SourceTracker = (function() { }, /** + * Returns the description of the specified SourceEntry, or an empty string + * if it doesn't exist. + */ + getDescription: function(id) { + var entry = this.getSourceEntry(id); + if (entry) + return entry.getDescription(); + return ''; + }, + + /** * Returns the specified SourceEntry. */ getSourceEntry: function(id) { |