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

Side by Side 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: Cleanup 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 unified diff | Download patch | Annotate | Revision Log
« 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef NET_SPDY_SPDY_SESSION_H_ 5 #ifndef NET_SPDY_SPDY_SESSION_H_
6 #define NET_SPDY_SPDY_SESSION_H_ 6 #define NET_SPDY_SPDY_SESSION_H_
7 #pragma once 7 #pragma once
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <list> 10 #include <list>
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 // If the session is un-authenticated, then this call always returns true. 151 // If the session is un-authenticated, then this call always returns true.
152 // For SSL-based sessions, verifies that the server certificate in use by 152 // For SSL-based sessions, verifies that the server certificate in use by
153 // this session provides authentication for the domain and no client 153 // this session provides authentication for the domain and no client
154 // certificate was sent to the original server during the SSL handshake. 154 // certificate was sent to the original server during the SSL handshake.
155 // NOTE: This function can have false negatives on some platforms. 155 // NOTE: This function can have false negatives on some platforms.
156 // TODO(wtc): rename this function and the Net.SpdyIPPoolDomainMatch 156 // TODO(wtc): rename this function and the Net.SpdyIPPoolDomainMatch
157 // histogram because this function does more than verifying domain 157 // histogram because this function does more than verifying domain
158 // authentication now. 158 // authentication now.
159 bool VerifyDomainAuthentication(const std::string& domain); 159 bool VerifyDomainAuthentication(const std::string& domain);
160 160
161 // Records that |stream| has a write available.
162 void SetStreamHasWriteAvailable(SpdyStream* stream);
163
161 // Send the SYN frame for |stream_id|. This also sends PING message to check 164 // Send the SYN frame for |stream_id|. This also sends PING message to check
162 // the status of the connection. 165 // the status of the connection.
163 int WriteSynStream( 166 SpdySynStreamControlFrame* CreateSynStream(
164 SpdyStreamId stream_id, 167 SpdyStreamId stream_id,
165 RequestPriority priority, 168 RequestPriority priority,
166 uint8 credential_slot, 169 uint8 credential_slot,
167 SpdyControlFlags flags, 170 SpdyControlFlags flags,
168 const linked_ptr<SpdyHeaderBlock>& headers); 171 const linked_ptr<SpdyHeaderBlock>& headers);
169 172
170 // Write a CREDENTIAL frame to the session. 173 // Write a CREDENTIAL frame to the session.
171 int WriteCredentialFrame(const std::string& origin, 174 SpdyCredentialControlFrame* CreateCredentialFrame(const std::string& origin,
172 SSLClientCertType type, 175 SSLClientCertType type,
173 const std::string& key, 176 const std::string& key,
174 const std::string& cert, 177 const std::string& cert,
175 RequestPriority priority); 178 RequestPriority priority);
176 179
177 // Write a data frame to the stream. 180 // Write a data frame to the stream.
178 // Used to create and queue a data frame for the given stream. 181 // Used to create and queue a data frame for the given stream.
179 int WriteStreamData(SpdyStreamId stream_id, net::IOBuffer* data, 182 SpdyDataFrame* CreateDataFrame(SpdyStreamId stream_id,
180 int len, 183 net::IOBuffer* data, int len,
181 SpdyDataFlags flags); 184 SpdyDataFlags flags);
182 185
183 // Close a stream. 186 // Close a stream.
184 void CloseStream(SpdyStreamId stream_id, int status); 187 void CloseStream(SpdyStreamId stream_id, int status);
185 188
189 // Close a stream that has been created but is not yet active.
190 void CloseCreatedStream(SpdyStream* stream, int status);
191
186 // Reset a stream by sending a RST_STREAM frame with given status code. 192 // Reset a stream by sending a RST_STREAM frame with given status code.
187 // Also closes the stream. Was not piggybacked to CloseStream since not 193 // Also closes the stream. Was not piggybacked to CloseStream since not
188 // all of the calls to CloseStream necessitate sending a RST_STREAM. 194 // all of the calls to CloseStream necessitate sending a RST_STREAM.
189 void ResetStream(SpdyStreamId stream_id, 195 void ResetStream(SpdyStreamId stream_id,
190 SpdyStatusCodes status, 196 SpdyStatusCodes status,
191 const std::string& description); 197 const std::string& description);
192 198
193 // Check if a stream is active. 199 // Check if a stream is active.
194 bool IsStreamActive(SpdyStreamId stream_id) const; 200 bool IsStreamActive(SpdyStreamId stream_id) const;
195 201
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 bool WasEverUsed() const { 269 bool WasEverUsed() const {
264 return connection_->socket()->WasEverUsed(); 270 return connection_->socket()->WasEverUsed();
265 } 271 }
266 272
267 void set_spdy_session_pool(SpdySessionPool* pool) { 273 void set_spdy_session_pool(SpdySessionPool* pool) {
268 spdy_session_pool_ = NULL; 274 spdy_session_pool_ = NULL;
269 } 275 }
270 276
271 // Returns true if session is not currently active 277 // Returns true if session is not currently active
272 bool is_active() const { 278 bool is_active() const {
273 return !active_streams_.empty(); 279 return !active_streams_.empty() || !created_streams_.empty();
274 } 280 }
275 281
276 // Access to the number of active and pending streams. These are primarily 282 // Access to the number of active and pending streams. These are primarily
277 // available for testing and diagnostics. 283 // available for testing and diagnostics.
278 size_t num_active_streams() const { return active_streams_.size(); } 284 size_t num_active_streams() const { return active_streams_.size(); }
279 size_t num_unclaimed_pushed_streams() const { 285 size_t num_unclaimed_pushed_streams() const {
280 return unclaimed_pushed_streams_.size(); 286 return unclaimed_pushed_streams_.size();
281 } 287 }
288 size_t num_created_streams() const { return created_streams_.size(); }
282 289
283 // Returns true if flow control is enabled for the session. 290 // Returns true if flow control is enabled for the session.
284 bool is_flow_control_enabled() const { 291 bool is_flow_control_enabled() const {
285 return flow_control_; 292 return flow_control_;
286 } 293 }
287 294
288 // Returns the current |initial_send_window_size_|. 295 // Returns the current |initial_send_window_size_|.
289 int32 initial_send_window_size() const { 296 int32 initial_send_window_size() const {
290 return initial_send_window_size_; 297 return initial_send_window_size_;
291 } 298 }
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 scoped_refptr<SpdyStream>* spdy_stream; 355 scoped_refptr<SpdyStream>* spdy_stream;
349 const BoundNetLog* stream_net_log; 356 const BoundNetLog* stream_net_log;
350 CompletionCallback callback; 357 CompletionCallback callback;
351 }; 358 };
352 typedef std::queue<PendingCreateStream, std::list< PendingCreateStream> > 359 typedef std::queue<PendingCreateStream, std::list< PendingCreateStream> >
353 PendingCreateStreamQueue; 360 PendingCreateStreamQueue;
354 typedef std::map<int, scoped_refptr<SpdyStream> > ActiveStreamMap; 361 typedef std::map<int, scoped_refptr<SpdyStream> > ActiveStreamMap;
355 // Only HTTP push a stream. 362 // Only HTTP push a stream.
356 typedef std::map<std::string, scoped_refptr<SpdyStream> > PushedStreamMap; 363 typedef std::map<std::string, scoped_refptr<SpdyStream> > PushedStreamMap;
357 typedef std::priority_queue<SpdyIOBuffer> OutputQueue; 364 typedef std::priority_queue<SpdyIOBuffer> OutputQueue;
365 typedef std::set<scoped_refptr<SpdyStream> > CreatedStreamSet;
366 class SpdyFrameProducerCompare {
367 public:
368 bool operator() (const SpdyFrameProducer* lhs,
369 const SpdyFrameProducer* rhs) const {
370 return lhs->GetPriority() < rhs->GetPriority();
371 }
372 };
373 typedef std::priority_queue<SpdyFrameProducer*,
374 std::vector<SpdyFrameProducer*>,
375 SpdyFrameProducerCompare> WriteQueue;
358 376
359 struct CallbackResultPair { 377 struct CallbackResultPair {
360 CallbackResultPair(const CompletionCallback& callback_in, int result_in) 378 CallbackResultPair(const CompletionCallback& callback_in, int result_in)
361 : callback(callback_in), result(result_in) {} 379 : callback(callback_in), result(result_in) {}
362 ~CallbackResultPair(); 380 ~CallbackResultPair();
363 381
364 CompletionCallback callback; 382 CompletionCallback callback;
365 int result; 383 int result;
366 }; 384 };
367 385
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 // Write current data to the socket. 440 // Write current data to the socket.
423 void WriteSocketLater(); 441 void WriteSocketLater();
424 void WriteSocket(); 442 void WriteSocket();
425 443
426 // Get a new stream id. 444 // Get a new stream id.
427 int GetNewStreamId(); 445 int GetNewStreamId();
428 446
429 // Queue a frame for sending. 447 // Queue a frame for sending.
430 // |frame| is the frame to send. 448 // |frame| is the frame to send.
431 // |priority| is the priority for insertion into the queue. 449 // |priority| is the priority for insertion into the queue.
432 // |stream| is the stream which this IO is associated with (or NULL). 450 void QueueFrame(SpdyFrame* frame, RequestPriority priority);
433 void QueueFrame(SpdyFrame* frame, RequestPriority priority,
434 SpdyStream* stream);
435 451
436 // Track active streams in the active stream list. 452 // Track active streams in the active stream list.
437 void ActivateStream(SpdyStream* stream); 453 void ActivateStream(SpdyStream* stream);
438 void DeleteStream(SpdyStreamId id, int status); 454 void DeleteStream(SpdyStreamId id, int status);
439 455
440 // Removes this session from the session pool. 456 // Removes this session from the session pool.
441 void RemoveFromPool(); 457 void RemoveFromPool();
442 458
443 // Check if we have a pending pushed-stream for this url 459 // Check if we have a pending pushed-stream for this url
444 // Returns the stream if found (and returns it from the pending 460 // Returns the stream if found (and returns it from the pending
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
551 // the server to start pushing the stream]) or there are still network events 567 // the server to start pushing the stream]) or there are still network events
552 // incoming even though the consumer has already gone away (cancellation). 568 // incoming even though the consumer has already gone away (cancellation).
553 // TODO(willchan): Perhaps we should separate out cancelled streams and move 569 // TODO(willchan): Perhaps we should separate out cancelled streams and move
554 // them into a separate ActiveStreamMap, and not deliver network events to 570 // them into a separate ActiveStreamMap, and not deliver network events to
555 // them? 571 // them?
556 ActiveStreamMap active_streams_; 572 ActiveStreamMap active_streams_;
557 // Map of all the streams that have already started to be pushed by the 573 // Map of all the streams that have already started to be pushed by the
558 // server, but do not have consumers yet. 574 // server, but do not have consumers yet.
559 PushedStreamMap unclaimed_pushed_streams_; 575 PushedStreamMap unclaimed_pushed_streams_;
560 576
577 // Set of all created streams that have not yet been activated.
willchan no longer on Chromium 2012/06/07 23:02:06 This comment makes no sense without context of wha
Ryan Hamilton 2012/06/08 00:02:26 Done.
578 CreatedStreamSet created_streams_;
579
561 // As we gather data to be sent, we put it into the output queue. 580 // As we gather data to be sent, we put it into the output queue.
562 OutputQueue queue_; 581 OutputQueue queue_;
willchan no longer on Chromium 2012/06/07 23:02:06 Can this die?
Ryan Hamilton 2012/06/08 00:02:26 Indeed! Done.
563 582
583 // As streams have data to be sent, we put them into the write queue.
584 WriteQueue write_queue_;
585
564 // The packet we are currently sending. 586 // The packet we are currently sending.
565 bool write_pending_; // Will be true when a write is in progress. 587 bool write_pending_; // Will be true when a write is in progress.
566 SpdyIOBuffer in_flight_write_; // This is the write buffer in progress. 588 SpdyIOBuffer in_flight_write_; // This is the write buffer in progress.
567 589
568 // Flag if we have a pending message scheduled for WriteSocket. 590 // Flag if we have a pending message scheduled for WriteSocket.
569 bool delayed_write_pending_; 591 bool delayed_write_pending_;
570 592
571 // Flag if we're using an SSL connection for this SpdySession. 593 // Flag if we're using an SSL connection for this SpdySession.
572 bool is_secure_; 594 bool is_secure_;
573 595
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
716 private: 738 private:
717 const int status_; 739 const int status_;
718 const std::string description_; 740 const std::string description_;
719 741
720 DISALLOW_COPY_AND_ASSIGN(NetLogSpdySessionCloseParameter); 742 DISALLOW_COPY_AND_ASSIGN(NetLogSpdySessionCloseParameter);
721 }; 743 };
722 744
723 } // namespace net 745 } // namespace net
724 746
725 #endif // NET_SPDY_SPDY_SESSION_H_ 747 #endif // NET_SPDY_SPDY_SESSION_H_
OLDNEW
« 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