summaryrefslogtreecommitdiffstats
path: root/chrome/browser/net
diff options
context:
space:
mode:
authorwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-16 00:59:10 +0000
committerwillchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-16 00:59:10 +0000
commit4429700a526a501f1a8feb597fa23f9e861e9852 (patch)
tree734f434874b7f07e85f26b0e85f1f6422b8a6218 /chrome/browser/net
parentd926bf73867d6a7c1ef777b7a555a4992f8bd62c (diff)
downloadchromium_src-4429700a526a501f1a8feb597fa23f9e861e9852.zip
chromium_src-4429700a526a501f1a8feb597fa23f9e861e9852.tar.gz
chromium_src-4429700a526a501f1a8feb597fa23f9e861e9852.tar.bz2
Reland 47342.
Fixes the merge issue this time. Also fixes a TODO in another change that was blocked on this one. Support SpdySession as a new NetLog source type. Start logging some more SPDY control frames. Original code review: http://codereview.chromium.org/2102003/show BUG=43237 Review URL: http://codereview.chromium.org/2114003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47376 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net')
-rw-r--r--chrome/browser/net/passive_log_collector.cc22
-rw-r--r--chrome/browser/net/passive_log_collector.h27
-rw-r--r--chrome/browser/net/passive_log_collector_unittest.cc32
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());
+}