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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/location.h" | 8 #include "base/location.h" |
9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 | 512 |
513 int MockBackendFactory::CreateBackend(NetLog* net_log, | 513 int MockBackendFactory::CreateBackend(NetLog* net_log, |
514 scoped_ptr<disk_cache::Backend>* backend, | 514 scoped_ptr<disk_cache::Backend>* backend, |
515 const CompletionCallback& callback) { | 515 const CompletionCallback& callback) { |
516 backend->reset(new MockDiskCache()); | 516 backend->reset(new MockDiskCache()); |
517 return OK; | 517 return OK; |
518 } | 518 } |
519 | 519 |
520 //----------------------------------------------------------------------------- | 520 //----------------------------------------------------------------------------- |
521 | 521 |
522 MockHttpCache::MockHttpCache() : MockHttpCache(new MockBackendFactory()) {} | 522 MockHttpCache::MockHttpCache() |
| 523 : http_cache_(new MockNetworkLayer(), NULL, new MockBackendFactory()) { |
| 524 } |
523 | 525 |
524 MockHttpCache::MockHttpCache(HttpCache::BackendFactory* disk_cache_factory) | 526 MockHttpCache::MockHttpCache(HttpCache::BackendFactory* disk_cache_factory) |
525 : http_cache_(new MockNetworkLayer(), nullptr, disk_cache_factory, true) {} | 527 : http_cache_(new MockNetworkLayer(), NULL, disk_cache_factory) { |
| 528 } |
526 | 529 |
527 disk_cache::Backend* MockHttpCache::backend() { | 530 disk_cache::Backend* MockHttpCache::backend() { |
528 TestCompletionCallback cb; | 531 TestCompletionCallback cb; |
529 disk_cache::Backend* backend; | 532 disk_cache::Backend* backend; |
530 int rv = http_cache_.GetBackend(&backend, cb.callback()); | 533 int rv = http_cache_.GetBackend(&backend, cb.callback()); |
531 rv = cb.GetResult(rv); | 534 rv = cb.GetResult(rv); |
532 return (rv == OK) ? backend : NULL; | 535 return (rv == OK) ? backend : NULL; |
533 } | 536 } |
534 | 537 |
535 MockDiskCache* MockHttpCache::disk_cache() { | 538 MockDiskCache* MockHttpCache::disk_cache() { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 if (!callback_.is_null()) { | 661 if (!callback_.is_null()) { |
659 if (!fail_) | 662 if (!fail_) |
660 backend_->reset(new MockDiskCache()); | 663 backend_->reset(new MockDiskCache()); |
661 CompletionCallback cb = callback_; | 664 CompletionCallback cb = callback_; |
662 callback_.Reset(); | 665 callback_.Reset(); |
663 cb.Run(Result()); // This object can be deleted here. | 666 cb.Run(Result()); // This object can be deleted here. |
664 } | 667 } |
665 } | 668 } |
666 | 669 |
667 } // namespace net | 670 } // namespace net |
OLD | NEW |