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

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

Issue 13990005: [SPDY] Replace SpdyIOBuffer with new SpdyBuffer class (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix missing include Created 7 years, 8 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_io_buffer.cc ('k') | net/spdy/spdy_proxy_client_socket.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_PROXY_CLIENT_SOCKET_H_ 5 #ifndef NET_SPDY_SPDY_PROXY_CLIENT_SOCKET_H_
6 #define NET_SPDY_SPDY_PROXY_CLIENT_SOCKET_H_ 6 #define NET_SPDY_SPDY_PROXY_CLIENT_SOCKET_H_
7 7
8 #include <list>
8 #include <string> 9 #include <string>
9 #include <list>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/weak_ptr.h" 13 #include "base/memory/weak_ptr.h"
14 #include "net/base/completion_callback.h" 14 #include "net/base/completion_callback.h"
15 #include "net/base/host_port_pair.h" 15 #include "net/base/host_port_pair.h"
16 #include "net/base/net_log.h" 16 #include "net/base/net_log.h"
17 #include "net/http/http_auth_controller.h" 17 #include "net/http/http_auth_controller.h"
18 #include "net/http/http_request_headers.h" 18 #include "net/http/http_request_headers.h"
19 #include "net/http/http_request_info.h" 19 #include "net/http/http_request_info.h"
20 #include "net/http/http_response_info.h" 20 #include "net/http/http_response_info.h"
21 #include "net/http/proxy_client_socket.h" 21 #include "net/http/proxy_client_socket.h"
22 #include "net/spdy/spdy_http_stream.h" 22 #include "net/spdy/spdy_http_stream.h"
23 #include "net/spdy/spdy_protocol.h" 23 #include "net/spdy/spdy_protocol.h"
24 #include "net/spdy/spdy_read_queue.h"
24 #include "net/spdy/spdy_session.h" 25 #include "net/spdy/spdy_session.h"
25 #include "net/spdy/spdy_stream.h" 26 #include "net/spdy/spdy_stream.h"
26 27
27 28
28 class GURL; 29 class GURL;
29 30
30 namespace net { 31 namespace net {
31 32
32 class AddressList; 33 class AddressList;
33 class HttpStream; 34 class HttpStream;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 virtual int GetLocalAddress(IPEndPoint* address) const OVERRIDE; 91 virtual int GetLocalAddress(IPEndPoint* address) const OVERRIDE;
91 92
92 // SpdyStream::Delegate implementation. 93 // SpdyStream::Delegate implementation.
93 virtual SpdySendStatus OnSendHeadersComplete() OVERRIDE; 94 virtual SpdySendStatus OnSendHeadersComplete() OVERRIDE;
94 virtual int OnSendBody() OVERRIDE; 95 virtual int OnSendBody() OVERRIDE;
95 virtual SpdySendStatus OnSendBodyComplete(size_t bytes_sent) OVERRIDE; 96 virtual SpdySendStatus OnSendBodyComplete(size_t bytes_sent) OVERRIDE;
96 virtual int OnResponseReceived(const SpdyHeaderBlock& response, 97 virtual int OnResponseReceived(const SpdyHeaderBlock& response,
97 base::Time response_time, 98 base::Time response_time,
98 int status) OVERRIDE; 99 int status) OVERRIDE;
99 virtual void OnHeadersSent() OVERRIDE; 100 virtual void OnHeadersSent() OVERRIDE;
100 virtual int OnDataReceived(const char* data, int length) OVERRIDE; 101 virtual int OnDataReceived(scoped_ptr<SpdyBuffer> buffer) OVERRIDE;
101 virtual void OnDataSent(size_t bytes_sent) OVERRIDE; 102 virtual void OnDataSent(size_t bytes_sent) OVERRIDE;
102 virtual void OnClose(int status) OVERRIDE; 103 virtual void OnClose(int status) OVERRIDE;
103 104
104 private: 105 private:
105 enum State { 106 enum State {
106 STATE_DISCONNECTED, 107 STATE_DISCONNECTED,
107 STATE_GENERATE_AUTH_TOKEN, 108 STATE_GENERATE_AUTH_TOKEN,
108 STATE_GENERATE_AUTH_TOKEN_COMPLETE, 109 STATE_GENERATE_AUTH_TOKEN_COMPLETE,
109 STATE_SEND_REQUEST, 110 STATE_SEND_REQUEST,
110 STATE_SEND_REQUEST_COMPLETE, 111 STATE_SEND_REQUEST_COMPLETE,
111 STATE_READ_REPLY_COMPLETE, 112 STATE_READ_REPLY_COMPLETE,
112 STATE_OPEN, 113 STATE_OPEN,
113 STATE_CLOSED 114 STATE_CLOSED
114 }; 115 };
115 116
116 void LogBlockedTunnelResponse() const; 117 void LogBlockedTunnelResponse() const;
117 118
118 void OnIOComplete(int result); 119 void OnIOComplete(int result);
119 120
120 int DoLoop(int last_io_result); 121 int DoLoop(int last_io_result);
121 int DoGenerateAuthToken(); 122 int DoGenerateAuthToken();
122 int DoGenerateAuthTokenComplete(int result); 123 int DoGenerateAuthTokenComplete(int result);
123 int DoSendRequest(); 124 int DoSendRequest();
124 int DoSendRequestComplete(int result); 125 int DoSendRequestComplete(int result);
125 int DoReadReplyComplete(int result); 126 int DoReadReplyComplete(int result);
126 127
127 // Populates |user_buffer_| with as much read data as possible 128 // Populates |user_buffer_| with as much read data as possible
128 // and returns the number of bytes read. 129 // and returns the number of bytes read.
129 int PopulateUserReadBuffer(); 130 size_t PopulateUserReadBuffer(char* out, size_t len);
130 131
131 State next_state_; 132 State next_state_;
132 133
133 // Pointer to the SPDY Stream that this sits on top of. 134 // Pointer to the SPDY Stream that this sits on top of.
134 scoped_refptr<SpdyStream> spdy_stream_; 135 scoped_refptr<SpdyStream> spdy_stream_;
135 136
136 // Stores the callback to the layer above, called on completing Read() or 137 // Stores the callback to the layer above, called on completing Read() or
137 // Connect(). 138 // Connect().
138 CompletionCallback read_callback_; 139 CompletionCallback read_callback_;
139 // Stores the callback to the layer above, called on completing Write(). 140 // Stores the callback to the layer above, called on completing Write().
140 CompletionCallback write_callback_; 141 CompletionCallback write_callback_;
141 142
142 // CONNECT request and response. 143 // CONNECT request and response.
143 HttpRequestInfo request_; 144 HttpRequestInfo request_;
144 HttpResponseInfo response_; 145 HttpResponseInfo response_;
145 146
146 // The hostname and port of the endpoint. This is not necessarily the one 147 // The hostname and port of the endpoint. This is not necessarily the one
147 // specified by the URL, due to Alternate-Protocol or fixed testing ports. 148 // specified by the URL, due to Alternate-Protocol or fixed testing ports.
148 const HostPortPair endpoint_; 149 const HostPortPair endpoint_;
149 scoped_refptr<HttpAuthController> auth_; 150 scoped_refptr<HttpAuthController> auth_;
150 151
151 // We buffer the response body as it arrives asynchronously from the stream. 152 // We buffer the response body as it arrives asynchronously from the stream.
152 std::list<scoped_refptr<DrainableIOBuffer> > read_buffer_; 153 SpdyReadQueue read_buffer_queue_;
153 154
154 // User provided buffer for the Read() response. 155 // User provided buffer for the Read() response.
155 scoped_refptr<DrainableIOBuffer> user_buffer_; 156 scoped_refptr<IOBuffer> user_buffer_;
157 size_t user_buffer_len_;
156 158
157 // User specified number of bytes to be written. 159 // User specified number of bytes to be written.
158 int write_buffer_len_; 160 int write_buffer_len_;
159 // Number of bytes written which have not been confirmed 161 // Number of bytes written which have not been confirmed
160 int write_bytes_outstanding_; 162 int write_bytes_outstanding_;
161 163
162 // True if the transport socket has ever sent data. 164 // True if the transport socket has ever sent data.
163 bool was_ever_used_; 165 bool was_ever_used_;
164 166
165 scoped_ptr<SpdyHttpStream> response_stream_; 167 scoped_ptr<SpdyHttpStream> response_stream_;
166 168
167 base::WeakPtrFactory<SpdyProxyClientSocket> weak_factory_; 169 base::WeakPtrFactory<SpdyProxyClientSocket> weak_factory_;
168 170
169 const BoundNetLog net_log_; 171 const BoundNetLog net_log_;
170 172
171 DISALLOW_COPY_AND_ASSIGN(SpdyProxyClientSocket); 173 DISALLOW_COPY_AND_ASSIGN(SpdyProxyClientSocket);
172 }; 174 };
173 175
174 } // namespace net 176 } // namespace net
175 177
176 #endif // NET_SPDY_SPDY_PROXY_CLIENT_SOCKET_H_ 178 #endif // NET_SPDY_SPDY_PROXY_CLIENT_SOCKET_H_
OLDNEW
« no previous file with comments | « net/spdy/spdy_io_buffer.cc ('k') | net/spdy/spdy_proxy_client_socket.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698