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 528 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 } | 539 } |
540 | 540 |
541 //----------------------------------------------------------------------------- | 541 //----------------------------------------------------------------------------- |
542 | 542 |
543 MockHttpCache::MockHttpCache() : MockHttpCache(false) {} | 543 MockHttpCache::MockHttpCache() : MockHttpCache(false) {} |
544 | 544 |
545 MockHttpCache::MockHttpCache( | 545 MockHttpCache::MockHttpCache( |
546 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) {} | 547 : MockHttpCache(std::move(disk_cache_factory), false) {} |
548 | 548 |
549 MockHttpCache::MockHttpCache(bool set_up_quic_server_info) | 549 MockHttpCache::MockHttpCache(bool is_main_cache) |
550 : MockHttpCache(base::MakeUnique<MockBackendFactory>(), | 550 : MockHttpCache(base::MakeUnique<MockBackendFactory>(), is_main_cache) {} |
551 set_up_quic_server_info) {} | |
552 | 551 |
553 MockHttpCache::MockHttpCache( | 552 MockHttpCache::MockHttpCache( |
554 std::unique_ptr<HttpCache::BackendFactory> disk_cache_factory, | 553 std::unique_ptr<HttpCache::BackendFactory> disk_cache_factory, |
555 bool set_up_quic_server_info) | 554 bool is_main_cache) |
556 : http_cache_(base::MakeUnique<MockNetworkLayer>(), | 555 : http_cache_(base::MakeUnique<MockNetworkLayer>(), |
557 std::move(disk_cache_factory), | 556 std::move(disk_cache_factory), |
558 set_up_quic_server_info) {} | 557 is_main_cache) {} |
559 | 558 |
560 disk_cache::Backend* MockHttpCache::backend() { | 559 disk_cache::Backend* MockHttpCache::backend() { |
561 TestCompletionCallback cb; | 560 TestCompletionCallback cb; |
562 disk_cache::Backend* backend; | 561 disk_cache::Backend* backend; |
563 int rv = http_cache_.GetBackend(&backend, cb.callback()); | 562 int rv = http_cache_.GetBackend(&backend, cb.callback()); |
564 rv = cb.GetResult(rv); | 563 rv = cb.GetResult(rv); |
565 return (rv == OK) ? backend : NULL; | 564 return (rv == OK) ? backend : NULL; |
566 } | 565 } |
567 | 566 |
568 MockDiskCache* MockHttpCache::disk_cache() { | 567 MockDiskCache* MockHttpCache::disk_cache() { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
691 if (!callback_.is_null()) { | 690 if (!callback_.is_null()) { |
692 if (!fail_) | 691 if (!fail_) |
693 backend_->reset(new MockDiskCache()); | 692 backend_->reset(new MockDiskCache()); |
694 CompletionCallback cb = callback_; | 693 CompletionCallback cb = callback_; |
695 callback_.Reset(); | 694 callback_.Reset(); |
696 cb.Run(Result()); // This object can be deleted here. | 695 cb.Run(Result()); // This object can be deleted here. |
697 } | 696 } |
698 } | 697 } |
699 | 698 |
700 } // namespace net | 699 } // namespace net |
OLD | NEW |