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/files/file.h" | 8 #include "base/files/file.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 2045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2056 // The way a CompletionCallback works means that all tasks (even new ones) | 2056 // The way a CompletionCallback works means that all tasks (even new ones) |
2057 // are executed by the message loop before returning to the caller so the only | 2057 // are executed by the message loop before returning to the caller so the only |
2058 // way to simulate a race is to execute what we want on the callback. | 2058 // way to simulate a race is to execute what we want on the callback. |
2059 class SparseTestCompletionCallback: public net::TestCompletionCallback { | 2059 class SparseTestCompletionCallback: public net::TestCompletionCallback { |
2060 public: | 2060 public: |
2061 explicit SparseTestCompletionCallback(scoped_ptr<disk_cache::Backend> cache) | 2061 explicit SparseTestCompletionCallback(scoped_ptr<disk_cache::Backend> cache) |
2062 : cache_(cache.Pass()) { | 2062 : cache_(cache.Pass()) { |
2063 } | 2063 } |
2064 | 2064 |
2065 private: | 2065 private: |
2066 virtual void SetResult(int result) OVERRIDE { | 2066 virtual void SetResult(int result) override { |
2067 cache_.reset(); | 2067 cache_.reset(); |
2068 TestCompletionCallback::SetResult(result); | 2068 TestCompletionCallback::SetResult(result); |
2069 } | 2069 } |
2070 | 2070 |
2071 scoped_ptr<disk_cache::Backend> cache_; | 2071 scoped_ptr<disk_cache::Backend> cache_; |
2072 DISALLOW_COPY_AND_ASSIGN(SparseTestCompletionCallback); | 2072 DISALLOW_COPY_AND_ASSIGN(SparseTestCompletionCallback); |
2073 }; | 2073 }; |
2074 | 2074 |
2075 // Tests that we don't crash when the backend is deleted while we are working | 2075 // Tests that we don't crash when the backend is deleted while we are working |
2076 // deleting the sub-entries of a sparse entry. | 2076 // deleting the sub-entries of a sparse entry. |
(...skipping 1981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4058 EXPECT_EQ(kSize, callback.GetResult(ret)); | 4058 EXPECT_EQ(kSize, callback.GetResult(ret)); |
4059 | 4059 |
4060 // Make sure the first range was removed when the second was written. | 4060 // Make sure the first range was removed when the second was written. |
4061 ret = entry->ReadSparseData(0, buffer.get(), kSize, callback.callback()); | 4061 ret = entry->ReadSparseData(0, buffer.get(), kSize, callback.callback()); |
4062 EXPECT_EQ(0, callback.GetResult(ret)); | 4062 EXPECT_EQ(0, callback.GetResult(ret)); |
4063 | 4063 |
4064 entry->Close(); | 4064 entry->Close(); |
4065 } | 4065 } |
4066 | 4066 |
4067 #endif // defined(OS_POSIX) | 4067 #endif // defined(OS_POSIX) |
OLD | NEW |