diff options
Diffstat (limited to 'chrome/browser/net')
-rw-r--r-- | chrome/browser/net/passive_log_collector.cc | 22 | ||||
-rw-r--r-- | chrome/browser/net/passive_log_collector.h | 27 | ||||
-rw-r--r-- | chrome/browser/net/passive_log_collector_unittest.cc | 32 |
3 files changed, 76 insertions, 5 deletions
diff --git a/chrome/browser/net/passive_log_collector.cc b/chrome/browser/net/passive_log_collector.cc index 1192965..bc7bbf6 100644 --- a/chrome/browser/net/passive_log_collector.cc +++ b/chrome/browser/net/passive_log_collector.cc @@ -133,6 +133,7 @@ void PassiveLogCollector::GetAllCapturedEvents(EntryList* out) const { // |out|. socket_stream_tracker_.AppendAllEntries(out); url_request_tracker_.AppendAllEntries(out); + spdy_session_tracker_.AppendAllEntries(out); const EntryList& proxy_entries = init_proxy_resolver_tracker_.entries(); @@ -556,3 +557,24 @@ void PassiveLogCollector::InitProxyResolverTracker::OnAddEntry( entries_.clear(); } +//---------------------------------------------------------------------------- +// SpdySessionTracker +//---------------------------------------------------------------------------- + +const size_t PassiveLogCollector::SpdySessionTracker::kMaxGraveyardSize = 10; + +PassiveLogCollector::SpdySessionTracker::SpdySessionTracker() + : RequestTrackerBase(kMaxGraveyardSize) { +} + +PassiveLogCollector::RequestTrackerBase::Action +PassiveLogCollector::SpdySessionTracker::DoAddEntry(const Entry& entry, + RequestInfo* out_info) { + if (entry.type == net::NetLog::TYPE_SPDY_SESSION && + entry.phase == net::NetLog::PHASE_END) { + return ACTION_MOVE_TO_GRAVEYARD; + } else { + AddEntryToRequestInfo(entry, out_info); + return ACTION_NONE; + } +} diff --git a/chrome/browser/net/passive_log_collector.h b/chrome/browser/net/passive_log_collector.h index e67b27b..207b45b 100644 --- a/chrome/browser/net/passive_log_collector.h +++ b/chrome/browser/net/passive_log_collector.h @@ -96,10 +96,6 @@ class PassiveLogCollector : public ChromeNetLog::Observer { ACTION_MOVE_TO_GRAVEYARD, }; - // Updates |out_info| with the information from |entry|. Returns an action - // to perform for this map entry on completion. - virtual Action DoAddEntry(const Entry& entry, RequestInfo* out_info) = 0; - // Finds a request, either in the live entries or the graveyard and returns // it. RequestInfo* GetRequestInfo(uint32 id); @@ -112,6 +108,10 @@ class PassiveLogCollector : public ChromeNetLog::Observer { private: typedef base::hash_map<uint32, RequestInfo> SourceIDToInfoMap; + // Updates |out_info| with the information from |entry|. Returns an action + // to perform for this map entry on completion. + virtual Action DoAddEntry(const Entry& entry, RequestInfo* out_info) = 0; + void RemoveFromLiveRequests(uint32 source_id); void InsertIntoGraveyard(const RequestInfo& info); @@ -197,6 +197,20 @@ class PassiveLogCollector : public ChromeNetLog::Observer { DISALLOW_COPY_AND_ASSIGN(InitProxyResolverTracker); }; + // Tracks the log entries for the last seen SOURCE_SPDY_SESSION. + class SpdySessionTracker : public RequestTrackerBase { + public: + static const size_t kMaxGraveyardSize; + + SpdySessionTracker(); + + protected: + virtual Action DoAddEntry(const Entry& entry, RequestInfo* out_info); + + private: + DISALLOW_COPY_AND_ASSIGN(SpdySessionTracker); + }; + PassiveLogCollector(); ~PassiveLogCollector(); @@ -222,6 +236,10 @@ class PassiveLogCollector : public ChromeNetLog::Observer { return &init_proxy_resolver_tracker_; } + SpdySessionTracker* spdy_session_tracker() { + return &spdy_session_tracker_; + } + // Fills |out| with the full list of events that have been passively // captured. The list is ordered by capture time. void GetAllCapturedEvents(EntryList* out) const; @@ -235,6 +253,7 @@ class PassiveLogCollector : public ChromeNetLog::Observer { RequestTracker url_request_tracker_; RequestTracker socket_stream_tracker_; InitProxyResolverTracker init_proxy_resolver_tracker_; + SpdySessionTracker spdy_session_tracker_; // The count of how many events have flowed through this log. Used to set the // "order" field on captured events. diff --git a/chrome/browser/net/passive_log_collector_unittest.cc b/chrome/browser/net/passive_log_collector_unittest.cc index e7e2f2e..0e86210 100644 --- a/chrome/browser/net/passive_log_collector_unittest.cc +++ b/chrome/browser/net/passive_log_collector_unittest.cc @@ -14,7 +14,7 @@ namespace { typedef PassiveLogCollector::RequestTracker RequestTracker; typedef PassiveLogCollector::RequestInfoList RequestInfoList; -typedef net::NetLog NetLog; +using net::NetLog; const NetLog::SourceType kSourceType = NetLog::SOURCE_NONE; @@ -959,3 +959,33 @@ TEST(PassiveLogCollectorTest, AccumulateRxTxData) { EXPECT_EQ(6u, requests[0].entries.size()); EXPECT_EQ(6u, requests[1].entries.size()); } + +TEST(SpdySessionTracker, MovesToGraveyard) { + PassiveLogCollector::SpdySessionTracker tracker; + EXPECT_EQ(0u, tracker.GetLiveRequests().size()); + EXPECT_EQ(0u, tracker.GetRecentlyDeceased().size()); + + PassiveLogCollector::Entry begin( + 0u, + NetLog::TYPE_SPDY_SESSION, + base::TimeTicks(), + NetLog::Source(NetLog::SOURCE_SPDY_SESSION, 1), + NetLog::PHASE_BEGIN, + NULL); + + tracker.OnAddEntry(begin); + EXPECT_EQ(1u, tracker.GetLiveRequests().size()); + EXPECT_EQ(0u, tracker.GetRecentlyDeceased().size()); + + PassiveLogCollector::Entry end( + 0u, + NetLog::TYPE_SPDY_SESSION, + base::TimeTicks(), + NetLog::Source(NetLog::SOURCE_SPDY_SESSION, 1), + NetLog::PHASE_END, + NULL); + + tracker.OnAddEntry(end); + EXPECT_EQ(0u, tracker.GetLiveRequests().size()); + EXPECT_EQ(1u, tracker.GetRecentlyDeceased().size()); +} |