| 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_HTTP_STREAM_H_ | 5 #ifndef NET_SPDY_SPDY_HTTP_STREAM_H_ |
| 6 #define NET_SPDY_SPDY_HTTP_STREAM_H_ | 6 #define NET_SPDY_SPDY_HTTP_STREAM_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <list> | 10 #include <list> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/macros.h" |
| 13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "base/memory/weak_ptr.h" | 14 #include "base/memory/weak_ptr.h" |
| 15 #include "net/base/completion_callback.h" | 15 #include "net/base/completion_callback.h" |
| 16 #include "net/base/net_export.h" | 16 #include "net/base/net_export.h" |
| 17 #include "net/log/net_log_source.h" |
| 17 #include "net/spdy/multiplexed_http_stream.h" | 18 #include "net/spdy/multiplexed_http_stream.h" |
| 18 #include "net/spdy/spdy_read_queue.h" | 19 #include "net/spdy/spdy_read_queue.h" |
| 19 #include "net/spdy/spdy_session.h" | 20 #include "net/spdy/spdy_session.h" |
| 20 #include "net/spdy/spdy_stream.h" | 21 #include "net/spdy/spdy_stream.h" |
| 21 | 22 |
| 22 namespace net { | 23 namespace net { |
| 23 | 24 |
| 24 struct HttpRequestInfo; | 25 struct HttpRequestInfo; |
| 25 class HttpResponseInfo; | 26 class HttpResponseInfo; |
| 26 class IOBuffer; | 27 class IOBuffer; |
| 27 class SpdySession; | 28 class SpdySession; |
| 28 class UploadDataStream; | 29 class UploadDataStream; |
| 29 | 30 |
| 30 // The SpdyHttpStream is a HTTP-specific type of stream known to a SpdySession. | 31 // The SpdyHttpStream is a HTTP-specific type of stream known to a SpdySession. |
| 31 class NET_EXPORT_PRIVATE SpdyHttpStream : public SpdyStream::Delegate, | 32 class NET_EXPORT_PRIVATE SpdyHttpStream : public SpdyStream::Delegate, |
| 32 public MultiplexedHttpStream { | 33 public MultiplexedHttpStream { |
| 33 public: | 34 public: |
| 34 static const size_t kRequestBodyBufferSize; | 35 static const size_t kRequestBodyBufferSize; |
| 35 // |spdy_session| must not be NULL. | 36 // |spdy_session| must not be NULL. |
| 36 SpdyHttpStream(const base::WeakPtr<SpdySession>& spdy_session, bool direct); | 37 SpdyHttpStream(const base::WeakPtr<SpdySession>& spdy_session, |
| 38 bool direct, |
| 39 NetLogSource source_dependency); |
| 37 ~SpdyHttpStream() override; | 40 ~SpdyHttpStream() override; |
| 38 | 41 |
| 39 SpdyStream* stream() { return stream_; } | 42 SpdyStream* stream() { return stream_; } |
| 40 | 43 |
| 41 // Cancels any callbacks from being invoked and deletes the stream. | 44 // Cancels any callbacks from being invoked and deletes the stream. |
| 42 void Cancel(); | 45 void Cancel(); |
| 43 | 46 |
| 44 // HttpStream implementation. | 47 // HttpStream implementation. |
| 45 | 48 |
| 46 int InitializeStream(const HttpRequestInfo* request_info, | 49 int InitializeStream(const HttpRequestInfo* request_info, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 76 void PopulateNetErrorDetails(NetErrorDetails* details) override; | 79 void PopulateNetErrorDetails(NetErrorDetails* details) override; |
| 77 void SetPriority(RequestPriority priority) override; | 80 void SetPriority(RequestPriority priority) override; |
| 78 | 81 |
| 79 // SpdyStream::Delegate implementation. | 82 // SpdyStream::Delegate implementation. |
| 80 void OnHeadersSent() override; | 83 void OnHeadersSent() override; |
| 81 void OnHeadersReceived(const SpdyHeaderBlock& response_headers) override; | 84 void OnHeadersReceived(const SpdyHeaderBlock& response_headers) override; |
| 82 void OnDataReceived(std::unique_ptr<SpdyBuffer> buffer) override; | 85 void OnDataReceived(std::unique_ptr<SpdyBuffer> buffer) override; |
| 83 void OnDataSent() override; | 86 void OnDataSent() override; |
| 84 void OnTrailers(const SpdyHeaderBlock& trailers) override; | 87 void OnTrailers(const SpdyHeaderBlock& trailers) override; |
| 85 void OnClose(int status) override; | 88 void OnClose(int status) override; |
| 89 NetLogSource source_dependency() const override; |
| 86 | 90 |
| 87 private: | 91 private: |
| 88 // Helper function used to initialize private members and to set delegate on | 92 // Helper function used to initialize private members and to set delegate on |
| 89 // stream when stream is created. | 93 // stream when stream is created. |
| 90 void InitializeStreamHelper(); | 94 void InitializeStreamHelper(); |
| 91 | 95 |
| 92 // Helper function used for resetting stream from inside the stream. | 96 // Helper function used for resetting stream from inside the stream. |
| 93 void ResetStreamInternal(); | 97 void ResetStreamInternal(); |
| 94 | 98 |
| 95 // Must be called only when |request_info_| is non-NULL. | 99 // Must be called only when |request_info_| is non-NULL. |
| (...skipping 25 matching lines...) Expand all Loading... |
| 121 // Call the user callback associated with reading the response. | 125 // Call the user callback associated with reading the response. |
| 122 void DoResponseCallback(int rv); | 126 void DoResponseCallback(int rv); |
| 123 | 127 |
| 124 void ScheduleBufferedReadCallback(); | 128 void ScheduleBufferedReadCallback(); |
| 125 void DoBufferedReadCallback(); | 129 void DoBufferedReadCallback(); |
| 126 bool ShouldWaitForMoreBufferedData() const; | 130 bool ShouldWaitForMoreBufferedData() const; |
| 127 | 131 |
| 128 const base::WeakPtr<SpdySession> spdy_session_; | 132 const base::WeakPtr<SpdySession> spdy_session_; |
| 129 bool is_reused_; | 133 bool is_reused_; |
| 130 SpdyStreamRequest stream_request_; | 134 SpdyStreamRequest stream_request_; |
| 135 const NetLogSource source_dependency_; |
| 131 | 136 |
| 132 // |stream_| is owned by SpdySession. | 137 // |stream_| is owned by SpdySession. |
| 133 // Before InitializeStream() is called, stream_ == nullptr. | 138 // Before InitializeStream() is called, stream_ == nullptr. |
| 134 // After InitializeStream() is called but before OnClose() is called, | 139 // After InitializeStream() is called but before OnClose() is called, |
| 135 // |*stream_| is guaranteed to be valid. | 140 // |*stream_| is guaranteed to be valid. |
| 136 // After OnClose() is called, stream_ == nullptr. | 141 // After OnClose() is called, stream_ == nullptr. |
| 137 SpdyStream* stream_; | 142 SpdyStream* stream_; |
| 138 | 143 |
| 139 // False before OnClose() is called, true after. | 144 // False before OnClose() is called, true after. |
| 140 bool stream_closed_; | 145 bool stream_closed_; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 bool was_alpn_negotiated_; | 197 bool was_alpn_negotiated_; |
| 193 | 198 |
| 194 base::WeakPtrFactory<SpdyHttpStream> weak_factory_; | 199 base::WeakPtrFactory<SpdyHttpStream> weak_factory_; |
| 195 | 200 |
| 196 DISALLOW_COPY_AND_ASSIGN(SpdyHttpStream); | 201 DISALLOW_COPY_AND_ASSIGN(SpdyHttpStream); |
| 197 }; | 202 }; |
| 198 | 203 |
| 199 } // namespace net | 204 } // namespace net |
| 200 | 205 |
| 201 #endif // NET_SPDY_SPDY_HTTP_STREAM_H_ | 206 #endif // NET_SPDY_SPDY_HTTP_STREAM_H_ |
| OLD | NEW |