Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(562)

Unified Diff: net/spdy/spdy_session.h

Issue 10448083: Fix out of order SYN_STEAM frames. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make SpdyFrameProducer a nested class in SpdySession. Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/spdy/spdy_network_transaction_spdy3_unittest.cc ('k') | net/spdy/spdy_session.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/spdy_session.h
diff --git a/net/spdy/spdy_session.h b/net/spdy/spdy_session.h
index 2b55528d6fd3cd37850b8197fea9a9330c3c50ab..ee91faa5f2fac53f0df36c7d608085f4a6649a9a 100644
--- a/net/spdy/spdy_session.h
+++ b/net/spdy/spdy_session.h
@@ -96,6 +96,29 @@ COMPILE_ASSERT(PROTOCOL_ERROR_UNEXPECTED_PING ==
class NET_EXPORT SpdySession : public base::RefCounted<SpdySession>,
public BufferedSpdyFramerVisitorInterface {
public:
+// Defines an interface for producing SPDY frames.
+class NET_EXPORT_PRIVATE SpdyFrameProducer {
willchan no longer on Chromium 2012/06/21 23:51:03 Indentation
Ryan Hamilton 2012/06/22 16:17:32 Done.
+ public:
+ SpdyFrameProducer() {}
+
+ // Returns a newly created SpdyFrame, owned by the called.
+ virtual SpdyFrame* ProduceNextFrame(SpdySession* session) = 0;
+
+ // Returns the priority of frames produced by this producer.
+ virtual RequestPriority GetPriority() const = 0;
+
+ // Returns a pointer to the underlying SpdyStream, or NULL if none exits.
+ virtual SpdyStream* GetSpdyStream() = 0;
willchan no longer on Chromium 2012/06/21 23:51:03 Do you still need this one?
Ryan Hamilton 2012/06/22 16:17:32 It is still used because when we decide that we ne
willchan no longer on Chromium 2012/06/22 21:10:44 I see. I think I'd rather keep it out of this inte
+
+ virtual ~SpdyFrameProducer() {}
+
+ // Activates |spdy_stream| in |spdy_session|.
+ void ActivateStream(SpdySession* spdy_session, SpdyStream* spdy_stream);
willchan no longer on Chromium 2012/06/21 23:51:03 Can this be static?
Ryan Hamilton 2012/06/22 16:17:32 Done.
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(SpdyFrameProducer);
+};
+
// Create a new SpdySession.
// |host_port_proxy_pair| is the host/port that this session connects to, and
// the proxy configuration settings that it's using.
@@ -158,9 +181,12 @@ class NET_EXPORT SpdySession : public base::RefCounted<SpdySession>,
// authentication now.
bool VerifyDomainAuthentication(const std::string& domain);
+ // Records that |stream| has a write available.
+ void SetStreamHasWriteAvailable(SpdyStream* stream);
+
// Send the SYN frame for |stream_id|. This also sends PING message to check
// the status of the connection.
- int WriteSynStream(
+ SpdySynStreamControlFrame* CreateSynStream(
SpdyStreamId stream_id,
RequestPriority priority,
uint8 credential_slot,
@@ -168,21 +194,24 @@ class NET_EXPORT SpdySession : public base::RefCounted<SpdySession>,
const linked_ptr<SpdyHeaderBlock>& headers);
// Write a CREDENTIAL frame to the session.
- int WriteCredentialFrame(const std::string& origin,
- SSLClientCertType type,
- const std::string& key,
- const std::string& cert,
- RequestPriority priority);
+ SpdyCredentialControlFrame* CreateCredentialFrame(const std::string& origin,
+ SSLClientCertType type,
+ const std::string& key,
+ const std::string& cert,
+ RequestPriority priority);
// Write a data frame to the stream.
// Used to create and queue a data frame for the given stream.
- int WriteStreamData(SpdyStreamId stream_id, net::IOBuffer* data,
- int len,
- SpdyDataFlags flags);
+ SpdyDataFrame* CreateDataFrame(SpdyStreamId stream_id,
+ net::IOBuffer* data, int len,
+ SpdyDataFlags flags);
// Close a stream.
void CloseStream(SpdyStreamId stream_id, int status);
+ // Close a stream that has been created but is not yet active.
+ void CloseCreatedStream(SpdyStream* stream, int status);
+
// Reset a stream by sending a RST_STREAM frame with given status code.
// Also closes the stream. Was not piggybacked to CloseStream since not
// all of the calls to CloseStream necessitate sending a RST_STREAM.
@@ -270,7 +299,7 @@ class NET_EXPORT SpdySession : public base::RefCounted<SpdySession>,
// Returns true if session is not currently active
bool is_active() const {
- return !active_streams_.empty();
+ return !active_streams_.empty() || !created_streams_.empty();
}
// Access to the number of active and pending streams. These are primarily
@@ -279,6 +308,7 @@ class NET_EXPORT SpdySession : public base::RefCounted<SpdySession>,
size_t num_unclaimed_pushed_streams() const {
return unclaimed_pushed_streams_.size();
}
+ size_t num_created_streams() const { return created_streams_.size(); }
// Returns true if flow control is enabled for the session.
bool is_flow_control_enabled() const {
@@ -354,7 +384,17 @@ class NET_EXPORT SpdySession : public base::RefCounted<SpdySession>,
typedef std::map<int, scoped_refptr<SpdyStream> > ActiveStreamMap;
// Only HTTP push a stream.
typedef std::map<std::string, scoped_refptr<SpdyStream> > PushedStreamMap;
- typedef std::priority_queue<SpdyIOBuffer> OutputQueue;
+ typedef std::set<scoped_refptr<SpdyStream> > CreatedStreamSet;
+ class SpdyFrameProducerCompare {
+ public:
+ bool operator() (const SpdyFrameProducer* lhs,
+ const SpdyFrameProducer* rhs) const {
+ return lhs->GetPriority() < rhs->GetPriority();
+ }
+ };
+ typedef std::priority_queue<SpdyFrameProducer*,
+ std::vector<SpdyFrameProducer*>,
+ SpdyFrameProducerCompare> WriteQueue;
struct CallbackResultPair {
CallbackResultPair(const CompletionCallback& callback_in, int result_in)
@@ -429,9 +469,7 @@ class NET_EXPORT SpdySession : public base::RefCounted<SpdySession>,
// Queue a frame for sending.
// |frame| is the frame to send.
// |priority| is the priority for insertion into the queue.
- // |stream| is the stream which this IO is associated with (or NULL).
- void QueueFrame(SpdyFrame* frame, RequestPriority priority,
- SpdyStream* stream);
+ void QueueFrame(SpdyFrame* frame, RequestPriority priority);
// Track active streams in the active stream list.
void ActivateStream(SpdyStream* stream);
@@ -558,8 +596,11 @@ class NET_EXPORT SpdySession : public base::RefCounted<SpdySession>,
// server, but do not have consumers yet.
PushedStreamMap unclaimed_pushed_streams_;
- // As we gather data to be sent, we put it into the output queue.
- OutputQueue queue_;
+ // Set of all created streams but that have not yet sent any frames.
+ CreatedStreamSet created_streams_;
+
+ // As streams have data to be sent, we put them into the write queue.
+ WriteQueue write_queue_;
// The packet we are currently sending.
bool write_pending_; // Will be true when a write is in progress.
« no previous file with comments | « net/spdy/spdy_network_transaction_spdy3_unittest.cc ('k') | net/spdy/spdy_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698