Chromium Code Reviews| 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_QUIC_CHROMIUM_QUIC_HTTP_STREAM_H_ | 5 #ifndef NET_QUIC_CHROMIUM_QUIC_HTTP_STREAM_H_ |
| 6 #define NET_QUIC_CHROMIUM_QUIC_HTTP_STREAM_H_ | 6 #define NET_QUIC_CHROMIUM_QUIC_HTTP_STREAM_H_ |
| 7 | 7 |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 namespace net { | 29 namespace net { |
| 30 | 30 |
| 31 namespace test { | 31 namespace test { |
| 32 class QuicHttpStreamPeer; | 32 class QuicHttpStreamPeer; |
| 33 } // namespace test | 33 } // namespace test |
| 34 | 34 |
| 35 // The QuicHttpStream is a QUIC-specific HttpStream subclass. It holds a | 35 // The QuicHttpStream is a QUIC-specific HttpStream subclass. It holds a |
| 36 // non-owning pointer to a QuicChromiumClientStream which it uses to | 36 // non-owning pointer to a QuicChromiumClientStream which it uses to |
| 37 // send and receive data. | 37 // send and receive data. |
| 38 class NET_EXPORT_PRIVATE QuicHttpStream | 38 class NET_EXPORT_PRIVATE QuicHttpStream |
| 39 : public QuicChromiumClientSession::Observer, | 39 : public QuicChromiumClientStream::Delegate, |
| 40 public QuicChromiumClientStream::Delegate, | |
| 41 public QuicClientPushPromiseIndex::Delegate, | 40 public QuicClientPushPromiseIndex::Delegate, |
| 42 public MultiplexedHttpStream { | 41 public MultiplexedHttpStream { |
| 43 public: | 42 public: |
| 44 QuicHttpStream(const base::WeakPtr<QuicChromiumClientSession>& session, | 43 QuicHttpStream(std::unique_ptr<QuicChromiumClientSession::Handle> session, |
| 45 HttpServerProperties* http_server_properties); | 44 HttpServerProperties* http_server_properties); |
| 46 | 45 |
| 47 ~QuicHttpStream() override; | 46 ~QuicHttpStream() override; |
| 48 | 47 |
| 49 // HttpStream implementation. | 48 // HttpStream implementation. |
| 50 int InitializeStream(const HttpRequestInfo* request_info, | 49 int InitializeStream(const HttpRequestInfo* request_info, |
| 51 RequestPriority priority, | 50 RequestPriority priority, |
| 52 const NetLogWithSource& net_log, | 51 const NetLogWithSource& net_log, |
| 53 const CompletionCallback& callback) override; | 52 const CompletionCallback& callback) override; |
| 54 int SendRequest(const HttpRequestHeaders& request_headers, | 53 int SendRequest(const HttpRequestHeaders& request_headers, |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 69 void PopulateNetErrorDetails(NetErrorDetails* details) override; | 68 void PopulateNetErrorDetails(NetErrorDetails* details) override; |
| 70 void SetPriority(RequestPriority priority) override; | 69 void SetPriority(RequestPriority priority) override; |
| 71 | 70 |
| 72 // QuicChromiumClientStream::Delegate implementation | 71 // QuicChromiumClientStream::Delegate implementation |
| 73 void OnHeadersAvailable(const SpdyHeaderBlock& headers, | 72 void OnHeadersAvailable(const SpdyHeaderBlock& headers, |
| 74 size_t frame_len) override; | 73 size_t frame_len) override; |
| 75 void OnDataAvailable() override; | 74 void OnDataAvailable() override; |
| 76 void OnClose() override; | 75 void OnClose() override; |
| 77 void OnError(int error) override; | 76 void OnError(int error) override; |
| 78 | 77 |
| 79 // QuicChromiumClientSession::Observer implementation | |
| 80 void OnCryptoHandshakeConfirmed() override; | |
| 81 void OnSuccessfulVersionNegotiation(const QuicVersion& version) override; | |
| 82 void OnSessionClosed(int error, bool port_migration_detected) override; | |
| 83 | |
| 84 // QuicClientPushPromiseIndex::Delegate implementation | 78 // QuicClientPushPromiseIndex::Delegate implementation |
| 85 bool CheckVary(const SpdyHeaderBlock& client_request, | 79 bool CheckVary(const SpdyHeaderBlock& client_request, |
| 86 const SpdyHeaderBlock& promise_request, | 80 const SpdyHeaderBlock& promise_request, |
| 87 const SpdyHeaderBlock& promise_response) override; | 81 const SpdyHeaderBlock& promise_response) override; |
| 88 void OnRendezvousResult(QuicSpdyStream* stream) override; | 82 void OnRendezvousResult(QuicSpdyStream* stream) override; |
| 89 | 83 |
| 90 static HttpResponseInfo::ConnectionInfo ConnectionInfoFromQuicVersion( | 84 static HttpResponseInfo::ConnectionInfo ConnectionInfoFromQuicVersion( |
| 91 QuicVersion quic_version); | 85 QuicVersion quic_version); |
| 92 | 86 |
| 93 private: | 87 private: |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 137 int GetResponseStatus(); | 131 int GetResponseStatus(); |
| 138 // Sets the result of |ComputeResponseStatus()| as the |response_status_|. | 132 // Sets the result of |ComputeResponseStatus()| as the |response_status_|. |
| 139 void SaveResponseStatus(); | 133 void SaveResponseStatus(); |
| 140 // Sets |response_status_| to |response_status| and sets | 134 // Sets |response_status_| to |response_status| and sets |
| 141 // |has_response_status_| to true. | 135 // |has_response_status_| to true. |
| 142 void SetResponseStatus(int response_status); | 136 void SetResponseStatus(int response_status); |
| 143 // Computes the correct response status based on the status of the handshake, | 137 // Computes the correct response status based on the status of the handshake, |
| 144 // |session_error|, |connection_error| and |stream_error|. | 138 // |session_error|, |connection_error| and |stream_error|. |
| 145 int ComputeResponseStatus() const; | 139 int ComputeResponseStatus() const; |
| 146 | 140 |
| 141 QuicChromiumClientSession::Handle* quic_session() { | |
| 142 return static_cast<QuicChromiumClientSession::Handle*>(session()); | |
| 143 } | |
| 144 | |
| 145 const QuicChromiumClientSession::Handle* quic_session() const { | |
|
xunjieli
2017/05/05 14:10:01
We have two versions of accessors? Can we get rid
Ryan Hamilton
2017/05/05 17:32:47
Can't get rid of either because we need the const
| |
| 146 return static_cast<const QuicChromiumClientSession::Handle*>(session()); | |
| 147 } | |
| 148 | |
| 147 State next_state_; | 149 State next_state_; |
| 148 | 150 |
| 149 base::WeakPtr<QuicChromiumClientSession> session_; | |
| 150 const QuicServerId server_id_; // The ID of the QUIC server for this stream. | |
| 151 | |
| 152 HttpServerProperties* http_server_properties_; // Unowned. | 151 HttpServerProperties* http_server_properties_; // Unowned. |
| 153 | 152 |
| 154 QuicVersion quic_version_; | |
| 155 int session_error_; // Error code from the connection shutdown. | |
| 156 bool was_handshake_confirmed_; // True if the crypto handshake succeeded. | |
| 157 std::unique_ptr<QuicChromiumClientSession::StreamRequest> stream_request_; | |
| 158 QuicChromiumClientStream* stream_; // Non-owning. | 153 QuicChromiumClientStream* stream_; // Non-owning. |
| 159 | 154 |
| 160 // The following three fields are all owned by the caller and must | 155 // The following three fields are all owned by the caller and must |
| 161 // outlive this object, according to the HttpStream contract. | 156 // outlive this object, according to the HttpStream contract. |
| 162 | 157 |
| 163 // The request to send. | 158 // The request to send. |
| 164 // Only valid before the response body is read. | 159 // Only valid before the response body is read. |
| 165 const HttpRequestInfo* request_info_; | 160 const HttpRequestInfo* request_info_; |
| 166 | 161 |
| 167 // The request body to send, if any, owned by the caller. | 162 // The request body to send, if any, owned by the caller. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 206 scoped_refptr<IOBuffer> user_buffer_; | 201 scoped_refptr<IOBuffer> user_buffer_; |
| 207 int user_buffer_len_; | 202 int user_buffer_len_; |
| 208 | 203 |
| 209 // Temporary buffer used to read the request body from UploadDataStream. | 204 // Temporary buffer used to read the request body from UploadDataStream. |
| 210 scoped_refptr<IOBufferWithSize> raw_request_body_buf_; | 205 scoped_refptr<IOBufferWithSize> raw_request_body_buf_; |
| 211 // Wraps raw_request_body_buf_ to read the remaining data progressively. | 206 // Wraps raw_request_body_buf_ to read the remaining data progressively. |
| 212 scoped_refptr<DrainableIOBuffer> request_body_buf_; | 207 scoped_refptr<DrainableIOBuffer> request_body_buf_; |
| 213 | 208 |
| 214 NetLogWithSource stream_net_log_; | 209 NetLogWithSource stream_net_log_; |
| 215 | 210 |
| 211 int session_error_; // Error code from the connection shutdown. | |
| 216 QuicErrorCode quic_connection_error_; // Cached connection error code. | 212 QuicErrorCode quic_connection_error_; // Cached connection error code. |
| 217 QuicRstStreamErrorCode quic_stream_error_; // Cached stream error code. | 213 QuicRstStreamErrorCode quic_stream_error_; // Cached stream error code. |
| 218 | 214 |
| 219 // True when this stream receives a go away from server due to port migration. | |
| 220 bool port_migration_detected_; | |
| 221 | |
| 222 bool found_promise_; | 215 bool found_promise_; |
| 223 // |QuicClientPromisedInfo| owns this. It will be set when |Try()| | 216 // |QuicClientPromisedInfo| owns this. It will be set when |Try()| |
| 224 // is asynchronous, i.e. it returned QUIC_PENDING, and remains valid | 217 // is asynchronous, i.e. it returned QUIC_PENDING, and remains valid |
| 225 // until |OnRendezvouResult()| fires or |push_handle_->Cancel()| is | 218 // until |OnRendezvouResult()| fires or |push_handle_->Cancel()| is |
| 226 // invoked. | 219 // invoked. |
| 227 QuicClientPushPromiseIndex::TryHandle* push_handle_; | 220 QuicClientPushPromiseIndex::TryHandle* push_handle_; |
| 228 | 221 |
| 229 // Set to true when DoLoop() is being executed, false otherwise. | 222 // Set to true when DoLoop() is being executed, false otherwise. |
| 230 bool in_loop_; | 223 bool in_loop_; |
| 231 | 224 |
| 232 // Session connect timing info. | 225 // Session connect timing info. |
| 233 LoadTimingInfo::ConnectTiming connect_timing_; | 226 LoadTimingInfo::ConnectTiming connect_timing_; |
| 234 | 227 |
| 235 base::WeakPtrFactory<QuicHttpStream> weak_factory_; | 228 base::WeakPtrFactory<QuicHttpStream> weak_factory_; |
| 236 | 229 |
| 237 DISALLOW_COPY_AND_ASSIGN(QuicHttpStream); | 230 DISALLOW_COPY_AND_ASSIGN(QuicHttpStream); |
| 238 }; | 231 }; |
| 239 | 232 |
| 240 } // namespace net | 233 } // namespace net |
| 241 | 234 |
| 242 #endif // NET_QUIC_CHROMIUM_QUIC_HTTP_STREAM_H_ | 235 #endif // NET_QUIC_CHROMIUM_QUIC_HTTP_STREAM_H_ |
| OLD | NEW |