OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/websockets/websocket_test_util.h" | 5 #include "net/websockets/websocket_test_util.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 } | 129 } |
130 | 130 |
131 void | 131 void |
132 WebSocketDeterministicMockClientSocketFactoryMaker::AddSSLSocketDataProvider( | 132 WebSocketDeterministicMockClientSocketFactoryMaker::AddSSLSocketDataProvider( |
133 scoped_ptr<SSLSocketDataProvider> ssl_socket_data) { | 133 scoped_ptr<SSLSocketDataProvider> ssl_socket_data) { |
134 detail_->factory.AddSSLSocketDataProvider(ssl_socket_data.get()); | 134 detail_->factory.AddSSLSocketDataProvider(ssl_socket_data.get()); |
135 detail_->ssl_socket_data_vector.push_back(ssl_socket_data.release()); | 135 detail_->ssl_socket_data_vector.push_back(ssl_socket_data.release()); |
136 } | 136 } |
137 | 137 |
138 WebSocketTestURLRequestContextHost::WebSocketTestURLRequestContextHost() | 138 WebSocketTestURLRequestContextHost::WebSocketTestURLRequestContextHost() |
139 : url_request_context_(true) { | 139 : url_request_context_(true), url_request_context_initialized_(false) { |
140 url_request_context_.set_client_socket_factory(maker_.factory()); | 140 url_request_context_.set_client_socket_factory(maker_.factory()); |
141 } | 141 } |
142 | 142 |
143 WebSocketTestURLRequestContextHost::~WebSocketTestURLRequestContextHost() {} | 143 WebSocketTestURLRequestContextHost::~WebSocketTestURLRequestContextHost() {} |
144 | 144 |
145 void WebSocketTestURLRequestContextHost::AddRawExpectations( | 145 void WebSocketTestURLRequestContextHost::AddRawExpectations( |
146 scoped_ptr<DeterministicSocketData> socket_data) { | 146 scoped_ptr<DeterministicSocketData> socket_data) { |
147 maker_.AddRawExpectations(socket_data.Pass()); | 147 maker_.AddRawExpectations(socket_data.Pass()); |
148 } | 148 } |
149 | 149 |
150 void WebSocketTestURLRequestContextHost::AddSSLSocketDataProvider( | 150 void WebSocketTestURLRequestContextHost::AddSSLSocketDataProvider( |
151 scoped_ptr<SSLSocketDataProvider> ssl_socket_data) { | 151 scoped_ptr<SSLSocketDataProvider> ssl_socket_data) { |
152 maker_.AddSSLSocketDataProvider(ssl_socket_data.Pass()); | 152 maker_.AddSSLSocketDataProvider(ssl_socket_data.Pass()); |
153 } | 153 } |
154 | 154 |
155 TestURLRequestContext* | 155 TestURLRequestContext* |
156 WebSocketTestURLRequestContextHost::GetURLRequestContext() { | 156 WebSocketTestURLRequestContextHost::GetURLRequestContext() { |
157 url_request_context_.Init(); | 157 if (!url_request_context_initialized_) { |
158 // A Network Delegate is required to make the URLRequest::Delegate work. | 158 url_request_context_.Init(); |
159 url_request_context_.set_network_delegate(&network_delegate_); | 159 // A Network Delegate is required to make the URLRequest::Delegate work. |
| 160 url_request_context_.set_network_delegate(&network_delegate_); |
| 161 url_request_context_initialized_ = true; |
| 162 } |
160 return &url_request_context_; | 163 return &url_request_context_; |
161 } | 164 } |
162 | 165 |
163 } // namespace net | 166 } // namespace net |
OLD | NEW |