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

Side by Side Diff: net/http/http_transaction_unittest.h

Issue 23856018: Changes to HttpNetworkTransaction for WebSocket Handshake (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rename SetWebSocketHandshakeCreateHelper Created 7 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « net/http/http_transaction.h ('k') | net/http/http_transaction_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef NET_HTTP_HTTP_TRANSACTION_UNITTEST_H_ 5 #ifndef NET_HTTP_HTTP_TRANSACTION_UNITTEST_H_
6 #define NET_HTTP_HTTP_TRANSACTION_UNITTEST_H_ 6 #define NET_HTTP_HTTP_TRANSACTION_UNITTEST_H_
7 7
8 #include "net/http/http_transaction.h" 8 #include "net/http/http_transaction.h"
9 9
10 #include <string> 10 #include <string>
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 155
156 class MockNetworkLayer; 156 class MockNetworkLayer;
157 157
158 // This transaction class inspects the available set of mock transactions to 158 // This transaction class inspects the available set of mock transactions to
159 // find data for the request URL. It supports IO operations that complete 159 // find data for the request URL. It supports IO operations that complete
160 // synchronously or asynchronously to help exercise different code paths in the 160 // synchronously or asynchronously to help exercise different code paths in the
161 // HttpCache implementation. 161 // HttpCache implementation.
162 class MockNetworkTransaction 162 class MockNetworkTransaction
163 : public net::HttpTransaction, 163 : public net::HttpTransaction,
164 public base::SupportsWeakPtr<MockNetworkTransaction> { 164 public base::SupportsWeakPtr<MockNetworkTransaction> {
165 typedef net::WebSocketHandshakeStreamBase::CreateHelper CreateHelper;
165 public: 166 public:
166 MockNetworkTransaction(net::RequestPriority priority, 167 MockNetworkTransaction(net::RequestPriority priority,
167 MockNetworkLayer* factory); 168 MockNetworkLayer* factory);
168 virtual ~MockNetworkTransaction(); 169 virtual ~MockNetworkTransaction();
169 170
170 virtual int Start(const net::HttpRequestInfo* request, 171 virtual int Start(const net::HttpRequestInfo* request,
171 const net::CompletionCallback& callback, 172 const net::CompletionCallback& callback,
172 const net::BoundNetLog& net_log) OVERRIDE; 173 const net::BoundNetLog& net_log) OVERRIDE;
173 174
174 virtual int RestartIgnoringLastError( 175 virtual int RestartIgnoringLastError(
(...skipping 23 matching lines...) Expand all
198 199
199 virtual net::LoadState GetLoadState() const OVERRIDE; 200 virtual net::LoadState GetLoadState() const OVERRIDE;
200 201
201 virtual net::UploadProgress GetUploadProgress() const OVERRIDE; 202 virtual net::UploadProgress GetUploadProgress() const OVERRIDE;
202 203
203 virtual bool GetLoadTimingInfo( 204 virtual bool GetLoadTimingInfo(
204 net::LoadTimingInfo* load_timing_info) const OVERRIDE; 205 net::LoadTimingInfo* load_timing_info) const OVERRIDE;
205 206
206 virtual void SetPriority(net::RequestPriority priority) OVERRIDE; 207 virtual void SetPriority(net::RequestPriority priority) OVERRIDE;
207 208
209 virtual void SetWebSocketHandshakeStreamCreateHelper(
210 CreateHelper* create_helper) OVERRIDE;
211
212 CreateHelper* websocket_handshake_stream_create_helper() {
213 return websocket_handshake_stream_create_helper_;
214 }
208 net::RequestPriority priority() const { return priority_; } 215 net::RequestPriority priority() const { return priority_; }
209 216
210 private: 217 private:
211 void CallbackLater(const net::CompletionCallback& callback, int result); 218 void CallbackLater(const net::CompletionCallback& callback, int result);
212 void RunCallback(const net::CompletionCallback& callback, int result); 219 void RunCallback(const net::CompletionCallback& callback, int result);
213 220
214 base::WeakPtrFactory<MockNetworkTransaction> weak_factory_; 221 base::WeakPtrFactory<MockNetworkTransaction> weak_factory_;
215 net::HttpResponseInfo response_; 222 net::HttpResponseInfo response_;
216 std::string data_; 223 std::string data_;
217 int data_cursor_; 224 int data_cursor_;
218 int test_mode_; 225 int test_mode_;
219 net::RequestPriority priority_; 226 net::RequestPriority priority_;
227 CreateHelper* websocket_handshake_stream_create_helper_;
220 base::WeakPtr<MockNetworkLayer> transaction_factory_; 228 base::WeakPtr<MockNetworkLayer> transaction_factory_;
221 229
222 // NetLog ID of the fake / non-existent underlying socket used by the 230 // NetLog ID of the fake / non-existent underlying socket used by the
223 // connection. Requires Start() be passed a BoundNetLog with a real NetLog to 231 // connection. Requires Start() be passed a BoundNetLog with a real NetLog to
224 // be initialized. 232 // be initialized.
225 unsigned int socket_log_id_; 233 unsigned int socket_log_id_;
226 }; 234 };
227 235
228 class MockNetworkLayer : public net::HttpTransactionFactory, 236 class MockNetworkLayer : public net::HttpTransactionFactory,
229 public base::SupportsWeakPtr<MockNetworkLayer> { 237 public base::SupportsWeakPtr<MockNetworkLayer> {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 base::WeakPtr<MockNetworkTransaction> last_transaction_; 279 base::WeakPtr<MockNetworkTransaction> last_transaction_;
272 }; 280 };
273 281
274 //----------------------------------------------------------------------------- 282 //-----------------------------------------------------------------------------
275 // helpers 283 // helpers
276 284
277 // read the transaction completely 285 // read the transaction completely
278 int ReadTransaction(net::HttpTransaction* trans, std::string* result); 286 int ReadTransaction(net::HttpTransaction* trans, std::string* result);
279 287
280 #endif // NET_HTTP_HTTP_TRANSACTION_UNITTEST_H_ 288 #endif // NET_HTTP_HTTP_TRANSACTION_UNITTEST_H_
OLDNEW
« no previous file with comments | « net/http/http_transaction.h ('k') | net/http/http_transaction_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698