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

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

Issue 11644088: SPDY - implement greedy approach to read all the data and process it (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 10 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/net.gyp ('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 7
8 #include <algorithm> 8 #include <algorithm>
9 #include <list> 9 #include <list>
10 #include <map> 10 #include <map>
(...skipping 25 matching lines...) Expand all
36 // This is somewhat arbitrary and not really fixed, but it will always work 36 // This is somewhat arbitrary and not really fixed, but it will always work
37 // reasonably with ethernet. Chop the world into 2-packet chunks. This is 37 // reasonably with ethernet. Chop the world into 2-packet chunks. This is
38 // somewhat arbitrary, but is reasonably small and ensures that we elicit 38 // somewhat arbitrary, but is reasonably small and ensures that we elicit
39 // ACKs quickly from TCP (because TCP tries to only ACK every other packet). 39 // ACKs quickly from TCP (because TCP tries to only ACK every other packet).
40 const int kMss = 1430; 40 const int kMss = 1430;
41 const int kMaxSpdyFrameChunkSize = (2 * kMss) - SpdyFrame::kHeaderSize; 41 const int kMaxSpdyFrameChunkSize = (2 * kMss) - SpdyFrame::kHeaderSize;
42 42
43 // Specifies the maxiumum concurrent streams server could send (via push). 43 // Specifies the maxiumum concurrent streams server could send (via push).
44 const int kMaxConcurrentPushedStreams = 1000; 44 const int kMaxConcurrentPushedStreams = 1000;
45 45
46 // Specifies the number of bytes read synchronously (without yielding) if the
47 // data is available.
48 const int kMaxReadBytes = 32 * 1024;
49
46 class BoundNetLog; 50 class BoundNetLog;
47 struct LoadTimingInfo; 51 struct LoadTimingInfo;
48 class SpdyStream; 52 class SpdyStream;
49 class SSLInfo; 53 class SSLInfo;
50 54
51 enum SpdyProtocolErrorDetails { 55 enum SpdyProtocolErrorDetails {
52 // SpdyFramer::SpdyErrors 56 // SpdyFramer::SpdyErrors
53 SPDY_ERROR_NO_ERROR, 57 SPDY_ERROR_NO_ERROR,
54 SPDY_ERROR_INVALID_CONTROL_FRAME, 58 SPDY_ERROR_INVALID_CONTROL_FRAME,
55 SPDY_ERROR_CONTROL_PAYLOAD_TOO_LARGE, 59 SPDY_ERROR_CONTROL_PAYLOAD_TOO_LARGE,
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 262
259 // Returns the ServerBoundCertService used by this Socket, or NULL 263 // Returns the ServerBoundCertService used by this Socket, or NULL
260 // if server bound certs are not supported in this session. 264 // if server bound certs are not supported in this session.
261 ServerBoundCertService* GetServerBoundCertService() const; 265 ServerBoundCertService* GetServerBoundCertService() const;
262 266
263 // Send WINDOW_UPDATE frame, called by a stream whenever receive window 267 // Send WINDOW_UPDATE frame, called by a stream whenever receive window
264 // size is increased. 268 // size is increased.
265 void SendWindowUpdate(SpdyStreamId stream_id, int32 delta_window_size); 269 void SendWindowUpdate(SpdyStreamId stream_id, int32 delta_window_size);
266 270
267 // If session is closed, no new streams/transactions should be created. 271 // If session is closed, no new streams/transactions should be created.
268 bool IsClosed() const { return state_ == CLOSED; } 272 bool IsClosed() const { return state_ == STATE_CLOSED; }
269 273
270 // Closes this session. This will close all active streams and mark 274 // Closes this session. This will close all active streams and mark
271 // the session as permanently closed. 275 // the session as permanently closed.
272 // |err| should not be OK; this function is intended to be called on 276 // |err| should not be OK; this function is intended to be called on
273 // error. 277 // error.
274 // |remove_from_pool| indicates whether to also remove the session from the 278 // |remove_from_pool| indicates whether to also remove the session from the
275 // session pool. 279 // session pool.
276 // |description| indicates the reason for the error. 280 // |description| indicates the reason for the error.
277 void CloseSessionOnError(net::Error err, 281 void CloseSessionOnError(net::Error err,
278 bool remove_from_pool, 282 bool remove_from_pool,
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 ~CallbackResultPair(); 419 ~CallbackResultPair();
416 420
417 CompletionCallback callback; 421 CompletionCallback callback;
418 int result; 422 int result;
419 }; 423 };
420 424
421 typedef std::map<const scoped_refptr<SpdyStream>*, CallbackResultPair> 425 typedef std::map<const scoped_refptr<SpdyStream>*, CallbackResultPair>
422 PendingCallbackMap; 426 PendingCallbackMap;
423 427
424 enum State { 428 enum State {
425 IDLE, 429 STATE_IDLE,
426 CONNECTING, 430 STATE_CONNECTING,
427 CONNECTED, 431 STATE_DO_READ,
428 CLOSED 432 STATE_DO_READ_COMPLETE,
433 STATE_CLOSED
429 }; 434 };
430 435
431 virtual ~SpdySession(); 436 virtual ~SpdySession();
432 437
433 void ProcessPendingCreateStreams(); 438 void ProcessPendingCreateStreams();
434 int CreateStreamImpl( 439 int CreateStreamImpl(
435 const GURL& url, 440 const GURL& url,
436 RequestPriority priority, 441 RequestPriority priority,
437 scoped_refptr<SpdyStream>* spdy_stream, 442 scoped_refptr<SpdyStream>* spdy_stream,
438 const BoundNetLog& stream_net_log); 443 const BoundNetLog& stream_net_log);
439 444
445 // Start the DoLoop to read data from socket.
446 void StartRead();
447
448 // Try to make progress by reading and processing data.
449 int DoLoop(int result);
450 // The implementations of STATE_DO_READ/STATE_DO_READ_COMPLETE state changes
451 // of the state machine.
452 int DoRead();
453 int DoReadComplete(int bytes_read);
454
455 // Check if session is connected or not.
456 bool IsConnected() const {
457 return state_ == STATE_DO_READ || state_ == STATE_DO_READ_COMPLETE;
458 }
459
440 // IO Callbacks 460 // IO Callbacks
441 void OnReadComplete(int result); 461 void OnReadComplete(int result);
442 void OnWriteComplete(int result); 462 void OnWriteComplete(int result);
443 463
444 // Send relevant SETTINGS. This is generally called on connection setup. 464 // Send relevant SETTINGS. This is generally called on connection setup.
445 void SendInitialSettings(); 465 void SendInitialSettings();
446 466
447 // Helper method to send SETTINGS a frame. 467 // Helper method to send SETTINGS a frame.
448 void SendSettings(const SettingsMap& settings); 468 void SendSettings(const SettingsMap& settings);
449 469
(...skipping 14 matching lines...) Expand all
464 void WritePingFrame(uint32 unique_id); 484 void WritePingFrame(uint32 unique_id);
465 485
466 // Post a CheckPingStatus call after delay. Don't post if there is already 486 // Post a CheckPingStatus call after delay. Don't post if there is already
467 // CheckPingStatus running. 487 // CheckPingStatus running.
468 void PlanToCheckPingStatus(); 488 void PlanToCheckPingStatus();
469 489
470 // Check the status of the connection. It calls |CloseSessionOnError| if we 490 // Check the status of the connection. It calls |CloseSessionOnError| if we
471 // haven't received any data in |kHungInterval| time period. 491 // haven't received any data in |kHungInterval| time period.
472 void CheckPingStatus(base::TimeTicks last_check_time); 492 void CheckPingStatus(base::TimeTicks last_check_time);
473 493
474 // Start reading from the socket.
475 // Returns OK on success, or an error on failure.
476 net::Error ReadSocket();
477
478 // Write current data to the socket. 494 // Write current data to the socket.
479 void WriteSocketLater(); 495 void WriteSocketLater();
480 void WriteSocket(); 496 void WriteSocket();
481 497
482 // Get a new stream id. 498 // Get a new stream id.
483 int GetNewStreamId(); 499 int GetNewStreamId();
484 500
485 // Queue a frame for sending. 501 // Queue a frame for sending.
486 // |frame| is the frame to send. 502 // |frame| is the frame to send.
487 // |priority| is the priority for insertion into the queue. 503 // |priority| is the priority for insertion into the queue.
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 // |spdy_session_pool_| owns us, therefore its lifetime must exceed ours. We 618 // |spdy_session_pool_| owns us, therefore its lifetime must exceed ours. We
603 // set this to NULL after we are removed from the pool. 619 // set this to NULL after we are removed from the pool.
604 SpdySessionPool* spdy_session_pool_; 620 SpdySessionPool* spdy_session_pool_;
605 HttpServerProperties* const http_server_properties_; 621 HttpServerProperties* const http_server_properties_;
606 622
607 // The socket handle for this session. 623 // The socket handle for this session.
608 scoped_ptr<ClientSocketHandle> connection_; 624 scoped_ptr<ClientSocketHandle> connection_;
609 625
610 // The read buffer used to read data from the socket. 626 // The read buffer used to read data from the socket.
611 scoped_refptr<IOBuffer> read_buffer_; 627 scoped_refptr<IOBuffer> read_buffer_;
612 bool read_pending_;
613 628
614 int stream_hi_water_mark_; // The next stream id to use. 629 int stream_hi_water_mark_; // The next stream id to use.
615 630
616 // Queue, for each priority, of pending Create Streams that have not 631 // Queue, for each priority, of pending Create Streams that have not
617 // yet been satisfied 632 // yet been satisfied
618 PendingCreateStreamQueue pending_create_stream_queues_[NUM_PRIORITIES]; 633 PendingCreateStreamQueue pending_create_stream_queues_[NUM_PRIORITIES];
619 634
620 // Map from stream id to all active streams. Streams are active in the sense 635 // Map from stream id to all active streams. Streams are active in the sense
621 // that they have a consumer (typically SpdyNetworkTransaction and regardless 636 // that they have a consumer (typically SpdyNetworkTransaction and regardless
622 // of whether or not there is currently any ongoing IO [might be waiting for 637 // of whether or not there is currently any ongoing IO [might be waiting for
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 680
666 // Limits 681 // Limits
667 size_t max_concurrent_streams_; // 0 if no limit 682 size_t max_concurrent_streams_; // 0 if no limit
668 size_t max_concurrent_streams_limit_; 683 size_t max_concurrent_streams_limit_;
669 684
670 // Some statistics counters for the session. 685 // Some statistics counters for the session.
671 int streams_initiated_count_; 686 int streams_initiated_count_;
672 int streams_pushed_count_; 687 int streams_pushed_count_;
673 int streams_pushed_and_claimed_count_; 688 int streams_pushed_and_claimed_count_;
674 int streams_abandoned_count_; 689 int streams_abandoned_count_;
675 int bytes_received_; 690
691 // |total_bytes_received_| keeps track of all the bytes read by the
692 // SpdySession. It is used by the |Net.SpdySettingsCwnd...| histograms.
693 int total_bytes_received_;
694
695 // |bytes_read_| keeps track of number of bytes read continously in the
696 // DoLoop() without yielding.
697 int bytes_read_;
698
676 bool sent_settings_; // Did this session send settings when it started. 699 bool sent_settings_; // Did this session send settings when it started.
677 bool received_settings_; // Did this session receive at least one settings 700 bool received_settings_; // Did this session receive at least one settings
678 // frame. 701 // frame.
679 int stalled_streams_; // Count of streams that were ever stalled. 702 int stalled_streams_; // Count of streams that were ever stalled.
680 703
681 // Count of all pings on the wire, for which we have not gotten a response. 704 // Count of all pings on the wire, for which we have not gotten a response.
682 int64 pings_in_flight_; 705 int64 pings_in_flight_;
683 706
684 // This is the next ping_id (unique_id) to be sent in PING frame. 707 // This is the next ping_id (unique_id) to be sent in PING frame.
685 uint32 next_ping_id_; 708 uint32 next_ping_id_;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 // This SPDY proxy is allowed to push resources from origins that are 772 // This SPDY proxy is allowed to push resources from origins that are
750 // different from those of their associated streams. 773 // different from those of their associated streams.
751 HostPortPair trusted_spdy_proxy_; 774 HostPortPair trusted_spdy_proxy_;
752 775
753 TimeFunc time_func_; 776 TimeFunc time_func_;
754 }; 777 };
755 778
756 } // namespace net 779 } // namespace net
757 780
758 #endif // NET_SPDY_SPDY_SESSION_H_ 781 #endif // NET_SPDY_SPDY_SESSION_H_
OLDNEW
« no previous file with comments | « net/net.gyp ('k') | net/spdy/spdy_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698