summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/dom_ui/net_internals_ui.cc1
-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
-rw-r--r--net/base/net_log.h1
-rw-r--r--net/base/net_log_event_type_list.h45
-rw-r--r--net/spdy/spdy_session.cc61
-rw-r--r--net/spdy/spdy_session.h2
-rw-r--r--net/spdy/spdy_session_pool.cc4
9 files changed, 181 insertions, 14 deletions
diff --git a/chrome/browser/dom_ui/net_internals_ui.cc b/chrome/browser/dom_ui/net_internals_ui.cc
index c643af2..9b55d0e 100644
--- a/chrome/browser/dom_ui/net_internals_ui.cc
+++ b/chrome/browser/dom_ui/net_internals_ui.cc
@@ -523,6 +523,7 @@ void NetInternalsMessageHandler::IOThreadImpl::OnRendererReady(
net::NetLog::SOURCE_INIT_PROXY_RESOLVER);
dict->SetInteger(L"CONNECT_JOB", net::NetLog::SOURCE_CONNECT_JOB);
dict->SetInteger(L"SOCKET", net::NetLog::SOURCE_SOCKET);
+ dict->SetInteger(L"SPDY_SESSION", net::NetLog::SOURCE_SPDY_SESSION);
CallJavascriptFunction(L"g_browser.receivedLogSourceTypeConstants", dict);
}
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());
+}
diff --git a/net/base/net_log.h b/net/base/net_log.h
index 9270d78..02f0a4b 100644
--- a/net/base/net_log.h
+++ b/net/base/net_log.h
@@ -59,6 +59,7 @@ class NetLog {
SOURCE_INIT_PROXY_RESOLVER,
SOURCE_CONNECT_JOB,
SOURCE_SOCKET,
+ SOURCE_SPDY_SESSION,
};
// Identifies the entity that generated this log. The |id| field should
diff --git a/net/base/net_log_event_type_list.h b/net/base/net_log_event_type_list.h
index d849611..5ec710c 100644
--- a/net/base/net_log_event_type_list.h
+++ b/net/base/net_log_event_type_list.h
@@ -366,6 +366,44 @@ EVENT_TYPE(SPDY_TRANSACTION_READ_HEADERS)
EVENT_TYPE(SPDY_TRANSACTION_READ_BODY)
// ------------------------------------------------------------------------
+// SpdySession
+// ------------------------------------------------------------------------
+
+// The start/end of a SpdySession.
+EVENT_TYPE(SPDY_SESSION)
+
+// On sending a SPDY SETTINGS frame.
+// The following parameters are attached:
+// {
+// "settings": <The list of setting id:value pairs>
+// }
+EVENT_TYPE(SPDY_SESSION_SEND_SETTINGS)
+
+// Receipt of a SPDY SETTINGS frame.
+// The following parameters are attached:
+// {
+// "settings": <The list of setting id:value pairs>
+// }
+EVENT_TYPE(SPDY_SESSION_RECV_SETTINGS)
+
+// Receipt of a SPDY GOAWAY frame.
+// The following parameters are attached:
+// {
+// "last_accepted_stream_id": <Last stream id accepted by the server, duh>
+// }
+EVENT_TYPE(SPDY_SESSION_GOAWAY)
+
+// This event is sent for a SPDY SYN_STREAM pushed by the server, but no
+// URLRequest has requested it yet.
+// The following parameters are attached:
+// {
+// "flags": <The control frame flags>
+// "headers": <The list of header:value pairs>
+// "id": <The stream id>
+// }
+EVENT_TYPE(SPDY_SESSION_PUSHED_SYN_STREAM)
+
+// ------------------------------------------------------------------------
// SpdyStream
// ------------------------------------------------------------------------
@@ -412,6 +450,13 @@ EVENT_TYPE(SPDY_STREAM_READ_BODY)
// Logs that a stream attached to a pushed stream.
EVENT_TYPE(SPDY_STREAM_ADOPTED_PUSH_STREAM)
+// The receipt of a RST_STREAM
+// The following parameters are attached:
+// {
+// "status": <The reason for the RST_STREAM>
+// }
+EVENT_TYPE(SPDY_STREAM_RST_STREAM)
+
// ------------------------------------------------------------------------
// HttpStreamParser
// ------------------------------------------------------------------------
diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc
index 55c0b65..85c825b 100644
--- a/net/spdy/spdy_session.cc
+++ b/net/spdy/spdy_session.cc
@@ -213,6 +213,31 @@ class NetLogSpdySynParameter : public NetLog::EventParameters {
DISALLOW_COPY_AND_ASSIGN(NetLogSpdySynParameter);
};
+class NetLogSpdySettingsParameter : public NetLog::EventParameters {
+ public:
+ explicit NetLogSpdySettingsParameter(const spdy::SpdySettings& settings)
+ : settings_(settings) {}
+
+ Value* ToValue() const {
+ DictionaryValue* dict = new DictionaryValue();
+ ListValue* settings = new ListValue();
+ for (spdy::SpdySettings::const_iterator it = settings_.begin();
+ it != settings_.end(); ++it) {
+ settings->Append(new StringValue(
+ StringPrintf("[%u:%u]", it->first.id(), it->second)));
+ }
+ dict->Set(L"settings", settings);
+ return dict;
+ }
+
+ private:
+ ~NetLogSpdySettingsParameter() {}
+
+ const spdy::SpdySettings settings_;
+
+ DISALLOW_COPY_AND_ASSIGN(NetLogSpdySettingsParameter);
+};
+
} // namespace
// static
@@ -220,7 +245,7 @@ bool SpdySession::use_ssl_ = true;
SpdySession::SpdySession(const HostPortPair& host_port_pair,
HttpNetworkSession* session,
- const BoundNetLog& net_log)
+ NetLog* net_log)
: ALLOW_THIS_IN_INITIALIZER_LIST(
connect_callback_(this, &SpdySession::OnTCPConnect)),
ALLOW_THIS_IN_INITIALIZER_LIST(
@@ -245,7 +270,11 @@ SpdySession::SpdySession(const HostPortPair& host_port_pair,
streams_pushed_and_claimed_count_(0),
streams_abandoned_count_(0),
in_session_pool_(true),
- net_log_(net_log) {
+ net_log_(BoundNetLog::Make(net_log, NetLog::SOURCE_SPDY_SESSION)) {
+ net_log_.BeginEvent(
+ NetLog::TYPE_SPDY_SESSION,
+ new NetLogStringParameter("host_port", host_port_pair_.ToString()));
+
// TODO(mbelshe): consider randomization of the stream_hi_water_mark.
spdy_framer_.set_visitor(this);
@@ -277,6 +306,8 @@ SpdySession::~SpdySession() {
UMA_HISTOGRAM_CUSTOM_COUNTS("Net.SpdyStreamsAbandonedPerSession",
streams_abandoned_count_,
0, 300, 50);
+
+ net_log_.EndEvent(NetLog::TYPE_SPDY_SESSION, NULL);
}
void SpdySession::InitializeWithSSLSocket(ClientSocketHandle* connection) {
@@ -520,7 +551,6 @@ void SpdySession::OnTCPConnect(int result) {
socket, "" /* request_->url.HostNoBrackets() */ , ssl_config_);
connection_->set_socket(socket);
is_secure_ = true;
- // TODO(willchan): Plumb NetLog into SPDY code.
int status = connection_->socket()->Connect(&ssl_connect_callback_);
if (status != ERR_IO_PENDING)
OnSSLConnect(status);
@@ -1023,11 +1053,9 @@ void SpdySession::OnSyn(const spdy::SpdySynStreamControlFrame& frame,
} else {
stream = new SpdyStream(this, stream_id, true);
- // TODO(willchan): Rename this event to SPDY_SESSION_PUSHED_SYN_STREAM once
- // my other CL gets finished.
if (net_log_.HasListener()) {
net_log_.AddEvent(
- NetLog::TYPE_SPDY_STREAM_PUSHED_SYN_STREAM,
+ NetLog::TYPE_SPDY_SESSION_PUSHED_SYN_STREAM,
new NetLogSpdySynParameter(
headers, static_cast<spdy::SpdyControlFlags>(frame.flags()),
stream_id));
@@ -1167,6 +1195,12 @@ void SpdySession::OnFin(const spdy::SpdyRstStreamControlFrame& frame) {
scoped_refptr<SpdyStream> stream = active_streams_[stream_id];
CHECK_EQ(stream->stream_id(), stream_id);
CHECK(!stream->cancelled());
+
+ const BoundNetLog& log = stream->net_log();
+ log.AddEvent(
+ NetLog::TYPE_SPDY_STREAM_RST_STREAM,
+ new NetLogIntegerParameter("status", frame.status()));
+
if (frame.status() == 0) {
stream->OnDataReceived(NULL, 0);
} else {
@@ -1182,6 +1216,13 @@ void SpdySession::OnFin(const spdy::SpdyRstStreamControlFrame& frame) {
void SpdySession::OnGoAway(const spdy::SpdyGoAwayControlFrame& frame) {
LOG(INFO) << "Spdy GOAWAY for session[" << this << "] for " <<
host_port_pair().ToString();
+
+ net_log_.AddEvent(
+ NetLog::TYPE_SPDY_SESSION_GOAWAY,
+ new NetLogIntegerParameter(
+ "last_accepted_stream_id",
+ frame.last_accepted_stream_id()));
+
RemoveFromPool();
// TODO(willchan): Cancel any streams that are past the GoAway frame's
@@ -1198,6 +1239,10 @@ void SpdySession::OnSettings(const spdy::SpdySettingsControlFrame& frame) {
SpdySettingsStorage* settings_storage = session_->mutable_spdy_settings();
settings_storage->Set(host_port_pair_, settings);
}
+
+ net_log_.AddEvent(
+ NetLog::TYPE_SPDY_SESSION_RECV_SETTINGS,
+ new NetLogSpdySettingsParameter(settings));
}
void SpdySession::SendSettings() {
@@ -1206,6 +1251,10 @@ void SpdySession::SendSettings() {
if (settings.empty())
return;
+ net_log_.AddEvent(
+ NetLog::TYPE_SPDY_SESSION_SEND_SETTINGS,
+ new NetLogSpdySettingsParameter(settings));
+
// Create the SETTINGS frame and send it.
scoped_ptr<spdy::SpdySettingsControlFrame> settings_frame(
spdy_framer_.CreateSettings(settings));
diff --git a/net/spdy/spdy_session.h b/net/spdy/spdy_session.h
index 8ef2da0..8ef8759 100644
--- a/net/spdy/spdy_session.h
+++ b/net/spdy/spdy_session.h
@@ -46,7 +46,7 @@ class SpdySession : public base::RefCounted<SpdySession>,
// |session| is the HttpNetworkSession. |net_log| is the NetLog that we log
// network events to.
SpdySession(const HostPortPair& host_port_pair, HttpNetworkSession* session,
- const BoundNetLog& net_log);
+ NetLog* net_log);
const HostPortPair& host_port_pair() const { return host_port_pair_; }
diff --git a/net/spdy/spdy_session_pool.cc b/net/spdy/spdy_session_pool.cc
index af397c7..cd505a8 100644
--- a/net/spdy/spdy_session_pool.cc
+++ b/net/spdy/spdy_session_pool.cc
@@ -35,7 +35,7 @@ scoped_refptr<SpdySession> SpdySessionPool::Get(
DCHECK(list);
if (!spdy_session)
- spdy_session = new SpdySession(host_port_pair, session, net_log);
+ spdy_session = new SpdySession(host_port_pair, session, net_log.net_log());
DCHECK(spdy_session);
list->push_back(spdy_session);
@@ -53,7 +53,7 @@ scoped_refptr<SpdySession> SpdySessionPool::GetSpdySessionFromSSLSocket(
list = AddSessionList(host_port_pair);
DCHECK(list->empty());
scoped_refptr<SpdySession> spdy_session(
- new SpdySession(host_port_pair, session, net_log));
+ new SpdySession(host_port_pair, session, net_log.net_log()));
spdy_session->InitializeWithSSLSocket(connection);
list->push_back(spdy_session);
return spdy_session;