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

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

Issue 15740018: [SPDY] Change SpdyStream::QueueStreamData() To SendStreamData() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 7 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
« no previous file with comments | « net/spdy/spdy_session_spdy3_unittest.cc ('k') | net/spdy/spdy_stream.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_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 <deque> 8 #include <deque>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 // a SpdyNetworkTransaction) will maintain a reference to the stream. When 49 // a SpdyNetworkTransaction) will maintain a reference to the stream. When
50 // initiated by the server, only the SpdySession will maintain any reference, 50 // initiated by the server, only the SpdySession will maintain any reference,
51 // until such a time as a client object requests a stream for the path. 51 // until such a time as a client object requests a stream for the path.
52 class NET_EXPORT_PRIVATE SpdyStream { 52 class NET_EXPORT_PRIVATE SpdyStream {
53 public: 53 public:
54 // Delegate handles protocol specific behavior of spdy stream. 54 // Delegate handles protocol specific behavior of spdy stream.
55 class NET_EXPORT_PRIVATE Delegate { 55 class NET_EXPORT_PRIVATE Delegate {
56 public: 56 public:
57 Delegate() {} 57 Delegate() {}
58 58
59 // Called when SYN frame has been sent. 59 // Called when SYN frame has been sent. Must return whether
60 // Returns true if no more data to be sent after SYN frame. 60 // there's body data to send.
61 virtual SpdySendStatus OnSendHeadersComplete() = 0; 61 virtual SpdySendStatus OnSendHeadersComplete() = 0;
62 62
63 // Called when the stream is ready to send body data. The 63 // Called when the stream is ready to send body data. The
64 // delegate must call QueueStreamData() on the stream, either 64 // delegate must call SendStreamData() on the stream, either
65 // immediately or asynchronously (e.g., if the data to be send has 65 // immediately or asynchronously (e.g., if the data to be send has
66 // to be read asynchronously). 66 // to be read asynchronously).
67 // 67 //
68 // Called only when OnSendHeadersComplete() or 68 // Called only when OnSendHeadersComplete() or
69 // OnSendBodyComplete() returns MORE_DATA_TO_SEND. 69 // OnSendBodyComplete() returns MORE_DATA_TO_SEND.
70 virtual void OnSendBody() = 0; 70 virtual void OnSendBody() = 0;
71 71
72 // Called when body data has been sent. |bytes_sent| is the number 72 // Called when body data has been sent. Must return whether
73 // of bytes that has been sent (may be zero). Must return whether
74 // there's more body data to send. 73 // there's more body data to send.
75 virtual SpdySendStatus OnSendBodyComplete(size_t bytes_sent) = 0; 74 virtual SpdySendStatus OnSendBodyComplete() = 0;
76 75
77 // Called when the SYN_STREAM, SYN_REPLY, or HEADERS frames are received. 76 // Called when the SYN_STREAM, SYN_REPLY, or HEADERS frames are received.
78 // Normal streams will receive a SYN_REPLY and optional HEADERS frames. 77 // Normal streams will receive a SYN_REPLY and optional HEADERS frames.
79 // Pushed streams will receive a SYN_STREAM and optional HEADERS frames. 78 // Pushed streams will receive a SYN_STREAM and optional HEADERS frames.
80 // Because a stream may have a SYN_* frame and multiple HEADERS frames, 79 // Because a stream may have a SYN_* frame and multiple HEADERS frames,
81 // this callback may be called multiple times. 80 // this callback may be called multiple times.
82 // |status| indicates network error. Returns network error code. 81 // |status| indicates network error. Returns network error code.
83 virtual int OnResponseReceived(const SpdyHeaderBlock& response, 82 virtual int OnResponseReceived(const SpdyHeaderBlock& response,
84 base::Time response_time, 83 base::Time response_time,
85 int status) = 0; 84 int status) = 0;
86 85
87 // Called when a HEADERS frame is sent. 86 // Called when a HEADERS frame is sent.
88 virtual void OnHeadersSent() = 0; 87 virtual void OnHeadersSent() = 0;
89 88
90 // Called when data is received. |buffer| may be NULL, which 89 // Called when data is received. |buffer| may be NULL, which
91 // signals EOF. Must return OK if the data was received 90 // signals EOF. Must return OK if the data was received
92 // successfully, or a network error code otherwise. 91 // successfully, or a network error code otherwise.
93 virtual int OnDataReceived(scoped_ptr<SpdyBuffer> buffer) = 0; 92 virtual int OnDataReceived(scoped_ptr<SpdyBuffer> buffer) = 0;
94 93
95 // Called when data is sent. 94 // Called when data is sent.
96 virtual void OnDataSent(size_t bytes_sent) = 0; 95 virtual void OnDataSent() = 0;
97 96
98 // Called when SpdyStream is closed. No other delegate functions 97 // Called when SpdyStream is closed. No other delegate functions
99 // will be called after this is called, and the delegate must not 98 // will be called after this is called, and the delegate must not
100 // access the stream after this is called. 99 // access the stream after this is called.
101 virtual void OnClose(int status) = 0; 100 virtual void OnClose(int status) = 0;
102 101
103 protected: 102 protected:
104 virtual ~Delegate() {} 103 virtual ~Delegate() {}
105 104
106 private: 105 private:
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 280
282 // Returns whether or not this stream is closed. Note that the only 281 // Returns whether or not this stream is closed. Note that the only
283 // time a stream is closed and not deleted is in its delegate's 282 // time a stream is closed and not deleted is in its delegate's
284 // OnClose() method. 283 // OnClose() method.
285 bool closed() const { return io_state_ == STATE_DONE; } 284 bool closed() const { return io_state_ == STATE_DONE; }
286 285
287 // TODO(satorux): This is only for testing. We should be able to remove 286 // TODO(satorux): This is only for testing. We should be able to remove
288 // this once crbug.com/113107 is addressed. 287 // this once crbug.com/113107 is addressed.
289 bool body_sent() const { return io_state_ > STATE_SEND_BODY_COMPLETE; } 288 bool body_sent() const { return io_state_ > STATE_SEND_BODY_COMPLETE; }
290 289
291 // Interface for Spdy[Http|WebSocket]Stream to use. 290 // Interface for the delegate to use.
291 //
292 // TODO(akalin): Mandate that only one send can be in flight at one
293 // time.
292 294
293 // Sends the request. 295 // Sends the request.
294 // For non push stream, it will send SYN_STREAM frame. 296 // For non push stream, it will send SYN_STREAM frame.
295 int SendRequest(bool has_upload_data); 297 int SendRequest(bool has_upload_data);
296 298
297 // Queues a HEADERS frame to be sent. 299 // Sends a HEADERS frame. The delegate will be notified via
298 void QueueHeaders(scoped_ptr<SpdyHeaderBlock> headers); 300 // OnHeadersSent() when the send is complete.
301 void SendHeaders(scoped_ptr<SpdyHeaderBlock> headers);
299 302
300 // Queues a DATA frame to be sent. May not queue all the data that 303 // Sends a DATA frame. The delegate will be notified via
301 // is given (or even any of it) depending on flow control. 304 // OnSendBodyComplete() (if the response hasn't been received yet)
302 void QueueStreamData(IOBuffer* data, int length, 305 // or OnDataSent() (if the response has been received) when the send
303 SpdyDataFlags flags); 306 // is complete. Only one data send can be in flight at one time.
307 //
308 // |flags| must be DATA_FLAG_NONE except for the last piece of data
309 // for a request in a request/response stream, where it should be
310 // DATA_FLAG_FIN.
311 void SendStreamData(IOBuffer* data, int length, SpdyDataFlags flags);
304 312
305 // Fills SSL info in |ssl_info| and returns true when SSL is in use. 313 // Fills SSL info in |ssl_info| and returns true when SSL is in use.
306 bool GetSSLInfo(SSLInfo* ssl_info, 314 bool GetSSLInfo(SSLInfo* ssl_info,
307 bool* was_npn_negotiated, 315 bool* was_npn_negotiated,
308 NextProto* protocol_negotiated); 316 NextProto* protocol_negotiated);
309 317
310 // Fills SSL Certificate Request info |cert_request_info| and returns 318 // Fills SSL Certificate Request info |cert_request_info| and returns
311 // true when SSL is in use. 319 // true when SSL is in use.
312 bool GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info); 320 bool GetSSLCertRequestInfo(SSLCertRequestInfo* cert_request_info);
313 321
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 391
384 // Produces the SYN_STREAM frame for the stream. The stream must 392 // Produces the SYN_STREAM frame for the stream. The stream must
385 // already be activated. 393 // already be activated.
386 scoped_ptr<SpdyFrame> ProduceSynStreamFrame(); 394 scoped_ptr<SpdyFrame> ProduceSynStreamFrame();
387 395
388 // Produce the initial HEADER frame for the stream with the given 396 // Produce the initial HEADER frame for the stream with the given
389 // block. The stream must already be activated. 397 // block. The stream must already be activated.
390 scoped_ptr<SpdyFrame> ProduceHeaderFrame( 398 scoped_ptr<SpdyFrame> ProduceHeaderFrame(
391 scoped_ptr<SpdyHeaderBlock> header_block); 399 scoped_ptr<SpdyHeaderBlock> header_block);
392 400
401 // Queues the send for next frame of the remaining data in
402 // |pending_send_data_|. Must be called only when
403 // |pending_send_data_| and |pending_send_flags_| are set.
404 void QueueNextDataFrame();
405
393 base::WeakPtrFactory<SpdyStream> weak_ptr_factory_; 406 base::WeakPtrFactory<SpdyStream> weak_ptr_factory_;
394 407
395 // Sentinel variable used to make sure we don't get destroyed by a 408 // Sentinel variable used to make sure we don't get destroyed by a
396 // function called from DoLoop(). 409 // function called from DoLoop().
397 bool in_do_loop_; 410 bool in_do_loop_;
398 411
399 // There is a small period of time between when a server pushed stream is 412 // There is a small period of time between when a server pushed stream is
400 // first created, and the pushed data is replayed. Any data received during 413 // first created, and the pushed data is replayed. Any data received during
401 // this time should continue to be buffered. 414 // this time should continue to be buffered.
402 bool continue_buffering_data_; 415 bool continue_buffering_data_;
(...skipping 14 matching lines...) Expand all
417 bool response_received_; 430 bool response_received_;
418 431
419 scoped_refptr<SpdySession> session_; 432 scoped_refptr<SpdySession> session_;
420 433
421 // The transaction should own the delegate. 434 // The transaction should own the delegate.
422 SpdyStream::Delegate* delegate_; 435 SpdyStream::Delegate* delegate_;
423 436
424 // The request to send. 437 // The request to send.
425 scoped_ptr<SpdyHeaderBlock> request_; 438 scoped_ptr<SpdyHeaderBlock> request_;
426 439
440 // The data waiting to be sent.
441 scoped_refptr<DrainableIOBuffer> pending_send_data_;
442 SpdyDataFlags pending_send_flags_;
443
427 // The time at which the request was made that resulted in this response. 444 // The time at which the request was made that resulted in this response.
428 // For cached responses, this time could be "far" in the past. 445 // For cached responses, this time could be "far" in the past.
429 base::Time request_time_; 446 base::Time request_time_;
430 447
431 scoped_ptr<SpdyHeaderBlock> response_; 448 scoped_ptr<SpdyHeaderBlock> response_;
432 base::Time response_time_; 449 base::Time response_time_;
433 450
434 State io_state_; 451 State io_state_;
435 452
436 // Since we buffer the response, we also buffer the response status. 453 // Since we buffer the response, we also buffer the response status.
(...skipping 24 matching lines...) Expand all
461 // When OnFrameWriteComplete() is called, these variables are set. 478 // When OnFrameWriteComplete() is called, these variables are set.
462 SpdyFrameType just_completed_frame_type_; 479 SpdyFrameType just_completed_frame_type_;
463 size_t just_completed_frame_size_; 480 size_t just_completed_frame_size_;
464 481
465 DISALLOW_COPY_AND_ASSIGN(SpdyStream); 482 DISALLOW_COPY_AND_ASSIGN(SpdyStream);
466 }; 483 };
467 484
468 } // namespace net 485 } // namespace net
469 486
470 #endif // NET_SPDY_SPDY_STREAM_H_ 487 #endif // NET_SPDY_SPDY_STREAM_H_
OLDNEW
« no previous file with comments | « net/spdy/spdy_session_spdy3_unittest.cc ('k') | net/spdy/spdy_stream.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698