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

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

Issue 266243004: Clang format slam. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 PROTOCOL_ERROR_RST_STREAM_FOR_NON_ACTIVE_STREAM = 23, 105 PROTOCOL_ERROR_RST_STREAM_FOR_NON_ACTIVE_STREAM = 23,
106 PROTOCOL_ERROR_SPDY_COMPRESSION_FAILURE = 24, 106 PROTOCOL_ERROR_SPDY_COMPRESSION_FAILURE = 24,
107 PROTOCOL_ERROR_REQUEST_FOR_SECURE_CONTENT_OVER_INSECURE_SESSION = 25, 107 PROTOCOL_ERROR_REQUEST_FOR_SECURE_CONTENT_OVER_INSECURE_SESSION = 25,
108 PROTOCOL_ERROR_SYN_REPLY_NOT_RECEIVED = 26, 108 PROTOCOL_ERROR_SYN_REPLY_NOT_RECEIVED = 26,
109 PROTOCOL_ERROR_INVALID_WINDOW_UPDATE_SIZE = 27, 109 PROTOCOL_ERROR_INVALID_WINDOW_UPDATE_SIZE = 27,
110 PROTOCOL_ERROR_RECEIVE_WINDOW_VIOLATION = 28, 110 PROTOCOL_ERROR_RECEIVE_WINDOW_VIOLATION = 28,
111 111
112 // Next free value. 112 // Next free value.
113 NUM_SPDY_PROTOCOL_ERROR_DETAILS = 35, 113 NUM_SPDY_PROTOCOL_ERROR_DETAILS = 35,
114 }; 114 };
115 SpdyProtocolErrorDetails NET_EXPORT_PRIVATE MapFramerErrorToProtocolError( 115 SpdyProtocolErrorDetails NET_EXPORT_PRIVATE
116 SpdyFramer::SpdyError); 116 MapFramerErrorToProtocolError(SpdyFramer::SpdyError);
117 SpdyProtocolErrorDetails NET_EXPORT_PRIVATE MapRstStreamStatusToProtocolError( 117 SpdyProtocolErrorDetails NET_EXPORT_PRIVATE
118 SpdyRstStreamStatus); 118 MapRstStreamStatusToProtocolError(SpdyRstStreamStatus);
119 119
120 // If these compile asserts fail then SpdyProtocolErrorDetails needs 120 // If these compile asserts fail then SpdyProtocolErrorDetails needs
121 // to be updated with new values, as do the mapping functions above. 121 // to be updated with new values, as do the mapping functions above.
122 COMPILE_ASSERT(12 == SpdyFramer::LAST_ERROR, 122 COMPILE_ASSERT(12 == SpdyFramer::LAST_ERROR,
123 SpdyProtocolErrorDetails_SpdyErrors_mismatch); 123 SpdyProtocolErrorDetails_SpdyErrors_mismatch);
124 COMPILE_ASSERT(15 == RST_STREAM_NUM_STATUS_CODES, 124 COMPILE_ASSERT(15 == RST_STREAM_NUM_STATUS_CODES,
125 SpdyProtocolErrorDetails_RstStreamStatus_mismatch); 125 SpdyProtocolErrorDetails_RstStreamStatus_mismatch);
126 126
127 // A helper class used to manage a request to create a stream. 127 // A helper class used to manage a request to create a stream.
128 class NET_EXPORT_PRIVATE SpdyStreamRequest { 128 class NET_EXPORT_PRIVATE SpdyStreamRequest {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 NetLog* net_log); 226 NetLog* net_log);
227 227
228 virtual ~SpdySession(); 228 virtual ~SpdySession();
229 229
230 const HostPortPair& host_port_pair() const { 230 const HostPortPair& host_port_pair() const {
231 return spdy_session_key_.host_port_proxy_pair().first; 231 return spdy_session_key_.host_port_proxy_pair().first;
232 } 232 }
233 const HostPortProxyPair& host_port_proxy_pair() const { 233 const HostPortProxyPair& host_port_proxy_pair() const {
234 return spdy_session_key_.host_port_proxy_pair(); 234 return spdy_session_key_.host_port_proxy_pair();
235 } 235 }
236 const SpdySessionKey& spdy_session_key() const { 236 const SpdySessionKey& spdy_session_key() const { return spdy_session_key_; }
237 return spdy_session_key_;
238 }
239 // Get a pushed stream for a given |url|. If the server initiates a 237 // Get a pushed stream for a given |url|. If the server initiates a
240 // stream, it might already exist for a given path. The server 238 // stream, it might already exist for a given path. The server
241 // might also not have initiated the stream yet, but indicated it 239 // might also not have initiated the stream yet, but indicated it
242 // will via X-Associated-Content. Returns OK if a stream was found 240 // will via X-Associated-Content. Returns OK if a stream was found
243 // and put into |spdy_stream|, or if one was not found but it is 241 // and put into |spdy_stream|, or if one was not found but it is
244 // okay to create a new stream (in which case |spdy_stream| is 242 // okay to create a new stream (in which case |spdy_stream| is
245 // reset). Returns an error (not ERR_IO_PENDING) otherwise, and 243 // reset). Returns an error (not ERR_IO_PENDING) otherwise, and
246 // resets |spdy_stream|. 244 // resets |spdy_stream|.
247 int GetPushStream( 245 int GetPushStream(const GURL& url,
248 const GURL& url, 246 base::WeakPtr<SpdyStream>* spdy_stream,
249 base::WeakPtr<SpdyStream>* spdy_stream, 247 const BoundNetLog& stream_net_log);
250 const BoundNetLog& stream_net_log);
251 248
252 // Initialize the session with the given connection. |is_secure| 249 // Initialize the session with the given connection. |is_secure|
253 // must indicate whether |connection| uses an SSL socket or not; it 250 // must indicate whether |connection| uses an SSL socket or not; it
254 // is usually true, but it can be false for testing or when SPDY is 251 // is usually true, but it can be false for testing or when SPDY is
255 // configured to work with non-secure sockets. 252 // configured to work with non-secure sockets.
256 // 253 //
257 // |pool| is the SpdySessionPool that owns us. Its lifetime must 254 // |pool| is the SpdySessionPool that owns us. Its lifetime must
258 // strictly be greater than |this|. 255 // strictly be greater than |this|.
259 // 256 //
260 // |certificate_error_code| must either be OK or less than 257 // |certificate_error_code| must either be OK or less than
(...skipping 24 matching lines...) Expand all
285 bool VerifyDomainAuthentication(const std::string& domain); 282 bool VerifyDomainAuthentication(const std::string& domain);
286 283
287 // Pushes the given producer into the write queue for 284 // Pushes the given producer into the write queue for
288 // |stream|. |stream| is guaranteed to be activated before the 285 // |stream|. |stream| is guaranteed to be activated before the
289 // producer is used to produce its frame. 286 // producer is used to produce its frame.
290 void EnqueueStreamWrite(const base::WeakPtr<SpdyStream>& stream, 287 void EnqueueStreamWrite(const base::WeakPtr<SpdyStream>& stream,
291 SpdyFrameType frame_type, 288 SpdyFrameType frame_type,
292 scoped_ptr<SpdyBufferProducer> producer); 289 scoped_ptr<SpdyBufferProducer> producer);
293 290
294 // Creates and returns a SYN frame for |stream_id|. 291 // Creates and returns a SYN frame for |stream_id|.
295 scoped_ptr<SpdyFrame> CreateSynStream( 292 scoped_ptr<SpdyFrame> CreateSynStream(SpdyStreamId stream_id,
296 SpdyStreamId stream_id, 293 RequestPriority priority,
297 RequestPriority priority, 294 SpdyControlFlags flags,
298 SpdyControlFlags flags, 295 const SpdyHeaderBlock& headers);
299 const SpdyHeaderBlock& headers);
300 296
301 // Creates and returns a SpdyBuffer holding a data frame with the 297 // Creates and returns a SpdyBuffer holding a data frame with the
302 // given data. May return NULL if stalled by flow control. 298 // given data. May return NULL if stalled by flow control.
303 scoped_ptr<SpdyBuffer> CreateDataBuffer(SpdyStreamId stream_id, 299 scoped_ptr<SpdyBuffer> CreateDataBuffer(SpdyStreamId stream_id,
304 IOBuffer* data, 300 IOBuffer* data,
305 int len, 301 int len,
306 SpdyDataFlags flags); 302 SpdyDataFlags flags);
307 303
308 // Close the stream with the given ID, which must exist and be 304 // Close the stream with the given ID, which must exist and be
309 // active. Note that that stream may hold the last reference to the 305 // active. Note that that stream may hold the last reference to the
(...skipping 23 matching lines...) Expand all
333 bool GetSSLInfo(SSLInfo* ssl_info, 329 bool GetSSLInfo(SSLInfo* ssl_info,
334 bool* was_npn_negotiated, 330 bool* was_npn_negotiated,
335 NextProto* protocol_negotiated); 331 NextProto* protocol_negotiated);
336 332
337 // Fills SSL Certificate Request info |cert_request_info| and returns 333 // Fills SSL Certificate Request info |cert_request_info| and returns
338 // true when SSL is in use. 334 // true when SSL is in use.
339 bool GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info); 335 bool GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info);
340 336
341 // Send a WINDOW_UPDATE frame for a stream. Called by a stream 337 // Send a WINDOW_UPDATE frame for a stream. Called by a stream
342 // whenever receive window size is increased. 338 // whenever receive window size is increased.
343 void SendStreamWindowUpdate(SpdyStreamId stream_id, 339 void SendStreamWindowUpdate(SpdyStreamId stream_id, uint32 delta_window_size);
344 uint32 delta_window_size);
345 340
346 // Whether the stream is closed, i.e. it has stopped processing data 341 // Whether the stream is closed, i.e. it has stopped processing data
347 // and is about to be destroyed. 342 // and is about to be destroyed.
348 // 343 //
349 // TODO(akalin): This is only used in tests. Remove this function 344 // TODO(akalin): This is only used in tests. Remove this function
350 // and have tests test the WeakPtr instead. 345 // and have tests test the WeakPtr instead.
351 bool IsClosed() const { return availability_state_ == STATE_CLOSED; } 346 bool IsClosed() const { return availability_state_ == STATE_CLOSED; }
352 347
353 // Closes this session. This will close all active streams and mark 348 // Closes this session. This will close all active streams and mark
354 // the session as permanently closed. Callers must assume that the 349 // the session as permanently closed. Callers must assume that the
(...skipping 15 matching lines...) Expand all
370 // Value. Caller takes possession of the returned value. 365 // Value. Caller takes possession of the returned value.
371 base::Value* GetInfoAsValue() const; 366 base::Value* GetInfoAsValue() const;
372 367
373 // Indicates whether the session is being reused after having successfully 368 // Indicates whether the session is being reused after having successfully
374 // used to send/receive data in the past or if the underlying socket was idle 369 // used to send/receive data in the past or if the underlying socket was idle
375 // before being used for a SPDY session. 370 // before being used for a SPDY session.
376 bool IsReused() const; 371 bool IsReused() const;
377 372
378 // Returns true if the underlying transport socket ever had any reads or 373 // Returns true if the underlying transport socket ever had any reads or
379 // writes. 374 // writes.
380 bool WasEverUsed() const { 375 bool WasEverUsed() const { return connection_->socket()->WasEverUsed(); }
381 return connection_->socket()->WasEverUsed();
382 }
383 376
384 // Returns the load timing information from the perspective of the given 377 // Returns the load timing information from the perspective of the given
385 // stream. If it's not the first stream, the connection is considered reused 378 // stream. If it's not the first stream, the connection is considered reused
386 // for that stream. 379 // for that stream.
387 // 380 //
388 // This uses a different notion of reuse than IsReused(). This function 381 // This uses a different notion of reuse than IsReused(). This function
389 // sets |socket_reused| to false only if |stream_id| is the ID of the first 382 // sets |socket_reused| to false only if |stream_id| is the ID of the first
390 // stream using the session. IsReused(), on the other hand, indicates if the 383 // stream using the session. IsReused(), on the other hand, indicates if the
391 // session has been used to send/receive data at all. 384 // session has been used to send/receive data at all.
392 bool GetLoadTimingInfo(SpdyStreamId stream_id, 385 bool GetLoadTimingInfo(SpdyStreamId stream_id,
393 LoadTimingInfo* load_timing_info) const; 386 LoadTimingInfo* load_timing_info) const;
394 387
395 // Returns true if session is not currently active 388 // Returns true if session is not currently active
396 bool is_active() const { 389 bool is_active() const {
397 return !active_streams_.empty() || !created_streams_.empty(); 390 return !active_streams_.empty() || !created_streams_.empty();
398 } 391 }
399 392
400 // Access to the number of active and pending streams. These are primarily 393 // Access to the number of active and pending streams. These are primarily
401 // available for testing and diagnostics. 394 // available for testing and diagnostics.
402 size_t num_active_streams() const { return active_streams_.size(); } 395 size_t num_active_streams() const { return active_streams_.size(); }
403 size_t num_unclaimed_pushed_streams() const { 396 size_t num_unclaimed_pushed_streams() const {
404 return unclaimed_pushed_streams_.size(); 397 return unclaimed_pushed_streams_.size();
405 } 398 }
406 size_t num_created_streams() const { return created_streams_.size(); } 399 size_t num_created_streams() const { return created_streams_.size(); }
407 400
408 size_t pending_create_stream_queue_size(RequestPriority priority) const { 401 size_t pending_create_stream_queue_size(RequestPriority priority) const {
409 DCHECK_GE(priority, MINIMUM_PRIORITY); 402 DCHECK_GE(priority, MINIMUM_PRIORITY);
410 DCHECK_LE(priority, MAXIMUM_PRIORITY); 403 DCHECK_LE(priority, MAXIMUM_PRIORITY);
411 return pending_create_stream_queues_[priority].size(); 404 return pending_create_stream_queues_[priority].size();
412 } 405 }
413 406
414 // Returns the (version-dependent) flow control state. 407 // Returns the (version-dependent) flow control state.
415 FlowControlState flow_control_state() const { 408 FlowControlState flow_control_state() const { return flow_control_state_; }
416 return flow_control_state_;
417 }
418 409
419 // Returns the current |stream_initial_send_window_size_|. 410 // Returns the current |stream_initial_send_window_size_|.
420 int32 stream_initial_send_window_size() const { 411 int32 stream_initial_send_window_size() const {
421 return stream_initial_send_window_size_; 412 return stream_initial_send_window_size_;
422 } 413 }
423 414
424 // Returns the current |stream_initial_recv_window_size_|. 415 // Returns the current |stream_initial_recv_window_size_|.
425 int32 stream_initial_recv_window_size() const { 416 int32 stream_initial_recv_window_size() const {
426 return stream_initial_recv_window_size_; 417 return stream_initial_recv_window_size_;
427 } 418 }
428 419
429 // Returns true if no stream in the session can send data due to 420 // Returns true if no stream in the session can send data due to
430 // session flow control. 421 // session flow control.
431 bool IsSendStalled() const { 422 bool IsSendStalled() const {
432 return 423 return flow_control_state_ == FLOW_CONTROL_STREAM_AND_SESSION &&
433 flow_control_state_ == FLOW_CONTROL_STREAM_AND_SESSION && 424 session_send_window_size_ == 0;
434 session_send_window_size_ == 0;
435 } 425 }
436 426
437 const BoundNetLog& net_log() const { return net_log_; } 427 const BoundNetLog& net_log() const { return net_log_; }
438 428
439 int GetPeerAddress(IPEndPoint* address) const; 429 int GetPeerAddress(IPEndPoint* address) const;
440 int GetLocalAddress(IPEndPoint* address) const; 430 int GetLocalAddress(IPEndPoint* address) const;
441 431
442 // Adds |alias| to set of aliases associated with this session. 432 // Adds |alias| to set of aliases associated with this session.
443 void AddPooledAlias(const SpdySessionKey& alias_key); 433 void AddPooledAlias(const SpdySessionKey& alias_key);
444 434
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 // Adjust the send window size of all ActiveStreams and PendingStreamRequests. 652 // Adjust the send window size of all ActiveStreams and PendingStreamRequests.
663 void UpdateStreamsSendWindowSize(int32 delta_window_size); 653 void UpdateStreamsSendWindowSize(int32 delta_window_size);
664 654
665 // Send the PING (preface-PING) frame. 655 // Send the PING (preface-PING) frame.
666 void SendPrefacePingIfNoneInFlight(); 656 void SendPrefacePingIfNoneInFlight();
667 657
668 // Send PING if there are no PINGs in flight and we haven't heard from server. 658 // Send PING if there are no PINGs in flight and we haven't heard from server.
669 void SendPrefacePing(); 659 void SendPrefacePing();
670 660
671 // Send a single WINDOW_UPDATE frame. 661 // Send a single WINDOW_UPDATE frame.
672 void SendWindowUpdateFrame(SpdyStreamId stream_id, uint32 delta_window_size, 662 void SendWindowUpdateFrame(SpdyStreamId stream_id,
663 uint32 delta_window_size,
673 RequestPriority priority); 664 RequestPriority priority);
674 665
675 // Send the PING frame. 666 // Send the PING frame.
676 void WritePingFrame(uint32 unique_id, bool is_ack); 667 void WritePingFrame(uint32 unique_id, bool is_ack);
677 668
678 // Post a CheckPingStatus call after delay. Don't post if there is already 669 // Post a CheckPingStatus call after delay. Don't post if there is already
679 // CheckPingStatus running. 670 // CheckPingStatus running.
680 void PlanToCheckPingStatus(); 671 void PlanToCheckPingStatus();
681 672
682 // Check the status of the connection. It calls |CloseSessionOnError| if we 673 // Check the status of the connection. It calls |CloseSessionOnError| if we
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 virtual void OnGoAway(SpdyStreamId last_accepted_stream_id, 786 virtual void OnGoAway(SpdyStreamId last_accepted_stream_id,
796 SpdyGoAwayStatus status) OVERRIDE; 787 SpdyGoAwayStatus status) OVERRIDE;
797 virtual void OnDataFrameHeader(SpdyStreamId stream_id, 788 virtual void OnDataFrameHeader(SpdyStreamId stream_id,
798 size_t length, 789 size_t length,
799 bool fin) OVERRIDE; 790 bool fin) OVERRIDE;
800 virtual void OnStreamFrameData(SpdyStreamId stream_id, 791 virtual void OnStreamFrameData(SpdyStreamId stream_id,
801 const char* data, 792 const char* data,
802 size_t len, 793 size_t len,
803 bool fin) OVERRIDE; 794 bool fin) OVERRIDE;
804 virtual void OnSettings(bool clear_persisted) OVERRIDE; 795 virtual void OnSettings(bool clear_persisted) OVERRIDE;
805 virtual void OnSetting( 796 virtual void OnSetting(SpdySettingsIds id,
806 SpdySettingsIds id, uint8 flags, uint32 value) OVERRIDE; 797 uint8 flags,
798 uint32 value) OVERRIDE;
807 virtual void OnWindowUpdate(SpdyStreamId stream_id, 799 virtual void OnWindowUpdate(SpdyStreamId stream_id,
808 uint32 delta_window_size) OVERRIDE; 800 uint32 delta_window_size) OVERRIDE;
809 virtual void OnPushPromise(SpdyStreamId stream_id, 801 virtual void OnPushPromise(SpdyStreamId stream_id,
810 SpdyStreamId promised_stream_id) OVERRIDE; 802 SpdyStreamId promised_stream_id) OVERRIDE;
811 virtual void OnSynStream(SpdyStreamId stream_id, 803 virtual void OnSynStream(SpdyStreamId stream_id,
812 SpdyStreamId associated_stream_id, 804 SpdyStreamId associated_stream_id,
813 SpdyPriority priority, 805 SpdyPriority priority,
814 bool fin, 806 bool fin,
815 bool unidirectional, 807 bool unidirectional,
816 const SpdyHeaderBlock& headers) OVERRIDE; 808 const SpdyHeaderBlock& headers) OVERRIDE;
817 virtual void OnSynReply( 809 virtual void OnSynReply(SpdyStreamId stream_id,
818 SpdyStreamId stream_id, 810 bool fin,
819 bool fin, 811 const SpdyHeaderBlock& headers) OVERRIDE;
820 const SpdyHeaderBlock& headers) OVERRIDE; 812 virtual void OnHeaders(SpdyStreamId stream_id,
821 virtual void OnHeaders( 813 bool fin,
822 SpdyStreamId stream_id, 814 const SpdyHeaderBlock& headers) OVERRIDE;
823 bool fin,
824 const SpdyHeaderBlock& headers) OVERRIDE;
825 815
826 // SpdyFramerDebugVisitorInterface 816 // SpdyFramerDebugVisitorInterface
827 virtual void OnSendCompressedFrame( 817 virtual void OnSendCompressedFrame(SpdyStreamId stream_id,
828 SpdyStreamId stream_id, 818 SpdyFrameType type,
829 SpdyFrameType type, 819 size_t payload_len,
830 size_t payload_len, 820 size_t frame_len) OVERRIDE;
831 size_t frame_len) OVERRIDE; 821 virtual void OnReceiveCompressedFrame(SpdyStreamId stream_id,
832 virtual void OnReceiveCompressedFrame( 822 SpdyFrameType type,
833 SpdyStreamId stream_id, 823 size_t frame_len) OVERRIDE;
834 SpdyFrameType type,
835 size_t frame_len) OVERRIDE;
836 824
837 // Called when bytes are consumed from a SpdyBuffer for a DATA frame 825 // Called when bytes are consumed from a SpdyBuffer for a DATA frame
838 // that is to be written or is being written. Increases the send 826 // that is to be written or is being written. Increases the send
839 // window size accordingly if some or all of the SpdyBuffer is being 827 // window size accordingly if some or all of the SpdyBuffer is being
840 // discarded. 828 // discarded.
841 // 829 //
842 // If session flow control is turned off, this must not be called. 830 // If session flow control is turned off, this must not be called.
843 void OnWriteBufferConsumed(size_t frame_payload_size, 831 void OnWriteBufferConsumed(size_t frame_payload_size,
844 size_t consume_size, 832 size_t consume_size,
845 SpdyBuffer::ConsumeSource consume_source); 833 SpdyBuffer::ConsumeSource consume_source);
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
1124 // This SPDY proxy is allowed to push resources from origins that are 1112 // This SPDY proxy is allowed to push resources from origins that are
1125 // different from those of their associated streams. 1113 // different from those of their associated streams.
1126 HostPortPair trusted_spdy_proxy_; 1114 HostPortPair trusted_spdy_proxy_;
1127 1115
1128 TimeFunc time_func_; 1116 TimeFunc time_func_;
1129 }; 1117 };
1130 1118
1131 } // namespace net 1119 } // namespace net
1132 1120
1133 #endif // NET_SPDY_SPDY_SESSION_H_ 1121 #endif // NET_SPDY_SPDY_SESSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698