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

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

Issue 2458793002: Server push cancellation: add PushPromiseHelper which reflects information on the push promise. (Closed)
Patch Set: add PushDelegate Created 4 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
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 <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 15 matching lines...) Expand all
26 #include "net/base/net_errors.h" 26 #include "net/base/net_errors.h"
27 #include "net/base/net_export.h" 27 #include "net/base/net_export.h"
28 #include "net/base/request_priority.h" 28 #include "net/base/request_priority.h"
29 #include "net/socket/client_socket_handle.h" 29 #include "net/socket/client_socket_handle.h"
30 #include "net/socket/client_socket_pool.h" 30 #include "net/socket/client_socket_pool.h"
31 #include "net/socket/next_proto.h" 31 #include "net/socket/next_proto.h"
32 #include "net/socket/ssl_client_socket.h" 32 #include "net/socket/ssl_client_socket.h"
33 #include "net/socket/stream_socket.h" 33 #include "net/socket/stream_socket.h"
34 #include "net/spdy/buffered_spdy_framer.h" 34 #include "net/spdy/buffered_spdy_framer.h"
35 #include "net/spdy/http2_priority_dependencies.h" 35 #include "net/spdy/http2_priority_dependencies.h"
36 #include "net/spdy/push_delegate.h"
36 #include "net/spdy/spdy_alt_svc_wire_format.h" 37 #include "net/spdy/spdy_alt_svc_wire_format.h"
37 #include "net/spdy/spdy_buffer.h" 38 #include "net/spdy/spdy_buffer.h"
38 #include "net/spdy/spdy_framer.h" 39 #include "net/spdy/spdy_framer.h"
39 #include "net/spdy/spdy_header_block.h" 40 #include "net/spdy/spdy_header_block.h"
40 #include "net/spdy/spdy_protocol.h" 41 #include "net/spdy/spdy_protocol.h"
41 #include "net/spdy/spdy_session_pool.h" 42 #include "net/spdy/spdy_session_pool.h"
42 #include "net/spdy/spdy_stream.h" 43 #include "net/spdy/spdy_stream.h"
43 #include "net/spdy/spdy_write_queue.h" 44 #include "net/spdy/spdy_write_queue.h"
44 #include "net/ssl/ssl_config_service.h" 45 #include "net/ssl/ssl_config_service.h"
45 #include "url/gurl.h" 46 #include "url/gurl.h"
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 // might also not have initiated the stream yet, but indicated it 320 // might also not have initiated the stream yet, but indicated it
320 // will via X-Associated-Content. Returns OK if a stream was found 321 // will via X-Associated-Content. Returns OK if a stream was found
321 // and put into |spdy_stream|, or if one was not found but it is 322 // and put into |spdy_stream|, or if one was not found but it is
322 // okay to create a new stream (in which case |spdy_stream| is 323 // okay to create a new stream (in which case |spdy_stream| is
323 // reset). Returns an error (not ERR_IO_PENDING) otherwise, and 324 // reset). Returns an error (not ERR_IO_PENDING) otherwise, and
324 // resets |spdy_stream|. 325 // resets |spdy_stream|.
325 int GetPushStream(const GURL& url, 326 int GetPushStream(const GURL& url,
326 base::WeakPtr<SpdyStream>* spdy_stream, 327 base::WeakPtr<SpdyStream>* spdy_stream,
327 const NetLogWithSource& stream_net_log); 328 const NetLogWithSource& stream_net_log);
328 329
330 void set_push_delegate(PushDelegate* push_delegate) {
Ryan Hamilton 2016/10/28 00:32:22 nit: Comment on ownership of |push_delegate|, eith
Zhongyi Shi 2016/11/07 22:07:04 Done.
331 push_delegate_ = push_delegate;
332 }
Ryan Hamilton 2016/10/28 00:32:22 Can this come in via the constructor, or is that p
Zhongyi Shi 2016/11/07 22:07:04 It's hard for SpdySession. Especially in spdy_sess
333
334 // Called when the pushed stream should be cancelled. If the pushed stream is
335 // not claimed and active, sends RST to the server to cancel the stream.
336 void CancelPush(const GURL& url);
337
329 // Initialize the session with the given connection. |is_secure| 338 // Initialize the session with the given connection. |is_secure|
330 // must indicate whether |connection| uses an SSL socket or not; it 339 // must indicate whether |connection| uses an SSL socket or not; it
331 // is usually true, but it can be false for testing or when SPDY is 340 // is usually true, but it can be false for testing or when SPDY is
332 // configured to work with non-secure sockets. 341 // configured to work with non-secure sockets.
333 // 342 //
334 // |pool| is the SpdySessionPool that owns us. Its lifetime must 343 // |pool| is the SpdySessionPool that owns us. Its lifetime must
335 // strictly be greater than |this|. 344 // strictly be greater than |this|.
336 // 345 //
337 // The session begins reading from |connection| on a subsequent event loop 346 // The session begins reading from |connection| on a subsequent event loop
338 // iteration, so the SpdySession may close immediately afterwards if the first 347 // iteration, so the SpdySession may close immediately afterwards if the first
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 friend class SpdySessionTest; 576 friend class SpdySessionTest;
568 friend class SpdyStreamRequest; 577 friend class SpdyStreamRequest;
569 578
570 // Allow tests to access our innards for testing purposes. 579 // Allow tests to access our innards for testing purposes.
571 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, ClientPing); 580 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, ClientPing);
572 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, FailedPing); 581 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, FailedPing);
573 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, GetActivePushStream); 582 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, GetActivePushStream);
574 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, DeleteExpiredPushStreams); 583 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, DeleteExpiredPushStreams);
575 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, MetricsCollectionOnPushStreams); 584 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, MetricsCollectionOnPushStreams);
576 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, CancelPushBeforeClaimed); 585 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, CancelPushBeforeClaimed);
586 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, CancelPushAfterSessionGoesAway);
577 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, CancelPushAfterExpired); 587 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, CancelPushAfterExpired);
578 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, ProtocolNegotiation); 588 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, ProtocolNegotiation);
579 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, ClearSettings); 589 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, ClearSettings);
580 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, AdjustRecvWindowSize); 590 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, AdjustRecvWindowSize);
581 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, AdjustSendWindowSize); 591 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, AdjustSendWindowSize);
582 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, SessionFlowControlInactiveStream); 592 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, SessionFlowControlInactiveStream);
583 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, SessionFlowControlPadding); 593 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, SessionFlowControlPadding);
584 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, 594 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest,
585 SessionFlowControlTooMuchDataTwoDataFrames); 595 SessionFlowControlTooMuchDataTwoDataFrames);
586 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, 596 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest,
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 // Called when there is room to create more streams (e.g., a stream 680 // Called when there is room to create more streams (e.g., a stream
671 // was closed). Processes as many pending stream requests as 681 // was closed). Processes as many pending stream requests as
672 // possible. 682 // possible.
673 void ProcessPendingStreamRequests(); 683 void ProcessPendingStreamRequests();
674 684
675 bool TryCreatePushStream(SpdyStreamId stream_id, 685 bool TryCreatePushStream(SpdyStreamId stream_id,
676 SpdyStreamId associated_stream_id, 686 SpdyStreamId associated_stream_id,
677 SpdyPriority priority, 687 SpdyPriority priority,
678 SpdyHeaderBlock headers); 688 SpdyHeaderBlock headers);
679 689
680 // Called when the pushed stream should be cancelled. If the pushed stream is
681 // not claimed and active, sends RST to the server to cancel the stream.
682 void CancelPush(const GURL& url);
683
684 // Close the stream pointed to by the given iterator. Note that that 690 // Close the stream pointed to by the given iterator. Note that that
685 // stream may hold the last reference to the session. 691 // stream may hold the last reference to the session.
686 void CloseActiveStreamIterator(ActiveStreamMap::iterator it, int status); 692 void CloseActiveStreamIterator(ActiveStreamMap::iterator it, int status);
687 693
688 // Close the stream pointed to by the given iterator. Note that that 694 // Close the stream pointed to by the given iterator. Note that that
689 // stream may hold the last reference to the session. 695 // stream may hold the last reference to the session.
690 void CloseCreatedStreamIterator(CreatedStreamSet::iterator it, int status); 696 void CloseCreatedStreamIterator(CreatedStreamSet::iterator it, int status);
691 697
692 // Calls EnqueueResetStreamFrame() and then 698 // Calls EnqueueResetStreamFrame() and then
693 // CloseActiveStreamIterator(). 699 // CloseActiveStreamIterator().
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
1036 // 1042 //
1037 // |active_streams_| owns all its SpdyStream objects. 1043 // |active_streams_| owns all its SpdyStream objects.
1038 // 1044 //
1039 // TODO(willchan): Perhaps we should separate out cancelled streams and move 1045 // TODO(willchan): Perhaps we should separate out cancelled streams and move
1040 // them into a separate ActiveStreamMap, and not deliver network events to 1046 // them into a separate ActiveStreamMap, and not deliver network events to
1041 // them? 1047 // them?
1042 ActiveStreamMap active_streams_; 1048 ActiveStreamMap active_streams_;
1043 1049
1044 UnclaimedPushedStreamContainer unclaimed_pushed_streams_; 1050 UnclaimedPushedStreamContainer unclaimed_pushed_streams_;
1045 1051
1052 PushDelegate* push_delegate_;
Ryan Hamilton 2016/10/28 00:32:22 Can you add a comment which explains what this is
Zhongyi Shi 2016/11/07 22:07:04 Done.
1053
1046 // Set of all created streams but that have not yet sent any frames. 1054 // Set of all created streams but that have not yet sent any frames.
1047 // 1055 //
1048 // |created_streams_| owns all its SpdyStream objects. 1056 // |created_streams_| owns all its SpdyStream objects.
1049 CreatedStreamSet created_streams_; 1057 CreatedStreamSet created_streams_;
1050 1058
1051 // Number of pushed streams. All active streams are stored in 1059 // Number of pushed streams. All active streams are stored in
1052 // |active_streams_|, but it's better to know the number of push streams 1060 // |active_streams_|, but it's better to know the number of push streams
1053 // without traversing the whole collection. 1061 // without traversing the whole collection.
1054 size_t num_pushed_streams_; 1062 size_t num_pushed_streams_;
1055 1063
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 // Used for posting asynchronous IO tasks. We use this even though 1221 // Used for posting asynchronous IO tasks. We use this even though
1214 // SpdySession is refcounted because we don't need to keep the SpdySession 1222 // SpdySession is refcounted because we don't need to keep the SpdySession
1215 // alive if the last reference is within a RunnableMethod. Just revoke the 1223 // alive if the last reference is within a RunnableMethod. Just revoke the
1216 // method. 1224 // method.
1217 base::WeakPtrFactory<SpdySession> weak_factory_; 1225 base::WeakPtrFactory<SpdySession> weak_factory_;
1218 }; 1226 };
1219 1227
1220 } // namespace net 1228 } // namespace net
1221 1229
1222 #endif // NET_SPDY_SPDY_SESSION_H_ 1230 #endif // NET_SPDY_SPDY_SESSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698