| OLD | NEW |
| 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 #include "net/http/mock_http_cache.h" | 5 #include "net/http/mock_http_cache.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 int MockBackendFactory::CreateBackend( | 533 int MockBackendFactory::CreateBackend( |
| 534 NetLog* net_log, | 534 NetLog* net_log, |
| 535 std::unique_ptr<disk_cache::Backend>* backend, | 535 std::unique_ptr<disk_cache::Backend>* backend, |
| 536 const CompletionCallback& callback) { | 536 const CompletionCallback& callback) { |
| 537 backend->reset(new MockDiskCache()); | 537 backend->reset(new MockDiskCache()); |
| 538 return OK; | 538 return OK; |
| 539 } | 539 } |
| 540 | 540 |
| 541 //----------------------------------------------------------------------------- | 541 //----------------------------------------------------------------------------- |
| 542 | 542 |
| 543 MockHttpCache::MockHttpCache() | 543 MockHttpCache::MockHttpCache() : MockHttpCache(false) {} |
| 544 : MockHttpCache(base::MakeUnique<MockBackendFactory>()) {} | |
| 545 | 544 |
| 546 MockHttpCache::MockHttpCache( | 545 MockHttpCache::MockHttpCache( |
| 547 std::unique_ptr<HttpCache::BackendFactory> disk_cache_factory) | 546 std::unique_ptr<HttpCache::BackendFactory> disk_cache_factory) |
| 547 : MockHttpCache(std::move(disk_cache_factory), false) {} |
| 548 |
| 549 MockHttpCache::MockHttpCache(bool set_up_quic_server_info) |
| 550 : MockHttpCache(base::MakeUnique<MockBackendFactory>(), |
| 551 set_up_quic_server_info) {} |
| 552 |
| 553 MockHttpCache::MockHttpCache( |
| 554 std::unique_ptr<HttpCache::BackendFactory> disk_cache_factory, |
| 555 bool set_up_quic_server_info) |
| 548 : http_cache_(base::MakeUnique<MockNetworkLayer>(), | 556 : http_cache_(base::MakeUnique<MockNetworkLayer>(), |
| 549 std::move(disk_cache_factory), | 557 std::move(disk_cache_factory), |
| 550 true) {} | 558 set_up_quic_server_info) {} |
| 551 | 559 |
| 552 disk_cache::Backend* MockHttpCache::backend() { | 560 disk_cache::Backend* MockHttpCache::backend() { |
| 553 TestCompletionCallback cb; | 561 TestCompletionCallback cb; |
| 554 disk_cache::Backend* backend; | 562 disk_cache::Backend* backend; |
| 555 int rv = http_cache_.GetBackend(&backend, cb.callback()); | 563 int rv = http_cache_.GetBackend(&backend, cb.callback()); |
| 556 rv = cb.GetResult(rv); | 564 rv = cb.GetResult(rv); |
| 557 return (rv == OK) ? backend : NULL; | 565 return (rv == OK) ? backend : NULL; |
| 558 } | 566 } |
| 559 | 567 |
| 560 MockDiskCache* MockHttpCache::disk_cache() { | 568 MockDiskCache* MockHttpCache::disk_cache() { |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 683 if (!callback_.is_null()) { | 691 if (!callback_.is_null()) { |
| 684 if (!fail_) | 692 if (!fail_) |
| 685 backend_->reset(new MockDiskCache()); | 693 backend_->reset(new MockDiskCache()); |
| 686 CompletionCallback cb = callback_; | 694 CompletionCallback cb = callback_; |
| 687 callback_.Reset(); | 695 callback_.Reset(); |
| 688 cb.Run(Result()); // This object can be deleted here. | 696 cb.Run(Result()); // This object can be deleted here. |
| 689 } | 697 } |
| 690 } | 698 } |
| 691 | 699 |
| 692 } // namespace net | 700 } // namespace net |
| OLD | NEW |