OLD | NEW |
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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 // which point ReleaseStream() may be called. Otherwise, the stream | 126 // which point ReleaseStream() may be called. Otherwise, the stream |
127 // is not created, an error is returned, and ReleaseStream() may not | 127 // is not created, an error is returned, and ReleaseStream() may not |
128 // be called. | 128 // be called. |
129 // | 129 // |
130 // If OK is returned, must not be called again without | 130 // If OK is returned, must not be called again without |
131 // ReleaseStream() being called first. If ERR_IO_PENDING is | 131 // ReleaseStream() being called first. If ERR_IO_PENDING is |
132 // returned, must not be called again without CancelRequest() or | 132 // returned, must not be called again without CancelRequest() or |
133 // ReleaseStream() being called first. Otherwise, in case of an | 133 // ReleaseStream() being called first. Otherwise, in case of an |
134 // immediate error, this may be called again. | 134 // immediate error, this may be called again. |
135 int StartRequest(SpdyStreamType type, | 135 int StartRequest(SpdyStreamType type, |
136 const scoped_refptr<SpdySession>& session, | 136 const base::WeakPtr<SpdySession>& session, |
137 const GURL& url, | 137 const GURL& url, |
138 RequestPriority priority, | 138 RequestPriority priority, |
139 const BoundNetLog& net_log, | 139 const BoundNetLog& net_log, |
140 const CompletionCallback& callback); | 140 const CompletionCallback& callback); |
141 | 141 |
142 // Cancels any pending stream creation request. May be called | 142 // Cancels any pending stream creation request. May be called |
143 // repeatedly. | 143 // repeatedly. |
144 void CancelRequest(); | 144 void CancelRequest(); |
145 | 145 |
146 // Transfers the created stream (guaranteed to not be NULL) to the | 146 // Transfers the created stream (guaranteed to not be NULL) to the |
(...skipping 16 matching lines...) Expand all Loading... |
163 | 163 |
164 // Accessors called by |session_|. | 164 // Accessors called by |session_|. |
165 SpdyStreamType type() const { return type_; } | 165 SpdyStreamType type() const { return type_; } |
166 const GURL& url() const { return url_; } | 166 const GURL& url() const { return url_; } |
167 RequestPriority priority() const { return priority_; } | 167 RequestPriority priority() const { return priority_; } |
168 const BoundNetLog& net_log() const { return net_log_; } | 168 const BoundNetLog& net_log() const { return net_log_; } |
169 | 169 |
170 void Reset(); | 170 void Reset(); |
171 | 171 |
172 SpdyStreamType type_; | 172 SpdyStreamType type_; |
173 scoped_refptr<SpdySession> session_; | 173 base::WeakPtr<SpdySession> session_; |
174 base::WeakPtr<SpdyStream> stream_; | 174 base::WeakPtr<SpdyStream> stream_; |
175 GURL url_; | 175 GURL url_; |
176 RequestPriority priority_; | 176 RequestPriority priority_; |
177 BoundNetLog net_log_; | 177 BoundNetLog net_log_; |
178 CompletionCallback callback_; | 178 CompletionCallback callback_; |
179 | 179 |
180 DISALLOW_COPY_AND_ASSIGN(SpdyStreamRequest); | 180 DISALLOW_COPY_AND_ASSIGN(SpdyStreamRequest); |
181 }; | 181 }; |
182 | 182 |
183 class NET_EXPORT SpdySession : public base::RefCounted<SpdySession>, | 183 class NET_EXPORT SpdySession : public base::RefCounted<SpdySession>, |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 // if server bound certs are not supported in this session. | 337 // if server bound certs are not supported in this session. |
338 ServerBoundCertService* GetServerBoundCertService() const; | 338 ServerBoundCertService* GetServerBoundCertService() const; |
339 | 339 |
340 // Send a WINDOW_UPDATE frame for a stream. Called by a stream | 340 // Send a WINDOW_UPDATE frame for a stream. Called by a stream |
341 // whenever receive window size is increased. | 341 // whenever receive window size is increased. |
342 void SendStreamWindowUpdate(SpdyStreamId stream_id, | 342 void SendStreamWindowUpdate(SpdyStreamId stream_id, |
343 uint32 delta_window_size); | 343 uint32 delta_window_size); |
344 | 344 |
345 // Whether the stream is closed, i.e. it has stopped processing data | 345 // Whether the stream is closed, i.e. it has stopped processing data |
346 // and is about to be destroyed. | 346 // and is about to be destroyed. |
| 347 // |
| 348 // TODO(akalin): This is only used in tests. Remove this function |
| 349 // and have tests test the WeakPtr instead. |
347 bool IsClosed() const { return availability_state_ == STATE_CLOSED; } | 350 bool IsClosed() const { return availability_state_ == STATE_CLOSED; } |
348 | 351 |
349 // Closes this session. This will close all active streams and mark | 352 // Closes this session. This will close all active streams and mark |
350 // the session as permanently closed. Callers must assume that the | 353 // the session as permanently closed. Callers must assume that the |
351 // session is destroyed after this is called. (However, it may not | 354 // session is destroyed after this is called. (However, it may not |
352 // be destroyed right away, e.g. when a SpdySession function is | 355 // be destroyed right away, e.g. when a SpdySession function is |
353 // present in the call stack.) | 356 // present in the call stack.) |
354 // | 357 // |
355 // |err| should be < ERR_IO_PENDING; this function is intended to be | 358 // |err| should be < ERR_IO_PENDING; this function is intended to be |
356 // called on error. | 359 // called on error. |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
456 } | 459 } |
457 | 460 |
458 size_t GetFrameMaximumSize() const { | 461 size_t GetFrameMaximumSize() const { |
459 return buffered_spdy_framer_->GetFrameMaximumSize(); | 462 return buffered_spdy_framer_->GetFrameMaximumSize(); |
460 } | 463 } |
461 | 464 |
462 size_t GetDataFrameMaximumPayload() const { | 465 size_t GetDataFrameMaximumPayload() const { |
463 return buffered_spdy_framer_->GetDataFrameMaximumPayload(); | 466 return buffered_spdy_framer_->GetDataFrameMaximumPayload(); |
464 } | 467 } |
465 | 468 |
| 469 // Must be used only by |pool_|. |
| 470 base::WeakPtr<SpdySession> GetWeakPtr(); |
| 471 |
466 // LayeredPool implementation: | 472 // LayeredPool implementation: |
467 virtual bool CloseOneIdleConnection() OVERRIDE; | 473 virtual bool CloseOneIdleConnection() OVERRIDE; |
468 | 474 |
469 private: | 475 private: |
470 friend class base::RefCounted<SpdySession>; | 476 friend class base::RefCounted<SpdySession>; |
471 friend class SpdyStreamRequest; | 477 friend class SpdyStreamRequest; |
472 friend class SpdySessionTest; | 478 friend class SpdySessionTest; |
473 | 479 |
474 // Allow tests to access our innards for testing purposes. | 480 // Allow tests to access our innards for testing purposes. |
475 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, ClientPing); | 481 FRIEND_TEST_ALL_PREFIXES(SpdySessionTest, ClientPing); |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1102 // This SPDY proxy is allowed to push resources from origins that are | 1108 // This SPDY proxy is allowed to push resources from origins that are |
1103 // different from those of their associated streams. | 1109 // different from those of their associated streams. |
1104 HostPortPair trusted_spdy_proxy_; | 1110 HostPortPair trusted_spdy_proxy_; |
1105 | 1111 |
1106 TimeFunc time_func_; | 1112 TimeFunc time_func_; |
1107 }; | 1113 }; |
1108 | 1114 |
1109 } // namespace net | 1115 } // namespace net |
1110 | 1116 |
1111 #endif // NET_SPDY_SPDY_SESSION_H_ | 1117 #endif // NET_SPDY_SPDY_SESSION_H_ |
OLD | NEW |