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