| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 COMPONENTS_CRONET_IOS_CRONET_BIDIRECTIONAL_STREAM_H_ | 5 #ifndef COMPONENTS_CRONET_IOS_CRONET_BIDIRECTIONAL_STREAM_H_ |
| 6 #define COMPONENTS_CRONET_IOS_CRONET_BIDIRECTIONAL_STREAM_H_ | 6 #define COMPONENTS_CRONET_IOS_CRONET_BIDIRECTIONAL_STREAM_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 // Destroy can be called on any thread (including network thread), and post | 26 // Destroy can be called on any thread (including network thread), and post |
| 27 // calls to corresponding {Start|ReadData|WriteData|Destroy}OnNetworkThread to | 27 // calls to corresponding {Start|ReadData|WriteData|Destroy}OnNetworkThread to |
| 28 // the network thread. The object is always deleted on network thread. All | 28 // the network thread. The object is always deleted on network thread. All |
| 29 // callbacks into the Delegate are done on the network thread. | 29 // callbacks into the Delegate are done on the network thread. |
| 30 // The app is expected to initiate the next step like ReadData or Destroy. | 30 // The app is expected to initiate the next step like ReadData or Destroy. |
| 31 // Public methods can be called on any thread. | 31 // Public methods can be called on any thread. |
| 32 class CronetBidirectionalStream : public net::BidirectionalStream::Delegate { | 32 class CronetBidirectionalStream : public net::BidirectionalStream::Delegate { |
| 33 public: | 33 public: |
| 34 class Delegate { | 34 class Delegate { |
| 35 public: | 35 public: |
| 36 virtual void OnHeadersSent() = 0; | 36 virtual void OnStreamReady() = 0; |
| 37 | 37 |
| 38 virtual void OnHeadersReceived(const net::SpdyHeaderBlock& response_headers, | 38 virtual void OnHeadersReceived(const net::SpdyHeaderBlock& response_headers, |
| 39 const char* negotiated_protocol) = 0; | 39 const char* negotiated_protocol) = 0; |
| 40 | 40 |
| 41 virtual void OnDataRead(char* data, int size) = 0; | 41 virtual void OnDataRead(char* data, int size) = 0; |
| 42 | 42 |
| 43 virtual void OnDataSent(const char* data) = 0; | 43 virtual void OnDataSent(const char* data) = 0; |
| 44 | 44 |
| 45 virtual void OnTrailersReceived(const net::SpdyHeaderBlock& trailers) = 0; | 45 virtual void OnTrailersReceived(const net::SpdyHeaderBlock& trailers) = 0; |
| 46 | 46 |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 // Waiting for WriteData() to be called. | 110 // Waiting for WriteData() to be called. |
| 111 WAITING_FOR_WRITE, | 111 WAITING_FOR_WRITE, |
| 112 // Writing to the remote, callback will be invoked when done. | 112 // Writing to the remote, callback will be invoked when done. |
| 113 WRITING, | 113 WRITING, |
| 114 // There is no more data to write and stream is half-closed by the local | 114 // There is no more data to write and stream is half-closed by the local |
| 115 // side. | 115 // side. |
| 116 WRITING_DONE, | 116 WRITING_DONE, |
| 117 }; | 117 }; |
| 118 | 118 |
| 119 // net::BidirectionalStream::Delegate implementations: | 119 // net::BidirectionalStream::Delegate implementations: |
| 120 void OnHeadersSent() override; | 120 void OnStreamReady() override; |
| 121 void OnHeadersReceived(const net::SpdyHeaderBlock& response_headers) override; | 121 void OnHeadersReceived(const net::SpdyHeaderBlock& response_headers) override; |
| 122 void OnDataRead(int bytes_read) override; | 122 void OnDataRead(int bytes_read) override; |
| 123 void OnDataSent() override; | 123 void OnDataSent() override; |
| 124 void OnTrailersReceived(const net::SpdyHeaderBlock& trailers) override; | 124 void OnTrailersReceived(const net::SpdyHeaderBlock& trailers) override; |
| 125 void OnFailed(int error) override; | 125 void OnFailed(int error) override; |
| 126 // Helper method to derive OnSucceeded. | 126 // Helper method to derive OnSucceeded. |
| 127 void MaybeOnSucceded(); | 127 void MaybeOnSucceded(); |
| 128 | 128 |
| 129 void StartOnNetworkThread( | 129 void StartOnNetworkThread( |
| 130 std::unique_ptr<net::BidirectionalStreamRequestInfo> request_info); | 130 std::unique_ptr<net::BidirectionalStreamRequestInfo> request_info); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 158 scoped_refptr<net::WrappedIOBuffer> write_buffer_; | 158 scoped_refptr<net::WrappedIOBuffer> write_buffer_; |
| 159 std::unique_ptr<net::BidirectionalStream> bidi_stream_; | 159 std::unique_ptr<net::BidirectionalStream> bidi_stream_; |
| 160 Delegate* delegate_; | 160 Delegate* delegate_; |
| 161 | 161 |
| 162 DISALLOW_COPY_AND_ASSIGN(CronetBidirectionalStream); | 162 DISALLOW_COPY_AND_ASSIGN(CronetBidirectionalStream); |
| 163 }; | 163 }; |
| 164 | 164 |
| 165 } // namespace cronet | 165 } // namespace cronet |
| 166 | 166 |
| 167 #endif // COMPONENTS_CRONET_IOS_CRONET_BIDIRECTIONAL_STREAM_H_ | 167 #endif // COMPONENTS_CRONET_IOS_CRONET_BIDIRECTIONAL_STREAM_H_ |
| OLD | NEW |