Make HttpNetworkSession own HttpResponseBodyDrainer
HttpResponseBodyDrainers are jointly owned by themselves and by the
HttpNetworkSession, to ensure they're destroyed on teardown.
To make the ownership clear, this cl change this to make
HttpNetworkSession own HttpResponseBodyDrainer.
Bug: 479898
Change-Id: I141dfd2640291796a4210ba8fd217a44a96d0146
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3779865
Commit-Queue: Tsuyoshi Horo <[email protected]>
Reviewed-by: Matt Menke <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1027465}
diff --git a/net/websockets/websocket_basic_handshake_stream.cc b/net/websockets/websocket_basic_handshake_stream.cc
index 2f1ebc35..c727c14 100644
--- a/net/websockets/websocket_basic_handshake_stream.cc
+++ b/net/websockets/websocket_basic_handshake_stream.cc
@@ -23,6 +23,7 @@
#include "crypto/random.h"
#include "net/base/io_buffer.h"
#include "net/base/ip_endpoint.h"
+#include "net/http/http_network_session.h"
#include "net/http/http_request_headers.h"
#include "net/http/http_request_info.h"
#include "net/http/http_response_body_drainer.h"
@@ -375,8 +376,8 @@
}
void WebSocketBasicHandshakeStream::Drain(HttpNetworkSession* session) {
- HttpResponseBodyDrainer* drainer = new HttpResponseBodyDrainer(this);
- drainer->Start(session);
+ session->StartResponseDrainer(
+ std::make_unique<HttpResponseBodyDrainer>(this));
// |drainer| will delete itself.
}