| 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 <deque> | 8 #include <deque> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 | 271 |
| 272 // Close this stream without sending a RST_STREAM and delete | 272 // Close this stream without sending a RST_STREAM and delete |
| 273 // it. | 273 // it. |
| 274 void Close(); | 274 void Close(); |
| 275 | 275 |
| 276 // Returns whether or not this stream is closed. Note that the only | 276 // Returns whether or not this stream is closed. Note that the only |
| 277 // time a stream is closed and not deleted is in its delegate's | 277 // time a stream is closed and not deleted is in its delegate's |
| 278 // OnClose() method. | 278 // OnClose() method. |
| 279 bool closed() const { return io_state_ == STATE_DONE; } | 279 bool closed() const { return io_state_ == STATE_DONE; } |
| 280 | 280 |
| 281 // TODO(satorux): This is only for testing. We should be able to remove | |
| 282 // this once crbug.com/113107 is addressed. | |
| 283 bool body_sent() const { return io_state_ > STATE_SEND_BODY_COMPLETE; } | |
| 284 | |
| 285 // Interface for the delegate to use. | 281 // Interface for the delegate to use. |
| 286 | 282 |
| 287 // Only one send can be in flight at a time, except for push | 283 // Only one send can be in flight at a time, except for push |
| 288 // streams, which must not send anything. | 284 // streams, which must not send anything. |
| 289 | 285 |
| 290 // Sends the request headers. The delegate is called back via | 286 // Sends the request headers. The delegate is called back via |
| 291 // OnRequestHeadersSent() when the request headers have completed | 287 // OnRequestHeadersSent() when the request headers have completed |
| 292 // sending. |send_status| must be MORE_DATA_TO_SEND for | 288 // sending. |send_status| must be MORE_DATA_TO_SEND for |
| 293 // bidirectional streams; for request/response streams, it must be | 289 // bidirectional streams; for request/response streams, it must be |
| 294 // MORE_DATA_TO_SEND if the request has data to upload, or | 290 // MORE_DATA_TO_SEND if the request has data to upload, or |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 class HeaderBufferProducer; | 338 class HeaderBufferProducer; |
| 343 | 339 |
| 344 enum State { | 340 enum State { |
| 345 STATE_NONE, | 341 STATE_NONE, |
| 346 STATE_GET_DOMAIN_BOUND_CERT, | 342 STATE_GET_DOMAIN_BOUND_CERT, |
| 347 STATE_GET_DOMAIN_BOUND_CERT_COMPLETE, | 343 STATE_GET_DOMAIN_BOUND_CERT_COMPLETE, |
| 348 STATE_SEND_DOMAIN_BOUND_CERT, | 344 STATE_SEND_DOMAIN_BOUND_CERT, |
| 349 STATE_SEND_DOMAIN_BOUND_CERT_COMPLETE, | 345 STATE_SEND_DOMAIN_BOUND_CERT_COMPLETE, |
| 350 STATE_SEND_REQUEST_HEADERS, | 346 STATE_SEND_REQUEST_HEADERS, |
| 351 STATE_SEND_REQUEST_HEADERS_COMPLETE, | 347 STATE_SEND_REQUEST_HEADERS_COMPLETE, |
| 352 STATE_SEND_BODY, | |
| 353 STATE_SEND_BODY_COMPLETE, | |
| 354 STATE_WAITING_FOR_RESPONSE, | |
| 355 STATE_OPEN, | 348 STATE_OPEN, |
| 356 STATE_DONE | 349 STATE_DONE |
| 357 }; | 350 }; |
| 358 | 351 |
| 359 void OnGetDomainBoundCertComplete(int result); | 352 void OnGetDomainBoundCertComplete(int result); |
| 360 | 353 |
| 361 // Try to make progress sending/receiving the request/response. | 354 // Try to make progress sending/receiving the request/response. |
| 362 int DoLoop(int result); | 355 int DoLoop(int result); |
| 363 | 356 |
| 364 // The implementations of each state of the state machine. | 357 // The implementations of each state of the state machine. |
| 365 int DoGetDomainBoundCert(); | 358 int DoGetDomainBoundCert(); |
| 366 int DoGetDomainBoundCertComplete(int result); | 359 int DoGetDomainBoundCertComplete(int result); |
| 367 int DoSendDomainBoundCert(); | 360 int DoSendDomainBoundCert(); |
| 368 int DoSendDomainBoundCertComplete(int result); | 361 int DoSendDomainBoundCertComplete(int result); |
| 369 int DoSendRequestHeaders(); | 362 int DoSendRequestHeaders(); |
| 370 int DoSendRequestHeadersComplete(); | 363 int DoSendRequestHeadersComplete(); |
| 371 int DoSendBody(); | |
| 372 int DoSendBodyComplete(int result); | |
| 373 int DoReadHeaders(); | 364 int DoReadHeaders(); |
| 374 int DoReadHeadersComplete(int result); | 365 int DoReadHeadersComplete(int result); |
| 375 int DoOpen(); | 366 int DoOpen(); |
| 376 | 367 |
| 377 // Does the bookkeeping necessary after a frame has just been | |
| 378 // sent. If there's more data to be sent, |state_| is set to | |
| 379 // |io_pending_state|, the next frame is queued up, and | |
| 380 // ERR_IO_PENDING is returned. Otherwise, returns OK if successful | |
| 381 // or an error if not. | |
| 382 int ProcessJustCompletedFrame(int result, State io_pending_state); | |
| 383 | |
| 384 // Update the histograms. Can safely be called repeatedly, but should only | 368 // Update the histograms. Can safely be called repeatedly, but should only |
| 385 // be called after the stream has completed. | 369 // be called after the stream has completed. |
| 386 void UpdateHistograms(); | 370 void UpdateHistograms(); |
| 387 | 371 |
| 388 // When a server pushed stream is first created, this function is posted on | 372 // When a server pushed stream is first created, this function is posted on |
| 389 // the MessageLoop to replay all the data that the server has already sent. | 373 // the MessageLoop to replay all the data that the server has already sent. |
| 390 void PushedStreamReplayData(); | 374 void PushedStreamReplayData(); |
| 391 | 375 |
| 392 // Produces the SYN_STREAM frame for the stream. The stream must | 376 // Produces the SYN_STREAM frame for the stream. The stream must |
| 393 // already be activated. | 377 // already be activated. |
| 394 scoped_ptr<SpdyFrame> ProduceSynStreamFrame(); | 378 scoped_ptr<SpdyFrame> ProduceSynStreamFrame(); |
| 395 | 379 |
| 396 // Produce the initial HEADER frame for the stream with the given | 380 // Produce the initial HEADER frame for the stream with the given |
| 397 // block. The stream must already be activated. | 381 // block. The stream must already be activated. |
| 398 scoped_ptr<SpdyFrame> ProduceHeaderFrame( | 382 scoped_ptr<SpdyFrame> ProduceHeaderFrame( |
| 399 scoped_ptr<SpdyHeaderBlock> header_block); | 383 scoped_ptr<SpdyHeaderBlock> header_block); |
| 400 | 384 |
| 401 // Queues the send for next frame of the remaining data in | 385 // Queues the send for next frame of the remaining data in |
| 402 // |pending_send_data_|. Must be called only when | 386 // |pending_send_data_|. Must be called only when |
| 403 // |pending_send_data_| and |pending_send_flags_| are set. | 387 // |pending_send_data_| is set. |
| 404 void QueueNextDataFrame(); | 388 void QueueNextDataFrame(); |
| 405 | 389 |
| 406 const SpdyStreamType type_; | 390 const SpdyStreamType type_; |
| 407 | 391 |
| 408 base::WeakPtrFactory<SpdyStream> weak_ptr_factory_; | 392 base::WeakPtrFactory<SpdyStream> weak_ptr_factory_; |
| 409 | 393 |
| 410 // Sentinel variable used to make sure we don't get destroyed by a | 394 // Sentinel variable used to make sure we don't get destroyed by a |
| 411 // function called from DoLoop(). | 395 // function called from DoLoop(). |
| 412 bool in_do_loop_; | 396 bool in_do_loop_; |
| 413 | 397 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 // When OnFrameWriteComplete() is called, these variables are set. | 466 // When OnFrameWriteComplete() is called, these variables are set. |
| 483 SpdyFrameType just_completed_frame_type_; | 467 SpdyFrameType just_completed_frame_type_; |
| 484 size_t just_completed_frame_size_; | 468 size_t just_completed_frame_size_; |
| 485 | 469 |
| 486 DISALLOW_COPY_AND_ASSIGN(SpdyStream); | 470 DISALLOW_COPY_AND_ASSIGN(SpdyStream); |
| 487 }; | 471 }; |
| 488 | 472 |
| 489 } // namespace net | 473 } // namespace net |
| 490 | 474 |
| 491 #endif // NET_SPDY_SPDY_STREAM_H_ | 475 #endif // NET_SPDY_SPDY_STREAM_H_ |
| OLD | NEW |