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

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

Issue 8771012: Fix crash bug in SpdyProxyClientSocket.GetPeerAddress where (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Really final, I hope2 Created 9 years 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_proxy_client_socket.h ('k') | net/spdy/spdy_proxy_client_socket_unittest.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "net/spdy/spdy_proxy_client_socket.h" 5 #include "net/spdy/spdy_proxy_client_socket.h"
6 6
7 #include <algorithm> // min 7 #include <algorithm> // min
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
(...skipping 26 matching lines...) Expand all
37 write_callback_(NULL), 37 write_callback_(NULL),
38 endpoint_(endpoint), 38 endpoint_(endpoint),
39 auth_( 39 auth_(
40 new HttpAuthController(HttpAuth::AUTH_PROXY, 40 new HttpAuthController(HttpAuth::AUTH_PROXY,
41 GURL("https://" + proxy_server.ToString()), 41 GURL("https://" + proxy_server.ToString()),
42 auth_cache, 42 auth_cache,
43 auth_handler_factory)), 43 auth_handler_factory)),
44 user_buffer_(NULL), 44 user_buffer_(NULL),
45 write_buffer_len_(0), 45 write_buffer_len_(0),
46 write_bytes_outstanding_(0), 46 write_bytes_outstanding_(0),
47 eof_has_been_read_(false),
48 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)), 47 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)),
49 net_log_(spdy_stream->net_log()) { 48 net_log_(spdy_stream->net_log()) {
50 request_.method = "CONNECT"; 49 request_.method = "CONNECT";
51 request_.url = url; 50 request_.url = url;
52 if (!user_agent.empty()) 51 if (!user_agent.empty())
53 request_.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent, 52 request_.extra_headers.SetHeader(HttpRequestHeaders::kUserAgent,
54 user_agent); 53 user_agent);
55 spdy_stream_->SetDelegate(this); 54 spdy_stream_->SetDelegate(this);
56 was_ever_used_ = spdy_stream_->WasEverUsed(); 55 was_ever_used_ = spdy_stream_->WasEverUsed();
57 } 56 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 116
118 next_state_ = STATE_DISCONNECTED; 117 next_state_ = STATE_DISCONNECTED;
119 118
120 if (spdy_stream_) 119 if (spdy_stream_)
121 // This will cause OnClose to be invoked, which takes care of 120 // This will cause OnClose to be invoked, which takes care of
122 // cleaning up all the internal state. 121 // cleaning up all the internal state.
123 spdy_stream_->Cancel(); 122 spdy_stream_->Cancel();
124 } 123 }
125 124
126 bool SpdyProxyClientSocket::IsConnected() const { 125 bool SpdyProxyClientSocket::IsConnected() const {
127 return next_state_ == STATE_OPEN || next_state_ == STATE_CLOSED; 126 return next_state_ == STATE_OPEN;
128 } 127 }
129 128
130 bool SpdyProxyClientSocket::IsConnectedAndIdle() const { 129 bool SpdyProxyClientSocket::IsConnectedAndIdle() const {
131 return IsConnected() && spdy_stream_.get() != NULL && 130 return IsConnected() && read_buffer_.empty() && spdy_stream_->is_idle();
132 !spdy_stream_->is_idle();
133 } 131 }
134 132
135 const BoundNetLog& SpdyProxyClientSocket::NetLog() const { 133 const BoundNetLog& SpdyProxyClientSocket::NetLog() const {
136 return net_log_; 134 return net_log_;
137 } 135 }
138 136
139 void SpdyProxyClientSocket::SetSubresourceSpeculation() { 137 void SpdyProxyClientSocket::SetSubresourceSpeculation() {
140 // TODO(rch): what should this implementation be? 138 // TODO(rch): what should this implementation be?
141 } 139 }
142 140
(...skipping 18 matching lines...) Expand all
161 } 159 }
162 160
163 int SpdyProxyClientSocket::Read(IOBuffer* buf, int buf_len, 161 int SpdyProxyClientSocket::Read(IOBuffer* buf, int buf_len,
164 OldCompletionCallback* callback) { 162 OldCompletionCallback* callback) {
165 DCHECK(!read_callback_); 163 DCHECK(!read_callback_);
166 DCHECK(!user_buffer_); 164 DCHECK(!user_buffer_);
167 165
168 if (next_state_ == STATE_DISCONNECTED) 166 if (next_state_ == STATE_DISCONNECTED)
169 return ERR_SOCKET_NOT_CONNECTED; 167 return ERR_SOCKET_NOT_CONNECTED;
170 168
171 if (!spdy_stream_ && read_buffer_.empty()) { 169 if (next_state_ == STATE_CLOSED && read_buffer_.empty()) {
172 if (eof_has_been_read_)
173 return ERR_CONNECTION_CLOSED;
174 eof_has_been_read_ = true;
175 return 0; 170 return 0;
176 } 171 }
177 172
178 DCHECK(next_state_ == STATE_OPEN || next_state_ == STATE_CLOSED); 173 DCHECK(next_state_ == STATE_OPEN || next_state_ == STATE_CLOSED);
179 DCHECK(buf); 174 DCHECK(buf);
180 user_buffer_ = new DrainableIOBuffer(buf, buf_len); 175 user_buffer_ = new DrainableIOBuffer(buf, buf_len);
181 int result = PopulateUserReadBuffer(); 176 int result = PopulateUserReadBuffer();
182 if (result == 0) { 177 if (result == 0) {
183 DCHECK(callback); 178 DCHECK(callback);
184 read_callback_ = callback; 179 read_callback_ = callback;
(...skipping 20 matching lines...) Expand all
205 data->DidConsume(bytes_to_copy); 200 data->DidConsume(bytes_to_copy);
206 } 201 }
207 } 202 }
208 203
209 return user_buffer_->BytesConsumed(); 204 return user_buffer_->BytesConsumed();
210 } 205 }
211 206
212 int SpdyProxyClientSocket::Write(IOBuffer* buf, int buf_len, 207 int SpdyProxyClientSocket::Write(IOBuffer* buf, int buf_len,
213 OldCompletionCallback* callback) { 208 OldCompletionCallback* callback) {
214 DCHECK(!write_callback_); 209 DCHECK(!write_callback_);
215 if (next_state_ == STATE_DISCONNECTED) 210 if (next_state_ != STATE_OPEN)
216 return ERR_SOCKET_NOT_CONNECTED; 211 return ERR_SOCKET_NOT_CONNECTED;
217 212
218 if (!spdy_stream_) 213 DCHECK(spdy_stream_);
219 return ERR_CONNECTION_CLOSED;
220
221 write_bytes_outstanding_= buf_len; 214 write_bytes_outstanding_= buf_len;
222 if (buf_len <= kMaxSpdyFrameChunkSize) { 215 if (buf_len <= kMaxSpdyFrameChunkSize) {
223 int rv = spdy_stream_->WriteStreamData(buf, buf_len, spdy::DATA_FLAG_NONE); 216 int rv = spdy_stream_->WriteStreamData(buf, buf_len, spdy::DATA_FLAG_NONE);
224 if (rv == ERR_IO_PENDING) { 217 if (rv == ERR_IO_PENDING) {
225 write_callback_ = callback; 218 write_callback_ = callback;
226 write_buffer_len_ = buf_len; 219 write_buffer_len_ = buf_len;
227 } 220 }
228 return rv; 221 return rv;
229 } 222 }
230 223
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 } 529 }
537 // This may have been deleted by read_callback_, so check first. 530 // This may have been deleted by read_callback_, so check first.
538 if (weak_ptr && write_callback) 531 if (weak_ptr && write_callback)
539 write_callback->Run(ERR_CONNECTION_CLOSED); 532 write_callback->Run(ERR_CONNECTION_CLOSED);
540 } 533 }
541 534
542 void SpdyProxyClientSocket::set_chunk_callback(ChunkCallback* /*callback*/) { 535 void SpdyProxyClientSocket::set_chunk_callback(ChunkCallback* /*callback*/) {
543 } 536 }
544 537
545 } // namespace net 538 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_proxy_client_socket.h ('k') | net/spdy/spdy_proxy_client_socket_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698