Index: net/spdy/spdy_session.cc |
=================================================================== |
--- net/spdy/spdy_session.cc (revision 104856) |
+++ net/spdy/spdy_session.cc (working copy) |
@@ -172,6 +172,28 @@ |
DISALLOW_COPY_AND_ASSIGN(NetLogSpdyRstParameter); |
}; |
+class NetLogSpdyPingParameter : public NetLog::EventParameters { |
+ public: |
+ NetLogSpdyPingParameter(spdy::SpdyStreamId stream_id, |
+ uint32 unique_id) |
+ : stream_id_(stream_id), |
+ unique_id_(unique_id) {} |
+ |
+ virtual Value* ToValue() const { |
+ DictionaryValue* dict = new DictionaryValue(); |
+ dict->SetInteger("stream_id", static_cast<int>(stream_id_)); |
+ dict->SetInteger("unique_id", unique_id_); |
+ return dict; |
+ } |
+ |
+ private: |
+ ~NetLogSpdyPingParameter() {} |
+ const spdy::SpdyStreamId stream_id_; |
+ const uint32 unique_id_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(NetLogSpdyPingParameter); |
+}; |
+ |
class NetLogSpdyGoAwayParameter : public NetLog::EventParameters { |
public: |
NetLogSpdyGoAwayParameter(spdy::SpdyStreamId last_stream_id, |
@@ -460,6 +482,33 @@ |
return OK; |
} |
+int SpdySession::WritePingFrame(spdy::SpdyStreamId stream_id) { |
+ // Find our stream |
+ if (!IsStreamActive(stream_id)) |
+ return ERR_INVALID_SPDY_STREAM; |
+ const scoped_refptr<SpdyStream>& stream = active_streams_[stream_id]; |
+ CHECK_EQ(stream->stream_id(), stream_id); |
+ |
+ static uint32 unique_id = 1; |
+ unique_id += 2; |
+ scoped_ptr<spdy::SpdyPingControlFrame> ping_frame( |
+ spdy_framer_.CreatePingFrame(unique_id)); |
+ QueueFrame(ping_frame.get(), SPDY_PRIORITY_HIGHEST, stream); |
+ |
+ base::StatsCounter spdy_requests("spdy.requests"); |
+ spdy_requests.Increment(); |
+ streams_initiated_count_++; |
+ sent_ping_ = true; |
+ received_ping_ = false; |
+ if (net_log().IsLoggingAllEvents()) { |
+ net_log().AddEvent( |
+ NetLog::TYPE_SPDY_SESSION_PING, |
+ make_scoped_refptr(new NetLogSpdyPingParameter(stream_id, unique_id))); |
willchan no longer on Chromium
2011/10/12 05:41:06
There's no need to log the stream_id, just the uni
ramant (doing other things)
2011/10/13 21:41:14
Done.
|
+ } |
+ |
+ return ERR_IO_PENDING; |
+} |
+ |
int SpdySession::WriteSynStream( |
spdy::SpdyStreamId stream_id, |
RequestPriority priority, |
@@ -1226,6 +1275,9 @@ |
case spdy::GOAWAY: |
OnGoAway(*reinterpret_cast<const spdy::SpdyGoAwayControlFrame*>(frame)); |
break; |
+ case spdy::PING: |
+ OnPing(*reinterpret_cast<const spdy::SpdyPingControlFrame*>(frame)); |
+ break; |
case spdy::SETTINGS: |
OnSettings( |
*reinterpret_cast<const spdy::SpdySettingsControlFrame*>(frame)); |
@@ -1312,6 +1364,16 @@ |
// closed. |
} |
+void SpdySession::OnPing(const spdy::SpdyPingControlFrame& frame) { |
+ sent_ping_ = false; |
+ received_ping_ = true; |
+ net_log_.AddEvent( |
+ NetLog::TYPE_SPDY_SESSION_PING, |
+ make_scoped_refptr(new NetLogIntegerParameter("unique_id", |
+ frame.unique_id()))); |
+ // TODO(rtenneti): we should verify unique_id. |
+} |
+ |
void SpdySession::OnSettings(const spdy::SpdySettingsControlFrame& frame) { |
spdy::SpdySettings settings; |
if (spdy_framer_.ParseSettings(&frame, &settings)) { |