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

Unified Diff: net/websockets/websocket_channel.cc

Issue 2315213002: Temporary: Detect WebSocket destruction order problem (Closed)
Patch Set: s/October 2017/October 2016/ Created 4 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/http/http_network_session.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/websockets/websocket_channel.cc
diff --git a/net/websockets/websocket_channel.cc b/net/websockets/websocket_channel.cc
index d932c6d6c7648f8d7c9a1a1d2d04236e8edee1d4..17883351f11739538d7e4e35a7c3f640cad902f5 100644
--- a/net/websockets/websocket_channel.cc
+++ b/net/websockets/websocket_channel.cc
@@ -25,10 +25,13 @@
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h"
#include "net/base/io_buffer.h"
+#include "net/http/http_network_session.h" // TODO(ricea): Remove
#include "net/http/http_request_headers.h"
#include "net/http/http_response_headers.h"
+#include "net/http/http_transaction_factory.h" // TODO(ricea): Remove
#include "net/http/http_util.h"
#include "net/log/net_log.h"
+#include "net/url_request/url_request_context.h" // TODO(ricea): Remove
#include "net/websockets/websocket_errors.h"
#include "net/websockets/websocket_event_interface.h"
#include "net/websockets/websocket_frame.h"
@@ -327,6 +330,14 @@ WebSocketChannel::WebSocketChannel(
initial_frame_forwarded_(false) {}
WebSocketChannel::~WebSocketChannel() {
+ // TODO(ricea): Remove this by October 2016. See bug 641013.
+ if (stream_) {
+ HttpTransactionFactory* http_transaction_factory =
+ url_request_context_->http_transaction_factory();
+ if (http_transaction_factory)
+ http_transaction_factory->GetSession()->DecrementActiveWebSockets();
+ }
+
// The stream may hold a pointer to read_frames_, and so it needs to be
// destroyed first.
stream_.reset();
@@ -598,6 +609,12 @@ void WebSocketChannel::OnConnectSuccess(
stream_ = std::move(stream);
+ // TODO(ricea): Remove this before October 2016.
+ HttpTransactionFactory* http_transaction_factory =
+ url_request_context_->http_transaction_factory();
+ if (http_transaction_factory)
+ http_transaction_factory->GetSession()->IncrementActiveWebSockets();
+
SetState(CONNECTED);
if (event_interface_->OnAddChannelResponse(stream_->GetSubProtocol(),
« no previous file with comments | « net/http/http_network_session.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698