| 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 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 } | 517 } |
| 518 | 518 |
| 519 int MockHttpCache::CreateTransaction(scoped_ptr<net::HttpTransaction>* trans) { | 519 int MockHttpCache::CreateTransaction(scoped_ptr<net::HttpTransaction>* trans) { |
| 520 return http_cache_.CreateTransaction(net::DEFAULT_PRIORITY, trans); | 520 return http_cache_.CreateTransaction(net::DEFAULT_PRIORITY, trans); |
| 521 } | 521 } |
| 522 | 522 |
| 523 void MockHttpCache::BypassCacheLock() { | 523 void MockHttpCache::BypassCacheLock() { |
| 524 http_cache_.BypassLockForTest(); | 524 http_cache_.BypassLockForTest(); |
| 525 } | 525 } |
| 526 | 526 |
| 527 void MockHttpCache::FailConditionalizations() { |
| 528 http_cache_.FailConditionalizationForTest(); |
| 529 } |
| 530 |
| 527 bool MockHttpCache::ReadResponseInfo(disk_cache::Entry* disk_entry, | 531 bool MockHttpCache::ReadResponseInfo(disk_cache::Entry* disk_entry, |
| 528 net::HttpResponseInfo* response_info, | 532 net::HttpResponseInfo* response_info, |
| 529 bool* response_truncated) { | 533 bool* response_truncated) { |
| 530 int size = disk_entry->GetDataSize(0); | 534 int size = disk_entry->GetDataSize(0); |
| 531 | 535 |
| 532 net::TestCompletionCallback cb; | 536 net::TestCompletionCallback cb; |
| 533 scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(size)); | 537 scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(size)); |
| 534 int rv = disk_entry->ReadData(0, 0, buffer.get(), size, cb.callback()); | 538 int rv = disk_entry->ReadData(0, 0, buffer.get(), size, cb.callback()); |
| 535 rv = cb.GetResult(rv); | 539 rv = cb.GetResult(rv); |
| 536 EXPECT_EQ(size, rv); | 540 EXPECT_EQ(size, rv); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 void MockBlockingBackendFactory::FinishCreation() { | 634 void MockBlockingBackendFactory::FinishCreation() { |
| 631 block_ = false; | 635 block_ = false; |
| 632 if (!callback_.is_null()) { | 636 if (!callback_.is_null()) { |
| 633 if (!fail_) | 637 if (!fail_) |
| 634 backend_->reset(new MockDiskCache()); | 638 backend_->reset(new MockDiskCache()); |
| 635 net::CompletionCallback cb = callback_; | 639 net::CompletionCallback cb = callback_; |
| 636 callback_.Reset(); | 640 callback_.Reset(); |
| 637 cb.Run(Result()); // This object can be deleted here. | 641 cb.Run(Result()); // This object can be deleted here. |
| 638 } | 642 } |
| 639 } | 643 } |
| OLD | NEW |