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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
284 void ClearLastTransaction() { | 284 void ClearLastTransaction() { |
285 last_transaction_.reset(); | 285 last_transaction_.reset(); |
286 } | 286 } |
287 | 287 |
288 // net::HttpTransactionFactory: | 288 // net::HttpTransactionFactory: |
289 int CreateTransaction(net::RequestPriority priority, | 289 int CreateTransaction(net::RequestPriority priority, |
290 scoped_ptr<net::HttpTransaction>* trans) override; | 290 scoped_ptr<net::HttpTransaction>* trans) override; |
291 net::HttpCache* GetCache() override; | 291 net::HttpCache* GetCache() override; |
292 net::HttpNetworkSession* GetSession() override; | 292 net::HttpNetworkSession* GetSession() override; |
293 | 293 |
294 // The caller must guarantee that |clock| will outlive this object. | |
295 void set_clock(base::Clock* clock) { | |
296 DCHECK(!clock_); | |
rvargas (doing something else)
2015/01/09 02:25:34
Logging doesn't qualify anymore as trivial accesso
jkarlin
2015/01/09 14:03:51
Done.
| |
297 clock_ = clock; | |
298 } | |
299 base::Clock* clock() const { return clock_; } | |
300 | |
301 // The current time (will use clock_ if it is non NULL). | |
302 base::Time Now(); | |
303 | |
294 private: | 304 private: |
295 int transaction_count_; | 305 int transaction_count_; |
296 bool done_reading_called_; | 306 bool done_reading_called_; |
297 bool stop_caching_called_; | 307 bool stop_caching_called_; |
298 net::RequestPriority last_create_transaction_priority_; | 308 net::RequestPriority last_create_transaction_priority_; |
309 | |
310 // By default clock_ is NULL but it can be set to a custom clock by test | |
311 // frameworks using set_clock. | |
312 base::Clock* clock_; | |
313 | |
299 base::WeakPtr<MockNetworkTransaction> last_transaction_; | 314 base::WeakPtr<MockNetworkTransaction> last_transaction_; |
300 }; | 315 }; |
301 | 316 |
302 //----------------------------------------------------------------------------- | 317 //----------------------------------------------------------------------------- |
303 // helpers | 318 // helpers |
304 | 319 |
305 // read the transaction completely | 320 // read the transaction completely |
306 int ReadTransaction(net::HttpTransaction* trans, std::string* result); | 321 int ReadTransaction(net::HttpTransaction* trans, std::string* result); |
307 | 322 |
308 #endif // NET_HTTP_HTTP_TRANSACTION_UNITTEST_H_ | 323 #endif // NET_HTTP_HTTP_TRANSACTION_UNITTEST_H_ |
OLD | NEW |