Index: net/websockets/websocket_test_util.cc |
diff --git a/net/websockets/websocket_test_util.cc b/net/websockets/websocket_test_util.cc |
index 76057805a73be54e8531b1ac0c535b523cb307a7..11072eaa11f09ea3f159d6e40d6816c70e23fb7e 100644 |
--- a/net/websockets/websocket_test_util.cc |
+++ b/net/websockets/websocket_test_util.cc |
@@ -127,7 +127,7 @@ void WebSocketDeterministicMockClientSocketFactoryMaker::SetRawExpectations( |
} |
WebSocketTestURLRequestContextHost::WebSocketTestURLRequestContextHost() |
- : url_request_context_(true) { |
+ : url_request_context_(true), url_request_context_initialized_(false) { |
url_request_context_.set_client_socket_factory(maker_.factory()); |
} |
@@ -140,9 +140,12 @@ void WebSocketTestURLRequestContextHost::SetRawExpectations( |
TestURLRequestContext* |
WebSocketTestURLRequestContextHost::GetURLRequestContext() { |
- url_request_context_.Init(); |
- // A Network Delegate is required to make the URLRequest::Delegate work. |
- url_request_context_.set_network_delegate(&network_delegate_); |
+ if (!url_request_context_initialized_) { |
+ url_request_context_.Init(); |
+ // A Network Delegate is required to make the URLRequest::Delegate work. |
+ url_request_context_.set_network_delegate(&network_delegate_); |
+ url_request_context_initialized_ = true; |
+ } |
return &url_request_context_; |
} |