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

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

Issue 1411383005: Initial implementation of RequestPriority-based HTTP/2 dependencies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Final round of comments. Created 5 years, 1 month 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
« no previous file with comments | « net/spdy/spdy_proxy_client_socket_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 7
8 #include <deque> 8 #include <deque>
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 21 matching lines...) Expand all
32 #include "net/spdy/spdy_header_block.h" 32 #include "net/spdy/spdy_header_block.h"
33 #include "net/spdy/spdy_protocol.h" 33 #include "net/spdy/spdy_protocol.h"
34 #include "net/spdy/spdy_session_pool.h" 34 #include "net/spdy/spdy_session_pool.h"
35 #include "net/spdy/spdy_stream.h" 35 #include "net/spdy/spdy_stream.h"
36 #include "net/spdy/spdy_write_queue.h" 36 #include "net/spdy/spdy_write_queue.h"
37 #include "net/ssl/ssl_config_service.h" 37 #include "net/ssl/ssl_config_service.h"
38 #include "url/gurl.h" 38 #include "url/gurl.h"
39 39
40 namespace net { 40 namespace net {
41 41
42 namespace test {
43 class SpdyStreamTest;
44 }
45
42 // This is somewhat arbitrary and not really fixed, but it will always work 46 // This is somewhat arbitrary and not really fixed, but it will always work
43 // reasonably with ethernet. Chop the world into 2-packet chunks. This is 47 // reasonably with ethernet. Chop the world into 2-packet chunks. This is
44 // somewhat arbitrary, but is reasonably small and ensures that we elicit 48 // somewhat arbitrary, but is reasonably small and ensures that we elicit
45 // ACKs quickly from TCP (because TCP tries to only ACK every other packet). 49 // ACKs quickly from TCP (because TCP tries to only ACK every other packet).
46 const int kMss = 1430; 50 const int kMss = 1430;
47 // The 8 is the size of the SPDY frame header. 51 // The 8 is the size of the SPDY frame header.
48 const int kMaxSpdyFrameChunkSize = (2 * kMss) - 8; 52 const int kMaxSpdyFrameChunkSize = (2 * kMss) - 8;
49 53
50 // Maximum number of concurrent streams we will create, unless the server 54 // Maximum number of concurrent streams we will create, unless the server
51 // sends a SETTINGS frame with a different value. 55 // sends a SETTINGS frame with a different value.
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 // standards for TLS. 514 // standards for TLS.
511 bool HasAcceptableTransportSecurity() const; 515 bool HasAcceptableTransportSecurity() const;
512 516
513 // Must be used only by |pool_|. 517 // Must be used only by |pool_|.
514 base::WeakPtr<SpdySession> GetWeakPtr(); 518 base::WeakPtr<SpdySession> GetWeakPtr();
515 519
516 // HigherLayeredPool implementation: 520 // HigherLayeredPool implementation:
517 bool CloseOneIdleConnection() override; 521 bool CloseOneIdleConnection() override;
518 522
519 private: 523 private:
524 friend class test::SpdyStreamTest;
520 friend class base::RefCounted<SpdySession>; 525 friend class base::RefCounted<SpdySession>;
526 friend class HttpNetworkTransactionTest;
527 friend class HttpProxyClientSocketPoolTest;
528 friend class SpdyHttpStreamTest;
529 friend class SpdyNetworkTransactionTest;
530 friend class SpdyProxyClientSocketTest;
531 friend class SpdySessionTest;
521 friend class SpdyStreamRequest; 532 friend class SpdyStreamRequest;
522 friend class SpdySessionTest;
523 533
524 // Allow tests to access our innards for testing purposes. 534 // Allow tests to access our innards for testing purposes.
525 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, ClientPing); 535 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, ClientPing);
526 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, FailedPing); 536 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, FailedPing);
527 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, GetActivePushStream); 537 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, GetActivePushStream);
528 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, DeleteExpiredPushStreams); 538 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, DeleteExpiredPushStreams);
529 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, ProtocolNegotiation); 539 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, ProtocolNegotiation);
530 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, ClearSettings); 540 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, ClearSettings);
531 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, AdjustRecvWindowSize); 541 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, AdjustRecvWindowSize);
532 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, AdjustSendWindowSize); 542 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, AdjustSendWindowSize);
533 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, SessionFlowControlInactiveStream); 543 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, SessionFlowControlInactiveStream);
534 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, SessionFlowControlPadding); 544 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, SessionFlowControlPadding);
535 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, 545 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest,
536 SessionFlowControlTooMuchDataTwoDataFrames); 546 SessionFlowControlTooMuchDataTwoDataFrames);
537 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, 547 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest,
538 StreamFlowControlTooMuchDataTwoDataFrames); 548 StreamFlowControlTooMuchDataTwoDataFrames);
539 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, SessionFlowControlNoReceiveLeaks); 549 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, SessionFlowControlNoReceiveLeaks);
540 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, SessionFlowControlNoSendLeaks); 550 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, SessionFlowControlNoSendLeaks);
541 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, SessionFlowControlEndToEnd); 551 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, SessionFlowControlEndToEnd);
542 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, StreamIdSpaceExhausted); 552 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, StreamIdSpaceExhausted);
543 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, UnstallRacesWithStreamCreation); 553 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, UnstallRacesWithStreamCreation);
544 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, GoAwayOnSessionFlowControlError); 554 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, GoAwayOnSessionFlowControlError);
545 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, 555 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest,
546 RejectPushedStreamExceedingConcurrencyLimit); 556 RejectPushedStreamExceedingConcurrencyLimit);
547 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, IgnoreReservedRemoteStreamsCount); 557 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, IgnoreReservedRemoteStreamsCount);
548 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, 558 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest,
549 CancelReservedStreamOnHeadersReceived); 559 CancelReservedStreamOnHeadersReceived);
550 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, RejectInvalidUnknownFrames); 560 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, RejectInvalidUnknownFrames);
561 FRIEND_TEST_ALL_PREFIXES(SpdySessionPoolTest, IPAddressChanged);
551 562
552 typedef std::deque<base::WeakPtr<SpdyStreamRequest> > 563 typedef std::deque<base::WeakPtr<SpdyStreamRequest> >
553 PendingStreamRequestQueue; 564 PendingStreamRequestQueue;
554 565
555 struct ActiveStreamInfo { 566 struct ActiveStreamInfo {
556 ActiveStreamInfo(); 567 ActiveStreamInfo();
557 explicit ActiveStreamInfo(SpdyStream* stream); 568 explicit ActiveStreamInfo(SpdyStream* stream);
558 ~ActiveStreamInfo(); 569 ~ActiveStreamInfo();
559 570
560 SpdyStream* stream; 571 SpdyStream* stream;
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
951 int64 pings_in_flight() const { return pings_in_flight_; } 962 int64 pings_in_flight() const { return pings_in_flight_; }
952 963
953 SpdyPingId next_ping_id() const { return next_ping_id_; } 964 SpdyPingId next_ping_id() const { return next_ping_id_; }
954 965
955 base::TimeTicks last_activity_time() const { return last_activity_time_; } 966 base::TimeTicks last_activity_time() const { return last_activity_time_; }
956 967
957 bool check_ping_status_pending() const { return check_ping_status_pending_; } 968 bool check_ping_status_pending() const { return check_ping_status_pending_; }
958 969
959 size_t max_concurrent_streams() const { return max_concurrent_streams_; } 970 size_t max_concurrent_streams() const { return max_concurrent_streams_; }
960 971
972 // Set whether priority->dependency conversion is enabled
973 // by default for all future SpdySessions.
974 static void SetPriorityDependencyDefaultForTesting(bool enable);
975
961 // Whether Do{Read,Write}Loop() is in the call stack. Useful for 976 // Whether Do{Read,Write}Loop() is in the call stack. Useful for
962 // making sure we don't destroy ourselves prematurely in that case. 977 // making sure we don't destroy ourselves prematurely in that case.
963 bool in_io_loop_; 978 bool in_io_loop_;
964 979
965 // The key used to identify this session. 980 // The key used to identify this session.
966 const SpdySessionKey spdy_session_key_; 981 const SpdySessionKey spdy_session_key_;
967 982
968 // Set set of SpdySessionKeys for which this session has serviced 983 // Set set of SpdySessionKeys for which this session has serviced
969 // requests. 984 // requests.
970 std::set<SpdySessionKey> pooled_aliases_; 985 std::set<SpdySessionKey> pooled_aliases_;
(...skipping 26 matching lines...) Expand all
997 // the server to start pushing the stream]) or there are still network events 1012 // the server to start pushing the stream]) or there are still network events
998 // incoming even though the consumer has already gone away (cancellation). 1013 // incoming even though the consumer has already gone away (cancellation).
999 // 1014 //
1000 // |active_streams_| owns all its SpdyStream objects. 1015 // |active_streams_| owns all its SpdyStream objects.
1001 // 1016 //
1002 // TODO(willchan): Perhaps we should separate out cancelled streams and move 1017 // TODO(willchan): Perhaps we should separate out cancelled streams and move
1003 // them into a separate ActiveStreamMap, and not deliver network events to 1018 // them into a separate ActiveStreamMap, and not deliver network events to
1004 // them? 1019 // them?
1005 ActiveStreamMap active_streams_; 1020 ActiveStreamMap active_streams_;
1006 1021
1022 // Per-priority map from stream id to all active streams. This map will
1023 // contain the same set of streams as |active_streams_|. It is used for
1024 // setting dependencies to match incoming requests RequestPriority.
1025 //
1026 // |active_streams_by_priority_| does *not* own its SpdyStream objects.
1027 std::map<SpdyStreamId, SpdyStream*>
1028 active_streams_by_priority_[NUM_PRIORITIES];
1029
1007 // (Bijective) map from the URL to the ID of the streams that have 1030 // (Bijective) map from the URL to the ID of the streams that have
1008 // already started to be pushed by the server, but do not have 1031 // already started to be pushed by the server, but do not have
1009 // consumers yet. Contains a subset of |active_streams_|. 1032 // consumers yet. Contains a subset of |active_streams_|.
1010 PushedStreamMap unclaimed_pushed_streams_; 1033 PushedStreamMap unclaimed_pushed_streams_;
1011 1034
1012 // Set of all created streams but that have not yet sent any frames. 1035 // Set of all created streams but that have not yet sent any frames.
1013 // 1036 //
1014 // |created_streams_| owns all its SpdyStream objects. 1037 // |created_streams_| owns all its SpdyStream objects.
1015 CreatedStreamSet created_streams_; 1038 CreatedStreamSet created_streams_;
1016 1039
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
1175 // to build a new connection, and see if that completes before we (finally) 1198 // to build a new connection, and see if that completes before we (finally)
1176 // get a PING response (http://crbug.com/127812). 1199 // get a PING response (http://crbug.com/127812).
1177 base::TimeDelta hung_interval_; 1200 base::TimeDelta hung_interval_;
1178 1201
1179 // This SPDY proxy is allowed to push resources from origins that are 1202 // This SPDY proxy is allowed to push resources from origins that are
1180 // different from those of their associated streams. 1203 // different from those of their associated streams.
1181 HostPortPair trusted_spdy_proxy_; 1204 HostPortPair trusted_spdy_proxy_;
1182 1205
1183 TimeFunc time_func_; 1206 TimeFunc time_func_;
1184 1207
1208 // Should priority-based dependency information be sent in stream header
1209 // frames.
1210 bool send_priority_dependency_;
1211
1185 // Used for posting asynchronous IO tasks. We use this even though 1212 // Used for posting asynchronous IO tasks. We use this even though
1186 // SpdySession is refcounted because we don't need to keep the SpdySession 1213 // SpdySession is refcounted because we don't need to keep the SpdySession
1187 // alive if the last reference is within a RunnableMethod. Just revoke the 1214 // alive if the last reference is within a RunnableMethod. Just revoke the
1188 // method. 1215 // method.
1189 base::WeakPtrFactory<SpdySession> weak_factory_; 1216 base::WeakPtrFactory<SpdySession> weak_factory_;
1190 }; 1217 };
1191 1218
1192 } // namespace net 1219 } // namespace net
1193 1220
1194 #endif // NET_SPDY_SPDY_SESSION_H_ 1221 #endif // NET_SPDY_SPDY_SESSION_H_
OLDNEW
« no previous file with comments | « net/spdy/spdy_proxy_client_socket_unittest.cc ('k') | net/spdy/spdy_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698