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_STREAM_H_ | 5 #ifndef NET_SPDY_SPDY_STREAM_H_ |
6 #define NET_SPDY_SPDY_STREAM_H_ | 6 #define NET_SPDY_SPDY_STREAM_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/memory/weak_ptr.h" |
15 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
16 #include "net/base/bandwidth_metrics.h" | 17 #include "net/base/bandwidth_metrics.h" |
17 #include "net/base/io_buffer.h" | 18 #include "net/base/io_buffer.h" |
18 #include "net/base/net_export.h" | 19 #include "net/base/net_export.h" |
19 #include "net/base/net_log.h" | 20 #include "net/base/net_log.h" |
20 #include "net/base/request_priority.h" | 21 #include "net/base/request_priority.h" |
21 #include "net/socket/ssl_client_socket.h" | 22 #include "net/socket/ssl_client_socket.h" |
22 #include "net/spdy/spdy_framer.h" | 23 #include "net/spdy/spdy_framer.h" |
23 #include "net/spdy/spdy_header_block.h" | 24 #include "net/spdy/spdy_header_block.h" |
24 #include "net/spdy/spdy_protocol.h" | 25 #include "net/spdy/spdy_protocol.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 typedef struct { | 106 typedef struct { |
106 FrameType type; | 107 FrameType type; |
107 union { | 108 union { |
108 SpdyHeaderBlock* header_block; | 109 SpdyHeaderBlock* header_block; |
109 SpdyFrame* data_frame; | 110 SpdyFrame* data_frame; |
110 }; | 111 }; |
111 } PendingFrame; | 112 } PendingFrame; |
112 | 113 |
113 // SpdyStream constructor | 114 // SpdyStream constructor |
114 SpdyStream(SpdySession* session, | 115 SpdyStream(SpdySession* session, |
| 116 const std::string& path, |
| 117 RequestPriority priority, |
| 118 int32 initial_send_window_size, |
| 119 int32 initial_recv_window_size, |
115 bool pushed, | 120 bool pushed, |
116 const BoundNetLog& net_log); | 121 const BoundNetLog& net_log); |
117 | 122 |
118 // Set new |delegate|. |delegate| must not be NULL. | 123 // Set new |delegate|. |delegate| must not be NULL. |
119 // If it already received SYN_REPLY or data, OnResponseReceived() or | 124 // If it already received SYN_REPLY or data, OnResponseReceived() or |
120 // OnDataReceived() will be called. | 125 // OnDataReceived() will be called. |
121 void SetDelegate(Delegate* delegate); | 126 void SetDelegate(Delegate* delegate); |
122 Delegate* GetDelegate() { return delegate_; } | 127 Delegate* GetDelegate() { return delegate_; } |
123 | 128 |
124 // Detach delegate from the stream. It will cancel the stream if it was not | 129 // Detach delegate from the stream. It will cancel the stream if it was not |
125 // cancelled yet. It is safe to call multiple times. | 130 // cancelled yet. It is safe to call multiple times. |
126 void DetachDelegate(); | 131 void DetachDelegate(); |
127 | 132 |
128 // Is this stream a pushed stream from the server. | 133 // Is this stream a pushed stream from the server. |
129 bool pushed() const { return pushed_; } | 134 bool pushed() const { return pushed_; } |
130 | 135 |
131 SpdyStreamId stream_id() const { return stream_id_; } | 136 SpdyStreamId stream_id() const { return stream_id_; } |
132 void set_stream_id(SpdyStreamId stream_id) { stream_id_ = stream_id; } | 137 void set_stream_id(SpdyStreamId stream_id) { stream_id_ = stream_id; } |
133 | 138 |
134 bool response_received() const { return response_received_; } | 139 bool response_received() const { return response_received_; } |
135 void set_response_received() { response_received_ = true; } | 140 void set_response_received() { response_received_ = true; } |
136 | 141 |
137 // For pushed streams, we track a path to identify them. | 142 // For pushed streams, we track a path to identify them. |
138 const std::string& path() const { return path_; } | 143 const std::string& path() const { return path_; } |
139 void set_path(const std::string& path) { path_ = path; } | |
140 | 144 |
141 RequestPriority priority() const { return priority_; } | 145 RequestPriority priority() const { return priority_; } |
142 void set_priority(RequestPriority priority) { priority_ = priority; } | |
143 | 146 |
144 int32 send_window_size() const { return send_window_size_; } | 147 int32 send_window_size() const { return send_window_size_; } |
145 void set_send_window_size(int32 window_size) { | |
146 send_window_size_ = window_size; | |
147 } | |
148 | 148 |
149 int32 recv_window_size() const { return recv_window_size_; } | 149 int32 recv_window_size() const { return recv_window_size_; } |
150 void set_recv_window_size(int32 window_size) { | |
151 recv_window_size_ = window_size; | |
152 } | |
153 | 150 |
154 bool send_stalled_by_flow_control() { return send_stalled_by_flow_control_; } | 151 bool send_stalled_by_flow_control() { return send_stalled_by_flow_control_; } |
155 | 152 |
156 void set_send_stalled_by_flow_control(bool stalled) { | 153 void set_send_stalled_by_flow_control(bool stalled) { |
157 send_stalled_by_flow_control_ = stalled; | 154 send_stalled_by_flow_control_ = stalled; |
158 } | 155 } |
159 | 156 |
160 // If stream flow control is turned on, called by the session to | 157 // If stream flow control is turned on, called by the session to |
161 // adjust this stream's send window size by |delta_window_size|, | 158 // adjust this stream's send window size by |delta_window_size|, |
162 // which is the difference between the SETTINGS_INITIAL_WINDOW_SIZE | 159 // which is the difference between the SETTINGS_INITIAL_WINDOW_SIZE |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 // stream has become stalled on flow control. | 354 // stream has become stalled on flow control. |
358 scoped_ptr<SpdyFrame> ProduceNextFrame(); | 355 scoped_ptr<SpdyFrame> ProduceNextFrame(); |
359 | 356 |
360 // If the stream is active and stream flow control is turned on, | 357 // If the stream is active and stream flow control is turned on, |
361 // called by OnDataReceived (which is in turn called by the session) | 358 // called by OnDataReceived (which is in turn called by the session) |
362 // to decrease this stream's receive window size by | 359 // to decrease this stream's receive window size by |
363 // |delta_window_size|, which must be at least 1 and must not cause | 360 // |delta_window_size|, which must be at least 1 and must not cause |
364 // this stream's receive window size to go negative. | 361 // this stream's receive window size to go negative. |
365 void DecreaseRecvWindowSize(int32 delta_window_size); | 362 void DecreaseRecvWindowSize(int32 delta_window_size); |
366 | 363 |
| 364 base::WeakPtrFactory<SpdyStream> weak_ptr_factory_; |
| 365 |
367 // There is a small period of time between when a server pushed stream is | 366 // There is a small period of time between when a server pushed stream is |
368 // first created, and the pushed data is replayed. Any data received during | 367 // first created, and the pushed data is replayed. Any data received during |
369 // this time should continue to be buffered. | 368 // this time should continue to be buffered. |
370 bool continue_buffering_data_; | 369 bool continue_buffering_data_; |
371 | 370 |
372 SpdyStreamId stream_id_; | 371 SpdyStreamId stream_id_; |
373 std::string path_; | 372 const std::string path_; |
374 RequestPriority priority_; | 373 const RequestPriority priority_; |
375 size_t slot_; | 374 size_t slot_; |
376 | 375 |
377 // Flow control variables. | 376 // Flow control variables. |
378 bool send_stalled_by_flow_control_; | 377 bool send_stalled_by_flow_control_; |
379 int32 send_window_size_; | 378 int32 send_window_size_; |
380 int32 recv_window_size_; | 379 int32 recv_window_size_; |
381 int32 unacked_recv_window_bytes_; | 380 int32 unacked_recv_window_bytes_; |
382 | 381 |
383 const bool pushed_; | 382 const bool pushed_; |
384 ScopedBandwidthMetrics metrics_; | 383 ScopedBandwidthMetrics metrics_; |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 std::string domain_bound_private_key_; | 430 std::string domain_bound_private_key_; |
432 std::string domain_bound_cert_; | 431 std::string domain_bound_cert_; |
433 ServerBoundCertService::RequestHandle domain_bound_cert_request_handle_; | 432 ServerBoundCertService::RequestHandle domain_bound_cert_request_handle_; |
434 | 433 |
435 DISALLOW_COPY_AND_ASSIGN(SpdyStream); | 434 DISALLOW_COPY_AND_ASSIGN(SpdyStream); |
436 }; | 435 }; |
437 | 436 |
438 } // namespace net | 437 } // namespace net |
439 | 438 |
440 #endif // NET_SPDY_SPDY_STREAM_H_ | 439 #endif // NET_SPDY_SPDY_STREAM_H_ |
OLD | NEW |