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

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

Issue 15829004: Update net/ to use scoped_refptr<T>::get() rather than implicit "operator T*" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: license twerk Created 7 years, 6 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_proxy_client_socket_unittest.cc ('k') | net/spdy/spdy_session_pool.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 #include "net/spdy/spdy_session.h" 5 #include "net/spdy/spdy_session.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <map> 8 #include <map>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 CancelRequest(); 237 CancelRequest();
238 } 238 }
239 239
240 int SpdyStreamRequest::StartRequest( 240 int SpdyStreamRequest::StartRequest(
241 SpdyStreamType type, 241 SpdyStreamType type,
242 const scoped_refptr<SpdySession>& session, 242 const scoped_refptr<SpdySession>& session,
243 const GURL& url, 243 const GURL& url,
244 RequestPriority priority, 244 RequestPriority priority,
245 const BoundNetLog& net_log, 245 const BoundNetLog& net_log,
246 const CompletionCallback& callback) { 246 const CompletionCallback& callback) {
247 DCHECK(session); 247 DCHECK(session.get());
248 DCHECK(!session_); 248 DCHECK(!session_.get());
249 DCHECK(!stream_); 249 DCHECK(!stream_);
250 DCHECK(callback_.is_null()); 250 DCHECK(callback_.is_null());
251 251
252 type_ = type; 252 type_ = type;
253 session_ = session; 253 session_ = session;
254 url_ = url; 254 url_ = url;
255 priority_ = priority; 255 priority_ = priority;
256 net_log_ = net_log; 256 net_log_ = net_log;
257 callback_ = callback; 257 callback_ = callback;
258 258
259 base::WeakPtr<SpdyStream> stream; 259 base::WeakPtr<SpdyStream> stream;
260 int rv = session->TryCreateStream(this, &stream); 260 int rv = session->TryCreateStream(this, &stream);
261 if (rv == OK) { 261 if (rv == OK) {
262 Reset(); 262 Reset();
263 stream_ = stream; 263 stream_ = stream;
264 } 264 }
265 return rv; 265 return rv;
266 } 266 }
267 267
268 void SpdyStreamRequest::CancelRequest() { 268 void SpdyStreamRequest::CancelRequest() {
269 if (session_) 269 if (session_.get())
270 session_->CancelStreamRequest(this); 270 session_->CancelStreamRequest(this);
271 Reset(); 271 Reset();
272 } 272 }
273 273
274 base::WeakPtr<SpdyStream> SpdyStreamRequest::ReleaseStream() { 274 base::WeakPtr<SpdyStream> SpdyStreamRequest::ReleaseStream() {
275 DCHECK(!session_.get()); 275 DCHECK(!session_.get());
276 base::WeakPtr<SpdyStream> stream = stream_; 276 base::WeakPtr<SpdyStream> stream = stream_;
277 DCHECK(stream); 277 DCHECK(stream);
278 Reset(); 278 Reset();
279 return stream; 279 return stream;
280 } 280 }
281 281
282 void SpdyStreamRequest::OnRequestCompleteSuccess( 282 void SpdyStreamRequest::OnRequestCompleteSuccess(
283 base::WeakPtr<SpdyStream>* stream) { 283 base::WeakPtr<SpdyStream>* stream) {
284 DCHECK(session_); 284 DCHECK(session_.get());
285 DCHECK(!stream_); 285 DCHECK(!stream_);
286 DCHECK(!callback_.is_null()); 286 DCHECK(!callback_.is_null());
287 CompletionCallback callback = callback_; 287 CompletionCallback callback = callback_;
288 Reset(); 288 Reset();
289 DCHECK(*stream); 289 DCHECK(*stream);
290 stream_ = *stream; 290 stream_ = *stream;
291 callback.Run(OK); 291 callback.Run(OK);
292 } 292 }
293 293
294 void SpdyStreamRequest::OnRequestCompleteFailure(int rv) { 294 void SpdyStreamRequest::OnRequestCompleteFailure(int rv) {
295 DCHECK(session_); 295 DCHECK(session_.get());
296 DCHECK(!stream_); 296 DCHECK(!stream_);
297 DCHECK(!callback_.is_null()); 297 DCHECK(!callback_.is_null());
298 CompletionCallback callback = callback_; 298 CompletionCallback callback = callback_;
299 Reset(); 299 Reset();
300 DCHECK_NE(rv, OK); 300 DCHECK_NE(rv, OK);
301 callback.Run(rv); 301 callback.Run(rv);
302 } 302 }
303 303
304 void SpdyStreamRequest::Reset() { 304 void SpdyStreamRequest::Reset() {
305 type_ = SPDY_BIDIRECTIONAL_STREAM; 305 type_ = SPDY_BIDIRECTIONAL_STREAM;
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after
1193 write_pending_ = true; 1193 write_pending_ = true;
1194 // Explicitly store in a scoped_refptr<IOBuffer> to avoid problems 1194 // Explicitly store in a scoped_refptr<IOBuffer> to avoid problems
1195 // with Socket implementations that don't store their IOBuffer 1195 // with Socket implementations that don't store their IOBuffer
1196 // argument in a scoped_refptr<IOBuffer> (see crbug.com/232345). 1196 // argument in a scoped_refptr<IOBuffer> (see crbug.com/232345).
1197 scoped_refptr<IOBuffer> write_io_buffer = 1197 scoped_refptr<IOBuffer> write_io_buffer =
1198 in_flight_write_->GetIOBufferForRemainingData(); 1198 in_flight_write_->GetIOBufferForRemainingData();
1199 // We keep |in_flight_write_| alive until OnWriteComplete(), so 1199 // We keep |in_flight_write_| alive until OnWriteComplete(), so
1200 // it's okay to use GetIOBufferForRemainingData() since the socket 1200 // it's okay to use GetIOBufferForRemainingData() since the socket
1201 // doesn't use the IOBuffer past OnWriteComplete(). 1201 // doesn't use the IOBuffer past OnWriteComplete().
1202 int rv = connection_->socket()->Write( 1202 int rv = connection_->socket()->Write(
1203 write_io_buffer, 1203 write_io_buffer.get(),
1204 in_flight_write_->GetRemainingSize(), 1204 in_flight_write_->GetRemainingSize(),
1205 base::Bind(&SpdySession::OnWriteComplete, weak_factory_.GetWeakPtr())); 1205 base::Bind(&SpdySession::OnWriteComplete, weak_factory_.GetWeakPtr()));
1206 // Avoid persisting |write_io_buffer| past |in_flight_write_|'s 1206 // Avoid persisting |write_io_buffer| past |in_flight_write_|'s
1207 // lifetime (which will end if OnWriteComplete() is called below). 1207 // lifetime (which will end if OnWriteComplete() is called below).
1208 write_io_buffer = NULL; 1208 write_io_buffer = NULL;
1209 if (rv == ERR_IO_PENDING) 1209 if (rv == ERR_IO_PENDING)
1210 break; 1210 break;
1211 1211
1212 // We sent the frame successfully. 1212 // We sent the frame successfully.
1213 OnWriteComplete(rv); 1213 OnWriteComplete(rv);
(...skipping 1240 matching lines...) Expand 10 before | Expand all | Expand 10 after
2454 if (!queue->empty()) { 2454 if (!queue->empty()) {
2455 SpdyStreamId stream_id = queue->front(); 2455 SpdyStreamId stream_id = queue->front();
2456 queue->pop_front(); 2456 queue->pop_front();
2457 return stream_id; 2457 return stream_id;
2458 } 2458 }
2459 } 2459 }
2460 return 0; 2460 return 0;
2461 } 2461 }
2462 2462
2463 } // namespace net 2463 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_proxy_client_socket_unittest.cc ('k') | net/spdy/spdy_session_pool.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698