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

Side by Side Diff: net/spdy/spdy_session.h

Issue 13834009: SPDY - Re-land greedy read support for SpdySession (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reverting the Revert of 181390 and disabled the tests in patch 1 Created 7 years, 8 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
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 7
8 #include <deque> 8 #include <deque>
9 #include <list> 9 #include <list>
10 #include <map> 10 #include <map>
(...skipping 28 matching lines...) Expand all
39 // reasonably with ethernet. Chop the world into 2-packet chunks. This is 39 // reasonably with ethernet. Chop the world into 2-packet chunks. This is
40 // somewhat arbitrary, but is reasonably small and ensures that we elicit 40 // somewhat arbitrary, but is reasonably small and ensures that we elicit
41 // ACKs quickly from TCP (because TCP tries to only ACK every other packet). 41 // ACKs quickly from TCP (because TCP tries to only ACK every other packet).
42 const int kMss = 1430; 42 const int kMss = 1430;
43 // The 8 is the size of the SPDY frame header. 43 // The 8 is the size of the SPDY frame header.
44 const int kMaxSpdyFrameChunkSize = (2 * kMss) - 8; 44 const int kMaxSpdyFrameChunkSize = (2 * kMss) - 8;
45 45
46 // Specifies the maxiumum concurrent streams server could send (via push). 46 // Specifies the maxiumum concurrent streams server could send (via push).
47 const int kMaxConcurrentPushedStreams = 1000; 47 const int kMaxConcurrentPushedStreams = 1000;
48 48
49 // Specifies the number of bytes read synchronously (without yielding) if the
50 // data is available.
51 const int kMaxReadBytes = 32 * 1024;
52
49 // The initial receive window size for both streams and sessions. 53 // The initial receive window size for both streams and sessions.
50 const int32 kDefaultInitialRecvWindowSize = 10 * 1024 * 1024; // 10MB 54 const int32 kDefaultInitialRecvWindowSize = 10 * 1024 * 1024; // 10MB
51 55
52 class BoundNetLog; 56 class BoundNetLog;
53 struct LoadTimingInfo; 57 struct LoadTimingInfo;
54 class SpdyStream; 58 class SpdyStream;
55 class SSLInfo; 59 class SSLInfo;
56 60
57 enum SpdyProtocolErrorDetails { 61 enum SpdyProtocolErrorDetails {
58 // SpdyFramer::SpdyErrors 62 // SpdyFramer::SpdyErrors
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 uint32 delta_window_size); 333 uint32 delta_window_size);
330 334
331 // Called by a stream to increase this session's receive window size 335 // Called by a stream to increase this session's receive window size
332 // by |delta_window_size|, which must be at least 1 and must not 336 // by |delta_window_size|, which must be at least 1 and must not
333 // cause this session's receive window size to overflow, possibly 337 // cause this session's receive window size to overflow, possibly
334 // also sending a WINDOW_UPDATE frame. Does nothing if session flow 338 // also sending a WINDOW_UPDATE frame. Does nothing if session flow
335 // control is turned off. 339 // control is turned off.
336 void IncreaseRecvWindowSize(int32 delta_window_size); 340 void IncreaseRecvWindowSize(int32 delta_window_size);
337 341
338 // If session is closed, no new streams/transactions should be created. 342 // If session is closed, no new streams/transactions should be created.
339 bool IsClosed() const { return state_ == CLOSED; } 343 bool IsClosed() const { return state_ == STATE_CLOSED; }
340 344
341 // Closes this session. This will close all active streams and mark 345 // Closes this session. This will close all active streams and mark
342 // the session as permanently closed. 346 // the session as permanently closed.
343 // |err| should not be OK; this function is intended to be called on 347 // |err| should not be OK; this function is intended to be called on
344 // error. 348 // error.
345 // |remove_from_pool| indicates whether to also remove the session from the 349 // |remove_from_pool| indicates whether to also remove the session from the
346 // session pool. 350 // session pool.
347 // |description| indicates the reason for the error. 351 // |description| indicates the reason for the error.
348 void CloseSessionOnError(net::Error err, 352 void CloseSessionOnError(net::Error err,
349 bool remove_from_pool, 353 bool remove_from_pool,
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 const SpdyIOBufferProducer* rhs) const { 483 const SpdyIOBufferProducer* rhs) const {
480 return lhs->GetPriority() < rhs->GetPriority(); 484 return lhs->GetPriority() < rhs->GetPriority();
481 } 485 }
482 }; 486 };
483 487
484 typedef std::priority_queue<SpdyIOBufferProducer*, 488 typedef std::priority_queue<SpdyIOBufferProducer*,
485 std::vector<SpdyIOBufferProducer*>, 489 std::vector<SpdyIOBufferProducer*>,
486 SpdyIOBufferProducerCompare> WriteQueue; 490 SpdyIOBufferProducerCompare> WriteQueue;
487 491
488 enum State { 492 enum State {
489 IDLE, 493 STATE_IDLE,
490 CONNECTING, 494 STATE_CONNECTING,
491 CONNECTED, 495 STATE_DO_READ,
492 CLOSED 496 STATE_DO_READ_COMPLETE,
497 STATE_CLOSED
493 }; 498 };
494 499
495 virtual ~SpdySession(); 500 virtual ~SpdySession();
496 501
497 // Called by SpdyStreamRequest to start a request to create a 502 // Called by SpdyStreamRequest to start a request to create a
498 // stream. If OK is returned, then |stream| will be filled in with a 503 // stream. If OK is returned, then |stream| will be filled in with a
499 // valid stream. If ERR_IO_PENDING is returned, then 504 // valid stream. If ERR_IO_PENDING is returned, then
500 // |request->OnRequestComplete()| will be called when the stream is 505 // |request->OnRequestComplete()| will be called when the stream is
501 // created (unless it is cancelled). Otherwise, no stream is created 506 // created (unless it is cancelled). Otherwise, no stream is created
502 // and the error is returned. 507 // and the error is returned.
503 int TryCreateStream(SpdyStreamRequest* request, 508 int TryCreateStream(SpdyStreamRequest* request,
504 scoped_refptr<SpdyStream>* stream); 509 scoped_refptr<SpdyStream>* stream);
505 510
506 // Actually create a stream into |stream|. Returns OK if successful; 511 // Actually create a stream into |stream|. Returns OK if successful;
507 // otherwise, returns an error and |stream| is not filled. 512 // otherwise, returns an error and |stream| is not filled.
508 int CreateStream(const SpdyStreamRequest& request, 513 int CreateStream(const SpdyStreamRequest& request,
509 scoped_refptr<SpdyStream>* stream); 514 scoped_refptr<SpdyStream>* stream);
510 515
511 // Called by SpdyStreamRequest to remove |request| from the stream 516 // Called by SpdyStreamRequest to remove |request| from the stream
512 // creation queue. 517 // creation queue.
513 void CancelStreamRequest(SpdyStreamRequest* request); 518 void CancelStreamRequest(SpdyStreamRequest* request);
514 519
515 // Called when there is room to create more streams (e.g., a stream 520 // Called when there is room to create more streams (e.g., a stream
516 // was closed). Processes as many pending stream requests as 521 // was closed). Processes as many pending stream requests as
517 // possible. 522 // possible.
518 void ProcessPendingStreamRequests(); 523 void ProcessPendingStreamRequests();
519 524
525 // Start the DoLoop to read data from socket.
526 void StartRead();
527
528 // Try to make progress by reading and processing data.
529 int DoLoop(int result);
530 // The implementations of STATE_DO_READ/STATE_DO_READ_COMPLETE state changes
531 // of the state machine.
532 int DoRead();
533 int DoReadComplete(int bytes_read);
534
535 // Check if session is connected or not.
536 bool IsConnected() const {
537 return state_ == STATE_DO_READ || state_ == STATE_DO_READ_COMPLETE;
538 }
539
520 // IO Callbacks 540 // IO Callbacks
521 void OnReadComplete(int result); 541 void OnReadComplete(int result);
522 void OnWriteComplete(int result); 542 void OnWriteComplete(int result);
523 543
524 // Send relevant SETTINGS. This is generally called on connection setup. 544 // Send relevant SETTINGS. This is generally called on connection setup.
525 void SendInitialSettings(); 545 void SendInitialSettings();
526 546
527 // Helper method to send SETTINGS a frame. 547 // Helper method to send SETTINGS a frame.
528 void SendSettings(const SettingsMap& settings); 548 void SendSettings(const SettingsMap& settings);
529 549
(...skipping 18 matching lines...) Expand all
548 void WritePingFrame(uint32 unique_id); 568 void WritePingFrame(uint32 unique_id);
549 569
550 // Post a CheckPingStatus call after delay. Don't post if there is already 570 // Post a CheckPingStatus call after delay. Don't post if there is already
551 // CheckPingStatus running. 571 // CheckPingStatus running.
552 void PlanToCheckPingStatus(); 572 void PlanToCheckPingStatus();
553 573
554 // Check the status of the connection. It calls |CloseSessionOnError| if we 574 // Check the status of the connection. It calls |CloseSessionOnError| if we
555 // haven't received any data in |kHungInterval| time period. 575 // haven't received any data in |kHungInterval| time period.
556 void CheckPingStatus(base::TimeTicks last_check_time); 576 void CheckPingStatus(base::TimeTicks last_check_time);
557 577
558 // Start reading from the socket.
559 // Returns OK on success, or an error on failure.
560 net::Error ReadSocket();
561
562 // Write current data to the socket. 578 // Write current data to the socket.
563 void WriteSocketLater(); 579 void WriteSocketLater();
564 void WriteSocket(); 580 void WriteSocket();
565 581
566 // Get a new stream id. 582 // Get a new stream id.
567 int GetNewStreamId(); 583 int GetNewStreamId();
568 584
569 // Queue a frame for sending. 585 // Queue a frame for sending.
570 // |frame| is the frame to send. 586 // |frame| is the frame to send.
571 // |priority| is the priority for insertion into the queue. 587 // |priority| is the priority for insertion into the queue.
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 // |spdy_session_pool_| owns us, therefore its lifetime must exceed ours. We 731 // |spdy_session_pool_| owns us, therefore its lifetime must exceed ours. We
716 // set this to NULL after we are removed from the pool. 732 // set this to NULL after we are removed from the pool.
717 SpdySessionPool* spdy_session_pool_; 733 SpdySessionPool* spdy_session_pool_;
718 HttpServerProperties* const http_server_properties_; 734 HttpServerProperties* const http_server_properties_;
719 735
720 // The socket handle for this session. 736 // The socket handle for this session.
721 scoped_ptr<ClientSocketHandle> connection_; 737 scoped_ptr<ClientSocketHandle> connection_;
722 738
723 // The read buffer used to read data from the socket. 739 // The read buffer used to read data from the socket.
724 scoped_refptr<IOBuffer> read_buffer_; 740 scoped_refptr<IOBuffer> read_buffer_;
725 bool read_pending_;
726 741
727 int stream_hi_water_mark_; // The next stream id to use. 742 int stream_hi_water_mark_; // The next stream id to use.
728 743
729 // Queue, for each priority, of pending stream requests that have 744 // Queue, for each priority, of pending stream requests that have
730 // not yet been satisfied. 745 // not yet been satisfied.
731 PendingStreamRequestQueue pending_create_stream_queues_[NUM_PRIORITIES]; 746 PendingStreamRequestQueue pending_create_stream_queues_[NUM_PRIORITIES];
732 747
733 // A set of requests that are waiting to be completed (i.e., for the 748 // A set of requests that are waiting to be completed (i.e., for the
734 // stream to actually be created). This is necessary since we kick 749 // stream to actually be created). This is necessary since we kick
735 // off the stream creation asynchronously, and so the request may be 750 // off the stream creation asynchronously, and so the request may be
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
785 800
786 // Limits 801 // Limits
787 size_t max_concurrent_streams_; // 0 if no limit 802 size_t max_concurrent_streams_; // 0 if no limit
788 size_t max_concurrent_streams_limit_; 803 size_t max_concurrent_streams_limit_;
789 804
790 // Some statistics counters for the session. 805 // Some statistics counters for the session.
791 int streams_initiated_count_; 806 int streams_initiated_count_;
792 int streams_pushed_count_; 807 int streams_pushed_count_;
793 int streams_pushed_and_claimed_count_; 808 int streams_pushed_and_claimed_count_;
794 int streams_abandoned_count_; 809 int streams_abandoned_count_;
795 int bytes_received_; 810
811 // |total_bytes_received_| keeps track of all the bytes read by the
812 // SpdySession. It is used by the |Net.SpdySettingsCwnd...| histograms.
813 int total_bytes_received_;
814
815 // |bytes_read_| keeps track of number of bytes read continously in the
816 // DoLoop() without yielding.
817 int bytes_read_;
818
796 bool sent_settings_; // Did this session send settings when it started. 819 bool sent_settings_; // Did this session send settings when it started.
797 bool received_settings_; // Did this session receive at least one settings 820 bool received_settings_; // Did this session receive at least one settings
798 // frame. 821 // frame.
799 int stalled_streams_; // Count of streams that were ever stalled. 822 int stalled_streams_; // Count of streams that were ever stalled.
800 823
801 // Count of all pings on the wire, for which we have not gotten a response. 824 // Count of all pings on the wire, for which we have not gotten a response.
802 int64 pings_in_flight_; 825 int64 pings_in_flight_;
803 826
804 // This is the next ping_id (unique_id) to be sent in PING frame. 827 // This is the next ping_id (unique_id) to be sent in PING frame.
805 uint32 next_ping_id_; 828 uint32 next_ping_id_;
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 // This SPDY proxy is allowed to push resources from origins that are 903 // This SPDY proxy is allowed to push resources from origins that are
881 // different from those of their associated streams. 904 // different from those of their associated streams.
882 HostPortPair trusted_spdy_proxy_; 905 HostPortPair trusted_spdy_proxy_;
883 906
884 TimeFunc time_func_; 907 TimeFunc time_func_;
885 }; 908 };
886 909
887 } // namespace net 910 } // namespace net
888 911
889 #endif // NET_SPDY_SPDY_SESSION_H_ 912 #endif // NET_SPDY_SPDY_SESSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698