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 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 SetRawExpectations(socket_data.Pass()); | 120 SetRawExpectations(socket_data.Pass()); |
121 } | 121 } |
122 | 122 |
123 void WebSocketDeterministicMockClientSocketFactoryMaker::SetRawExpectations( | 123 void WebSocketDeterministicMockClientSocketFactoryMaker::SetRawExpectations( |
124 scoped_ptr<DeterministicSocketData> socket_data) { | 124 scoped_ptr<DeterministicSocketData> socket_data) { |
125 detail_->data = socket_data.Pass(); | 125 detail_->data = socket_data.Pass(); |
126 detail_->factory.AddSocketDataProvider(detail_->data.get()); | 126 detail_->factory.AddSocketDataProvider(detail_->data.get()); |
127 } | 127 } |
128 | 128 |
129 WebSocketTestURLRequestContextHost::WebSocketTestURLRequestContextHost() | 129 WebSocketTestURLRequestContextHost::WebSocketTestURLRequestContextHost() |
130 : url_request_context_(true) { | 130 : url_request_context_(true), url_request_context_initialized_(false) { |
131 url_request_context_.set_client_socket_factory(maker_.factory()); | 131 url_request_context_.set_client_socket_factory(maker_.factory()); |
132 } | 132 } |
133 | 133 |
134 WebSocketTestURLRequestContextHost::~WebSocketTestURLRequestContextHost() {} | 134 WebSocketTestURLRequestContextHost::~WebSocketTestURLRequestContextHost() {} |
135 | 135 |
136 void WebSocketTestURLRequestContextHost::SetRawExpectations( | 136 void WebSocketTestURLRequestContextHost::SetRawExpectations( |
137 scoped_ptr<DeterministicSocketData> socket_data) { | 137 scoped_ptr<DeterministicSocketData> socket_data) { |
138 maker_.SetRawExpectations(socket_data.Pass()); | 138 maker_.SetRawExpectations(socket_data.Pass()); |
139 } | 139 } |
140 | 140 |
141 TestURLRequestContext* | 141 TestURLRequestContext* |
142 WebSocketTestURLRequestContextHost::GetURLRequestContext() { | 142 WebSocketTestURLRequestContextHost::GetURLRequestContext() { |
143 url_request_context_.Init(); | 143 if (!url_request_context_initialized_) { |
144 // A Network Delegate is required to make the URLRequest::Delegate work. | 144 url_request_context_.Init(); |
145 url_request_context_.set_network_delegate(&network_delegate_); | 145 // A Network Delegate is required to make the URLRequest::Delegate work. |
| 146 url_request_context_.set_network_delegate(&network_delegate_); |
| 147 url_request_context_initialized_ = true; |
| 148 } |
146 return &url_request_context_; | 149 return &url_request_context_; |
147 } | 150 } |
148 | 151 |
149 } // namespace net | 152 } // namespace net |
OLD | NEW |