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 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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() |
544 : MockHttpCache(base::WrapUnique(new MockBackendFactory())) {} | 544 : MockHttpCache(base::MakeUnique<MockBackendFactory>()) {} |
545 | 545 |
546 MockHttpCache::MockHttpCache( | 546 MockHttpCache::MockHttpCache( |
547 std::unique_ptr<HttpCache::BackendFactory> disk_cache_factory) | 547 std::unique_ptr<HttpCache::BackendFactory> disk_cache_factory) |
548 : http_cache_(base::WrapUnique(new MockNetworkLayer()), | 548 : http_cache_(base::MakeUnique<MockNetworkLayer>(), |
549 std::move(disk_cache_factory), | 549 std::move(disk_cache_factory), |
550 true) {} | 550 true) {} |
551 | 551 |
552 disk_cache::Backend* MockHttpCache::backend() { | 552 disk_cache::Backend* MockHttpCache::backend() { |
553 TestCompletionCallback cb; | 553 TestCompletionCallback cb; |
554 disk_cache::Backend* backend; | 554 disk_cache::Backend* backend; |
555 int rv = http_cache_.GetBackend(&backend, cb.callback()); | 555 int rv = http_cache_.GetBackend(&backend, cb.callback()); |
556 rv = cb.GetResult(rv); | 556 rv = cb.GetResult(rv); |
557 return (rv == OK) ? backend : NULL; | 557 return (rv == OK) ? backend : NULL; |
558 } | 558 } |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 if (!callback_.is_null()) { | 683 if (!callback_.is_null()) { |
684 if (!fail_) | 684 if (!fail_) |
685 backend_->reset(new MockDiskCache()); | 685 backend_->reset(new MockDiskCache()); |
686 CompletionCallback cb = callback_; | 686 CompletionCallback cb = callback_; |
687 callback_.Reset(); | 687 callback_.Reset(); |
688 cb.Run(Result()); // This object can be deleted here. | 688 cb.Run(Result()); // This object can be deleted here. |
689 } | 689 } |
690 } | 690 } |
691 | 691 |
692 } // namespace net | 692 } // namespace net |
OLD | NEW |