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 | 9 |
9 #include "base/bind.h" | 10 #include "base/bind.h" |
10 #include "base/location.h" | 11 #include "base/location.h" |
11 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
12 #include "base/thread_task_runner_handle.h" | 13 #include "base/thread_task_runner_handle.h" |
13 #include "net/base/completion_callback.h" | 14 #include "net/base/completion_callback.h" |
14 #include "net/base/net_errors.h" | 15 #include "net/base/net_errors.h" |
15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
16 | 17 |
17 namespace net { | 18 namespace net { |
(...skipping 507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
525 } | 526 } |
526 | 527 |
527 //----------------------------------------------------------------------------- | 528 //----------------------------------------------------------------------------- |
528 | 529 |
529 MockHttpCache::MockHttpCache() | 530 MockHttpCache::MockHttpCache() |
530 : MockHttpCache(make_scoped_ptr(new MockBackendFactory())) {} | 531 : MockHttpCache(make_scoped_ptr(new MockBackendFactory())) {} |
531 | 532 |
532 MockHttpCache::MockHttpCache( | 533 MockHttpCache::MockHttpCache( |
533 scoped_ptr<HttpCache::BackendFactory> disk_cache_factory) | 534 scoped_ptr<HttpCache::BackendFactory> disk_cache_factory) |
534 : http_cache_(make_scoped_ptr(new MockNetworkLayer()), | 535 : http_cache_(make_scoped_ptr(new MockNetworkLayer()), |
535 disk_cache_factory.Pass(), | 536 std::move(disk_cache_factory), |
536 true) {} | 537 true) {} |
537 | 538 |
538 disk_cache::Backend* MockHttpCache::backend() { | 539 disk_cache::Backend* MockHttpCache::backend() { |
539 TestCompletionCallback cb; | 540 TestCompletionCallback cb; |
540 disk_cache::Backend* backend; | 541 disk_cache::Backend* backend; |
541 int rv = http_cache_.GetBackend(&backend, cb.callback()); | 542 int rv = http_cache_.GetBackend(&backend, cb.callback()); |
542 rv = cb.GetResult(rv); | 543 rv = cb.GetResult(rv); |
543 return (rv == OK) ? backend : NULL; | 544 return (rv == OK) ? backend : NULL; |
544 } | 545 } |
545 | 546 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 if (!callback_.is_null()) { | 670 if (!callback_.is_null()) { |
670 if (!fail_) | 671 if (!fail_) |
671 backend_->reset(new MockDiskCache()); | 672 backend_->reset(new MockDiskCache()); |
672 CompletionCallback cb = callback_; | 673 CompletionCallback cb = callback_; |
673 callback_.Reset(); | 674 callback_.Reset(); |
674 cb.Run(Result()); // This object can be deleted here. | 675 cb.Run(Result()); // This object can be deleted here. |
675 } | 676 } |
676 } | 677 } |
677 | 678 |
678 } // namespace net | 679 } // namespace net |
OLD | NEW |