Cancel posted write callbacks in Disconnect().
Add a second WeakPtrFactory for the posted write callbacks. Invalidate
the weak pointers created by this factory in Disconnect().
[email protected],[email protected],[email protected]
BUG=362733
Review URL: https://codereview.chromium.org/338583003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277158 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/net/spdy/spdy_proxy_client_socket.cc b/net/spdy/spdy_proxy_client_socket.cc
index 6a87b54..d268a4d 100644
--- a/net/spdy/spdy_proxy_client_socket.cc
+++ b/net/spdy/spdy_proxy_client_socket.cc
@@ -36,18 +36,18 @@
: next_state_(STATE_DISCONNECTED),
spdy_stream_(spdy_stream),
endpoint_(endpoint),
- auth_(
- new HttpAuthController(HttpAuth::AUTH_PROXY,
- GURL("https://" + proxy_server.ToString()),
- auth_cache,
- auth_handler_factory)),
+ auth_(new HttpAuthController(HttpAuth::AUTH_PROXY,
+ GURL("https://" + proxy_server.ToString()),
+ auth_cache,
+ auth_handler_factory)),
user_buffer_len_(0),
write_buffer_len_(0),
was_ever_used_(false),
redirect_has_load_timing_info_(false),
net_log_(BoundNetLog::Make(spdy_stream->net_log().net_log(),
NetLog::SOURCE_PROXY_CLIENT_SOCKET)),
- weak_factory_(this) {
+ weak_factory_(this),
+ write_callback_weak_factory_(this) {
request_.method = "CONNECT";
request_.url = url;
if (!user_agent.empty())
@@ -137,6 +137,7 @@
write_buffer_len_ = 0;
write_callback_.Reset();
+ write_callback_weak_factory_.InvalidateWeakPtrs();
next_state_ = STATE_DISCONNECTED;
@@ -268,6 +269,11 @@
/* is_https_proxy = */ true);
}
+void SpdyProxyClientSocket::RunCallback(const CompletionCallback& callback,
+ int result) const {
+ callback.Run(result);
+}
+
void SpdyProxyClientSocket::OnIOComplete(int result) {
DCHECK_NE(STATE_DISCONNECTED, next_state_);
int rv = DoLoop(result);
@@ -488,7 +494,10 @@
// stream's write callback chain to unwind (see crbug.com/355511).
base::MessageLoop::current()->PostTask(
FROM_HERE,
- base::Bind(ResetAndReturn(&write_callback_), rv));
+ base::Bind(&SpdyProxyClientSocket::RunCallback,
+ write_callback_weak_factory_.GetWeakPtr(),
+ ResetAndReturn(&write_callback_),
+ rv));
}
void SpdyProxyClientSocket::OnClose(int status) {