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/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "net/base/completion_callback.h" | 9 #include "net/base/completion_callback.h" |
10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 int MockBackendFactory::CreateBackend(net::NetLog* net_log, | 490 int MockBackendFactory::CreateBackend(net::NetLog* net_log, |
491 scoped_ptr<disk_cache::Backend>* backend, | 491 scoped_ptr<disk_cache::Backend>* backend, |
492 const net::CompletionCallback& callback) { | 492 const net::CompletionCallback& callback) { |
493 backend->reset(new MockDiskCache()); | 493 backend->reset(new MockDiskCache()); |
494 return net::OK; | 494 return net::OK; |
495 } | 495 } |
496 | 496 |
497 //----------------------------------------------------------------------------- | 497 //----------------------------------------------------------------------------- |
498 | 498 |
499 MockHttpCache::MockHttpCache() | 499 MockHttpCache::MockHttpCache() |
500 : http_cache_(new MockNetworkLayer(), NULL, new MockBackendFactory()) { | 500 : http_cache_(new MockNetworkLayer(), NULL, new MockBackendFactory(), |
| 501 false) { |
501 } | 502 } |
502 | 503 |
503 MockHttpCache::MockHttpCache(net::HttpCache::BackendFactory* disk_cache_factory) | 504 MockHttpCache::MockHttpCache(net::HttpCache::BackendFactory* disk_cache_factory) |
504 : http_cache_(new MockNetworkLayer(), NULL, disk_cache_factory) { | 505 : http_cache_(new MockNetworkLayer(), NULL, disk_cache_factory, false) { |
505 } | 506 } |
506 | 507 |
507 MockDiskCache* MockHttpCache::disk_cache() { | 508 MockDiskCache* MockHttpCache::disk_cache() { |
508 net::TestCompletionCallback cb; | 509 net::TestCompletionCallback cb; |
509 disk_cache::Backend* backend; | 510 disk_cache::Backend* backend; |
510 int rv = http_cache_.GetBackend(&backend, cb.callback()); | 511 int rv = http_cache_.GetBackend(&backend, cb.callback()); |
511 rv = cb.GetResult(rv); | 512 rv = cb.GetResult(rv); |
512 return (rv == net::OK) ? static_cast<MockDiskCache*>(backend) : NULL; | 513 return (rv == net::OK) ? static_cast<MockDiskCache*>(backend) : NULL; |
513 } | 514 } |
514 | 515 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 void MockBlockingBackendFactory::FinishCreation() { | 623 void MockBlockingBackendFactory::FinishCreation() { |
623 block_ = false; | 624 block_ = false; |
624 if (!callback_.is_null()) { | 625 if (!callback_.is_null()) { |
625 if (!fail_) | 626 if (!fail_) |
626 backend_->reset(new MockDiskCache()); | 627 backend_->reset(new MockDiskCache()); |
627 net::CompletionCallback cb = callback_; | 628 net::CompletionCallback cb = callback_; |
628 callback_.Reset(); | 629 callback_.Reset(); |
629 cb.Run(Result()); // This object can be deleted here. | 630 cb.Run(Result()); // This object can be deleted here. |
630 } | 631 } |
631 } | 632 } |
OLD | NEW |