| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/bind_helpers.h" | 7 #include "base/bind_helpers.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/threading/platform_thread.h" | 9 #include "base/threading/platform_thread.h" |
| 10 #include "base/timer.h" | 10 #include "base/timer.h" |
| (...skipping 1768 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1779 TEST_F(DiskCacheEntryTest, MemoryOnlyDoomSparseEntry) { | 1779 TEST_F(DiskCacheEntryTest, MemoryOnlyDoomSparseEntry) { |
| 1780 SetMemoryOnlyMode(); | 1780 SetMemoryOnlyMode(); |
| 1781 InitCache(); | 1781 InitCache(); |
| 1782 DoomSparseEntry(); | 1782 DoomSparseEntry(); |
| 1783 } | 1783 } |
| 1784 | 1784 |
| 1785 // A CompletionCallback wrapper that deletes the cache from within the callback. | 1785 // A CompletionCallback wrapper that deletes the cache from within the callback. |
| 1786 // The way an CompletionCallback works means that all tasks (even new ones) | 1786 // The way an CompletionCallback works means that all tasks (even new ones) |
| 1787 // are executed by the message loop before returning to the caller so the only | 1787 // are executed by the message loop before returning to the caller so the only |
| 1788 // way to simulate a race is to execute what we want on the callback. | 1788 // way to simulate a race is to execute what we want on the callback. |
| 1789 class SparseTestCompletionCallback: public TestCompletionCallbackBase { | 1789 class SparseTestCompletionCallback: public net::TestCompletionCallbackBase { |
| 1790 public: | 1790 public: |
| 1791 explicit SparseTestCompletionCallback(disk_cache::Backend* cache) | 1791 explicit SparseTestCompletionCallback(disk_cache::Backend* cache) |
| 1792 : cache_(cache), | 1792 : cache_(cache), |
| 1793 ALLOW_THIS_IN_INITIALIZER_LIST(callback_( | 1793 ALLOW_THIS_IN_INITIALIZER_LIST(callback_( |
| 1794 base::Bind(&SparseTestCompletionCallback::OnComplete, | 1794 base::Bind(&SparseTestCompletionCallback::OnComplete, |
| 1795 base::Unretained(this)))) { | 1795 base::Unretained(this)))) { |
| 1796 } | 1796 } |
| 1797 | 1797 |
| 1798 const net::CompletionCallback& callback() const { return callback_; } | 1798 const net::CompletionCallback& callback() const { return callback_; } |
| 1799 | 1799 |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2061 store->key_len = 800; | 2061 store->key_len = 800; |
| 2062 memset(store->key + key.size(), 'k', sizeof(store->key) - key.size()); | 2062 memset(store->key + key.size(), 'k', sizeof(store->key) - key.size()); |
| 2063 entry_impl->entry()->set_modified(); | 2063 entry_impl->entry()->set_modified(); |
| 2064 entry->Close(); | 2064 entry->Close(); |
| 2065 | 2065 |
| 2066 // We have a corrupt entry. Now reload it. We should NOT read beyond the | 2066 // We have a corrupt entry. Now reload it. We should NOT read beyond the |
| 2067 // allocated buffer here. | 2067 // allocated buffer here. |
| 2068 ASSERT_NE(net::OK, OpenEntry(key, &entry)); | 2068 ASSERT_NE(net::OK, OpenEntry(key, &entry)); |
| 2069 DisableIntegrityCheck(); | 2069 DisableIntegrityCheck(); |
| 2070 } | 2070 } |
| OLD | NEW |