OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 net::RequestPriority priority() const { return priority_; } | 230 net::RequestPriority priority() const { return priority_; } |
231 const net::HttpRequestInfo* request() const { return request_; } | 231 const net::HttpRequestInfo* request() const { return request_; } |
232 | 232 |
233 private: | 233 private: |
234 int StartInternal(const net::HttpRequestInfo* request, | 234 int StartInternal(const net::HttpRequestInfo* request, |
235 const net::CompletionCallback& callback, | 235 const net::CompletionCallback& callback, |
236 const net::BoundNetLog& net_log); | 236 const net::BoundNetLog& net_log); |
237 void CallbackLater(const net::CompletionCallback& callback, int result); | 237 void CallbackLater(const net::CompletionCallback& callback, int result); |
238 void RunCallback(const net::CompletionCallback& callback, int result); | 238 void RunCallback(const net::CompletionCallback& callback, int result); |
239 | 239 |
240 base::WeakPtrFactory<MockNetworkTransaction> weak_factory_; | |
241 const net::HttpRequestInfo* request_; | 240 const net::HttpRequestInfo* request_; |
242 net::HttpResponseInfo response_; | 241 net::HttpResponseInfo response_; |
243 std::string data_; | 242 std::string data_; |
244 int data_cursor_; | 243 int data_cursor_; |
245 int test_mode_; | 244 int test_mode_; |
246 net::RequestPriority priority_; | 245 net::RequestPriority priority_; |
247 CreateHelper* websocket_handshake_stream_create_helper_; | 246 CreateHelper* websocket_handshake_stream_create_helper_; |
248 base::WeakPtr<MockNetworkLayer> transaction_factory_; | 247 base::WeakPtr<MockNetworkLayer> transaction_factory_; |
249 int64 received_bytes_; | 248 int64 received_bytes_; |
250 | 249 |
251 // NetLog ID of the fake / non-existent underlying socket used by the | 250 // NetLog ID of the fake / non-existent underlying socket used by the |
252 // connection. Requires Start() be passed a BoundNetLog with a real NetLog to | 251 // connection. Requires Start() be passed a BoundNetLog with a real NetLog to |
253 // be initialized. | 252 // be initialized. |
254 unsigned int socket_log_id_; | 253 unsigned int socket_log_id_; |
| 254 |
| 255 base::WeakPtrFactory<MockNetworkTransaction> weak_factory_; |
| 256 |
255 }; | 257 }; |
256 | 258 |
257 class MockNetworkLayer : public net::HttpTransactionFactory, | 259 class MockNetworkLayer : public net::HttpTransactionFactory, |
258 public base::SupportsWeakPtr<MockNetworkLayer> { | 260 public base::SupportsWeakPtr<MockNetworkLayer> { |
259 public: | 261 public: |
260 MockNetworkLayer(); | 262 MockNetworkLayer(); |
261 virtual ~MockNetworkLayer(); | 263 virtual ~MockNetworkLayer(); |
262 | 264 |
263 int transaction_count() const { return transaction_count_; } | 265 int transaction_count() const { return transaction_count_; } |
264 bool done_reading_called() const { return done_reading_called_; } | 266 bool done_reading_called() const { return done_reading_called_; } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 base::WeakPtr<MockNetworkTransaction> last_transaction_; | 304 base::WeakPtr<MockNetworkTransaction> last_transaction_; |
303 }; | 305 }; |
304 | 306 |
305 //----------------------------------------------------------------------------- | 307 //----------------------------------------------------------------------------- |
306 // helpers | 308 // helpers |
307 | 309 |
308 // read the transaction completely | 310 // read the transaction completely |
309 int ReadTransaction(net::HttpTransaction* trans, std::string* result); | 311 int ReadTransaction(net::HttpTransaction* trans, std::string* result); |
310 | 312 |
311 #endif // NET_HTTP_HTTP_TRANSACTION_UNITTEST_H_ | 313 #endif // NET_HTTP_HTTP_TRANSACTION_UNITTEST_H_ |
OLD | NEW |