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 #include "net/http/http_transaction_test_util.h" | 5 #include "net/http/http_transaction_test_util.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 void MockNetworkTransaction::RunCallback(const CompletionCallback& callback, | 493 void MockNetworkTransaction::RunCallback(const CompletionCallback& callback, |
494 int result) { | 494 int result) { |
495 callback.Run(result); | 495 callback.Run(result); |
496 } | 496 } |
497 | 497 |
498 MockNetworkLayer::MockNetworkLayer() | 498 MockNetworkLayer::MockNetworkLayer() |
499 : transaction_count_(0), | 499 : transaction_count_(0), |
500 done_reading_called_(false), | 500 done_reading_called_(false), |
501 stop_caching_called_(false), | 501 stop_caching_called_(false), |
502 last_create_transaction_priority_(DEFAULT_PRIORITY), | 502 last_create_transaction_priority_(DEFAULT_PRIORITY), |
503 clock_(nullptr) { | 503 clock_(nullptr), |
504 } | 504 session_(nullptr) {} |
505 | 505 |
506 MockNetworkLayer::~MockNetworkLayer() {} | 506 MockNetworkLayer::~MockNetworkLayer() {} |
507 | 507 |
508 void MockNetworkLayer::TransactionDoneReading() { | 508 void MockNetworkLayer::TransactionDoneReading() { |
509 done_reading_called_ = true; | 509 done_reading_called_ = true; |
510 } | 510 } |
511 | 511 |
512 void MockNetworkLayer::TransactionStopCaching() { | 512 void MockNetworkLayer::TransactionStopCaching() { |
513 stop_caching_called_ = true; | 513 stop_caching_called_ = true; |
514 } | 514 } |
515 | 515 |
516 int MockNetworkLayer::CreateTransaction(RequestPriority priority, | 516 int MockNetworkLayer::CreateTransaction(RequestPriority priority, |
517 scoped_ptr<HttpTransaction>* trans) { | 517 scoped_ptr<HttpTransaction>* trans) { |
518 transaction_count_++; | 518 transaction_count_++; |
519 last_create_transaction_priority_ = priority; | 519 last_create_transaction_priority_ = priority; |
520 scoped_ptr<MockNetworkTransaction> mock_transaction( | 520 scoped_ptr<MockNetworkTransaction> mock_transaction( |
521 new MockNetworkTransaction(priority, this)); | 521 new MockNetworkTransaction(priority, this)); |
522 last_transaction_ = mock_transaction->AsWeakPtr(); | 522 last_transaction_ = mock_transaction->AsWeakPtr(); |
523 *trans = mock_transaction.Pass(); | 523 *trans = mock_transaction.Pass(); |
524 return OK; | 524 return OK; |
525 } | 525 } |
526 | 526 |
527 HttpCache* MockNetworkLayer::GetCache() { | 527 HttpCache* MockNetworkLayer::GetCache() { |
528 return NULL; | 528 return NULL; |
529 } | 529 } |
530 | 530 |
531 HttpNetworkSession* MockNetworkLayer::GetSession() { | 531 HttpNetworkSession* MockNetworkLayer::GetSession() { |
532 return NULL; | 532 return session_; |
533 } | 533 } |
534 | 534 |
535 void MockNetworkLayer::SetClock(base::Clock* clock) { | 535 void MockNetworkLayer::SetClock(base::Clock* clock) { |
536 DCHECK(!clock_); | 536 DCHECK(!clock_); |
537 clock_ = clock; | 537 clock_ = clock; |
538 } | 538 } |
539 | 539 |
540 base::Time MockNetworkLayer::Now() { | 540 base::Time MockNetworkLayer::Now() { |
541 if (clock_) | 541 if (clock_) |
542 return clock_->Now(); | 542 return clock_->Now(); |
(...skipping 19 matching lines...) Expand all Loading... |
562 content.append(buf->data(), rv); | 562 content.append(buf->data(), rv); |
563 else if (rv < 0) | 563 else if (rv < 0) |
564 return rv; | 564 return rv; |
565 } while (rv > 0); | 565 } while (rv > 0); |
566 | 566 |
567 result->swap(content); | 567 result->swap(content); |
568 return OK; | 568 return OK; |
569 } | 569 } |
570 | 570 |
571 } // namespace net | 571 } // namespace net |
OLD | NEW |