OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/spdy/spdy_session.h" | 5 #include "net/spdy/spdy_session.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/linked_ptr.h" | 9 #include "base/memory/linked_ptr.h" |
10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 private: | 168 private: |
169 ~NetLogSpdyRstParameter() {} | 169 ~NetLogSpdyRstParameter() {} |
170 const spdy::SpdyStreamId stream_id_; | 170 const spdy::SpdyStreamId stream_id_; |
171 const int status_; | 171 const int status_; |
172 | 172 |
173 DISALLOW_COPY_AND_ASSIGN(NetLogSpdyRstParameter); | 173 DISALLOW_COPY_AND_ASSIGN(NetLogSpdyRstParameter); |
174 }; | 174 }; |
175 | 175 |
176 class NetLogSpdyPingParameter : public NetLog::EventParameters { | 176 class NetLogSpdyPingParameter : public NetLog::EventParameters { |
177 public: | 177 public: |
178 explicit NetLogSpdyPingParameter(uint32 unique_id) : unique_id_(unique_id) {} | 178 explicit NetLogSpdyPingParameter(uint32 unique_id, const std::string& type) |
| 179 : unique_id_(unique_id), |
| 180 type_(type) {} |
179 | 181 |
180 virtual Value* ToValue() const { | 182 virtual Value* ToValue() const { |
181 DictionaryValue* dict = new DictionaryValue(); | 183 DictionaryValue* dict = new DictionaryValue(); |
182 dict->SetInteger("unique_id", unique_id_); | 184 dict->SetInteger("unique_id", unique_id_); |
| 185 dict->SetString("type", type_); |
183 return dict; | 186 return dict; |
184 } | 187 } |
185 | 188 |
186 private: | 189 private: |
187 ~NetLogSpdyPingParameter() {} | 190 ~NetLogSpdyPingParameter() {} |
188 const uint32 unique_id_; | 191 const uint32 unique_id_; |
| 192 const std::string type_; |
189 | 193 |
190 DISALLOW_COPY_AND_ASSIGN(NetLogSpdyPingParameter); | 194 DISALLOW_COPY_AND_ASSIGN(NetLogSpdyPingParameter); |
191 }; | 195 }; |
192 | 196 |
193 class NetLogSpdyGoAwayParameter : public NetLog::EventParameters { | 197 class NetLogSpdyGoAwayParameter : public NetLog::EventParameters { |
194 public: | 198 public: |
195 NetLogSpdyGoAwayParameter(spdy::SpdyStreamId last_stream_id, | 199 NetLogSpdyGoAwayParameter(spdy::SpdyStreamId last_stream_id, |
196 int active_streams, | 200 int active_streams, |
197 int unclaimed_streams) | 201 int unclaimed_streams) |
198 : last_stream_id_(last_stream_id), | 202 : last_stream_id_(last_stream_id), |
(...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1375 // |last_accepted_stream_id|. | 1379 // |last_accepted_stream_id|. |
1376 | 1380 |
1377 // Don't bother killing any streams that are still reading. They'll either | 1381 // Don't bother killing any streams that are still reading. They'll either |
1378 // complete successfully or get an ERR_CONNECTION_CLOSED when the socket is | 1382 // complete successfully or get an ERR_CONNECTION_CLOSED when the socket is |
1379 // closed. | 1383 // closed. |
1380 } | 1384 } |
1381 | 1385 |
1382 void SpdySession::OnPing(const spdy::SpdyPingControlFrame& frame) { | 1386 void SpdySession::OnPing(const spdy::SpdyPingControlFrame& frame) { |
1383 net_log_.AddEvent( | 1387 net_log_.AddEvent( |
1384 NetLog::TYPE_SPDY_SESSION_PING, | 1388 NetLog::TYPE_SPDY_SESSION_PING, |
1385 make_scoped_refptr(new NetLogSpdyPingParameter(frame.unique_id()))); | 1389 make_scoped_refptr( |
| 1390 new NetLogSpdyPingParameter(frame.unique_id(), "received"))); |
1386 | 1391 |
1387 // Send response to a PING from server. | 1392 // Send response to a PING from server. |
1388 if (frame.unique_id() % 2 == 0) { | 1393 if (frame.unique_id() % 2 == 0) { |
1389 WritePingFrame(frame.unique_id()); | 1394 WritePingFrame(frame.unique_id()); |
1390 return; | 1395 return; |
1391 } | 1396 } |
1392 | 1397 |
1393 --pings_in_flight_; | 1398 --pings_in_flight_; |
1394 if (pings_in_flight_ < 0) { | 1399 if (pings_in_flight_ < 0) { |
1395 CloseSessionOnError(net::ERR_SPDY_PROTOCOL_ERROR, true); | 1400 CloseSessionOnError(net::ERR_SPDY_PROTOCOL_ERROR, true); |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1586 } | 1591 } |
1587 | 1592 |
1588 void SpdySession::WritePingFrame(uint32 unique_id) { | 1593 void SpdySession::WritePingFrame(uint32 unique_id) { |
1589 scoped_ptr<spdy::SpdyPingControlFrame> ping_frame( | 1594 scoped_ptr<spdy::SpdyPingControlFrame> ping_frame( |
1590 spdy_framer_.CreatePingFrame(next_ping_id_)); | 1595 spdy_framer_.CreatePingFrame(next_ping_id_)); |
1591 QueueFrame(ping_frame.get(), SPDY_PRIORITY_HIGHEST, NULL); | 1596 QueueFrame(ping_frame.get(), SPDY_PRIORITY_HIGHEST, NULL); |
1592 | 1597 |
1593 if (net_log().IsLoggingAllEvents()) { | 1598 if (net_log().IsLoggingAllEvents()) { |
1594 net_log().AddEvent( | 1599 net_log().AddEvent( |
1595 NetLog::TYPE_SPDY_SESSION_PING, | 1600 NetLog::TYPE_SPDY_SESSION_PING, |
1596 make_scoped_refptr(new NetLogSpdyPingParameter(next_ping_id_))); | 1601 make_scoped_refptr(new NetLogSpdyPingParameter(next_ping_id_, "sent"))); |
1597 } | 1602 } |
1598 if (unique_id % 2 != 0) { | 1603 if (unique_id % 2 != 0) { |
1599 next_ping_id_ += 2; | 1604 next_ping_id_ += 2; |
1600 ++pings_in_flight_; | 1605 ++pings_in_flight_; |
1601 need_to_send_ping_ = false; | 1606 need_to_send_ping_ = false; |
1602 PlanToCheckPingStatus(); | 1607 PlanToCheckPingStatus(); |
1603 last_ping_sent_time_ = base::TimeTicks::Now(); | 1608 last_ping_sent_time_ = base::TimeTicks::Now(); |
1604 } | 1609 } |
1605 } | 1610 } |
1606 | 1611 |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1733 if (it == pending_callback_map_.end()) | 1738 if (it == pending_callback_map_.end()) |
1734 return; | 1739 return; |
1735 | 1740 |
1736 OldCompletionCallback* callback = it->second.callback; | 1741 OldCompletionCallback* callback = it->second.callback; |
1737 int result = it->second.result; | 1742 int result = it->second.result; |
1738 pending_callback_map_.erase(it); | 1743 pending_callback_map_.erase(it); |
1739 callback->Run(result); | 1744 callback->Run(result); |
1740 } | 1745 } |
1741 | 1746 |
1742 } // namespace net | 1747 } // namespace net |
OLD | NEW |