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

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

Issue 14087008: [SPDY] Fix memory leak introduced by r194564 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 | « no previous file | no next file » | 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 1085 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 continue; 1096 continue;
1097 } 1097 }
1098 in_flight_write_frame_type_ = frame_type; 1098 in_flight_write_frame_type_ = frame_type;
1099 in_flight_write_frame_size_ = in_flight_write_->GetRemainingSize(); 1099 in_flight_write_frame_size_ = in_flight_write_->GetRemainingSize();
1100 DCHECK_GE(in_flight_write_frame_size_, 1100 DCHECK_GE(in_flight_write_frame_size_,
1101 buffered_spdy_framer_->GetFrameMinimumSize()); 1101 buffered_spdy_framer_->GetFrameMinimumSize());
1102 in_flight_write_stream_ = stream; 1102 in_flight_write_stream_ = stream;
1103 } 1103 }
1104 1104
1105 write_pending_ = true; 1105 write_pending_ = true;
1106 // Explicitly store in a scoped_refptr<IOBuffer> to avoid problems
1107 // with net::Socket implementations that don't store their
1108 // IOBuffer argument in a scoped_refptr<IOBuffer> (see
1109 // crbug.com/232345).
1110 scoped_refptr<IOBuffer> write_io_buffer =
1111 in_flight_write_->GetIOBufferForRemainingData();
1106 // We keep |in_flight_write_| alive until OnWriteComplete(), so 1112 // We keep |in_flight_write_| alive until OnWriteComplete(), so
1107 // it's okay to use GetIOBufferForRemainingData() since the socket 1113 // it's okay to use GetIOBufferForRemainingData() since the socket
1108 // doesn't use the IOBuffer past OnWriteComplete(). 1114 // doesn't use the IOBuffer past OnWriteComplete().
1109 int rv = connection_->socket()->Write( 1115 int rv = connection_->socket()->Write(
1110 in_flight_write_->GetIOBufferForRemainingData(), 1116 write_io_buffer,
1111 in_flight_write_->GetRemainingSize(), 1117 in_flight_write_->GetRemainingSize(),
1112 base::Bind(&SpdySession::OnWriteComplete, weak_factory_.GetWeakPtr())); 1118 base::Bind(&SpdySession::OnWriteComplete, weak_factory_.GetWeakPtr()));
1119 // Avoid persisting |write_io_buffer| past |in_flight_write_|'s
1120 // lifetime (which will end if OnWriteComplete() is called below).
1121 write_io_buffer = NULL;
1113 if (rv == net::ERR_IO_PENDING) 1122 if (rv == net::ERR_IO_PENDING)
1114 break; 1123 break;
1115 1124
1116 // We sent the frame successfully. 1125 // We sent the frame successfully.
1117 OnWriteComplete(rv); 1126 OnWriteComplete(rv);
1118 1127
1119 // TODO(mbelshe): Test this error case. Maybe we should mark the socket 1128 // TODO(mbelshe): Test this error case. Maybe we should mark the socket
1120 // as in an error state. 1129 // as in an error state.
1121 if (rv < 0) 1130 if (rv < 0)
1122 break; 1131 break;
(...skipping 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after
2324 } 2333 }
2325 2334
2326 session_recv_window_size_ -= delta_window_size; 2335 session_recv_window_size_ -= delta_window_size;
2327 net_log_.AddEvent( 2336 net_log_.AddEvent(
2328 NetLog::TYPE_SPDY_SESSION_UPDATE_RECV_WINDOW, 2337 NetLog::TYPE_SPDY_SESSION_UPDATE_RECV_WINDOW,
2329 base::Bind(&NetLogSpdySessionWindowUpdateCallback, 2338 base::Bind(&NetLogSpdySessionWindowUpdateCallback,
2330 -delta_window_size, session_recv_window_size_)); 2339 -delta_window_size, session_recv_window_size_));
2331 } 2340 }
2332 2341
2333 } // namespace net 2342 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698