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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include "base/files/file.h" | 7 #include "base/files/file.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 #define CACHE_UMA_BACKEND_IMPL_OBJ backend_ | 56 #define CACHE_UMA_BACKEND_IMPL_OBJ backend_ |
57 | 57 |
58 using base::Time; | 58 using base::Time; |
59 | 59 |
60 namespace { | 60 namespace { |
61 | 61 |
62 const char kExistingEntryKey[] = "existing entry key"; | 62 const char kExistingEntryKey[] = "existing entry key"; |
63 | 63 |
64 std::unique_ptr<disk_cache::BackendImpl> CreateExistingEntryCache( | 64 std::unique_ptr<disk_cache::BackendImpl> CreateExistingEntryCache( |
65 const base::Thread& cache_thread, | 65 const base::Thread& cache_thread, |
66 base::FilePath& cache_path) { | 66 const base::FilePath& cache_path) { |
67 net::TestCompletionCallback cb; | 67 net::TestCompletionCallback cb; |
68 | 68 |
69 std::unique_ptr<disk_cache::BackendImpl> cache(new disk_cache::BackendImpl( | 69 std::unique_ptr<disk_cache::BackendImpl> cache(new disk_cache::BackendImpl( |
70 cache_path, cache_thread.task_runner(), NULL)); | 70 cache_path, cache_thread.task_runner(), NULL)); |
71 int rv = cache->Init(cb.callback()); | 71 int rv = cache->Init(cb.callback()); |
72 if (cb.GetResult(rv) != net::OK) | 72 if (cb.GetResult(rv) != net::OK) |
73 return std::unique_ptr<disk_cache::BackendImpl>(); | 73 return std::unique_ptr<disk_cache::BackendImpl>(); |
74 | 74 |
75 disk_cache::Entry* entry = NULL; | 75 disk_cache::Entry* entry = NULL; |
76 rv = cache->CreateEntry(kExistingEntryKey, &entry, cb.callback()); | 76 rv = cache->CreateEntry(kExistingEntryKey, &entry, cb.callback()); |
(...skipping 4008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4085 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting(); | 4085 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting(); |
4086 base::RunLoop().RunUntilIdle(); | 4086 base::RunLoop().RunUntilIdle(); |
4087 | 4087 |
4088 disk_cache::Entry* reopen_entry1; | 4088 disk_cache::Entry* reopen_entry1; |
4089 ASSERT_THAT(OpenEntry(key1, &reopen_entry1), IsOk()); | 4089 ASSERT_THAT(OpenEntry(key1, &reopen_entry1), IsOk()); |
4090 | 4090 |
4091 // This shouldn't pick up entry2's write time incorrectly. | 4091 // This shouldn't pick up entry2's write time incorrectly. |
4092 EXPECT_LE(reopen_entry1->GetLastModified(), entry1_timestamp); | 4092 EXPECT_LE(reopen_entry1->GetLastModified(), entry1_timestamp); |
4093 reopen_entry1->Close(); | 4093 reopen_entry1->Close(); |
4094 } | 4094 } |
OLD | NEW |