Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(167)

Side by Side Diff: net/disk_cache/entry_unittest.cc

Issue 2862943002: SimpleCache: try to recover on CreateEntry on missing cache dir (Closed)
Patch Set: Rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | net/disk_cache/simple/simple_synchronous_entry.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <utility> 5 #include <utility>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/files/file.h" 9 #include "base/files/file.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/run_loop.h" 12 #include "base/run_loop.h"
13 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
14 #include "base/strings/string_util.h" 14 #include "base/strings/string_util.h"
15 #include "base/test/histogram_tester.h" 15 #include "base/test/histogram_tester.h"
16 #include "base/threading/platform_thread.h" 16 #include "base/threading/platform_thread.h"
17 #include "net/base/completion_callback.h" 17 #include "net/base/completion_callback.h"
18 #include "net/base/io_buffer.h" 18 #include "net/base/io_buffer.h"
19 #include "net/base/net_errors.h" 19 #include "net/base/net_errors.h"
20 #include "net/base/test_completion_callback.h" 20 #include "net/base/test_completion_callback.h"
21 #include "net/disk_cache/blockfile/backend_impl.h" 21 #include "net/disk_cache/blockfile/backend_impl.h"
22 #include "net/disk_cache/blockfile/entry_impl.h" 22 #include "net/disk_cache/blockfile/entry_impl.h"
23 #include "net/disk_cache/cache_util.h"
23 #include "net/disk_cache/disk_cache_test_base.h" 24 #include "net/disk_cache/disk_cache_test_base.h"
24 #include "net/disk_cache/disk_cache_test_util.h" 25 #include "net/disk_cache/disk_cache_test_util.h"
25 #include "net/disk_cache/memory/mem_entry_impl.h" 26 #include "net/disk_cache/memory/mem_entry_impl.h"
26 #include "net/disk_cache/simple/simple_backend_impl.h" 27 #include "net/disk_cache/simple/simple_backend_impl.h"
27 #include "net/disk_cache/simple/simple_entry_format.h" 28 #include "net/disk_cache/simple/simple_entry_format.h"
28 #include "net/disk_cache/simple/simple_entry_impl.h" 29 #include "net/disk_cache/simple/simple_entry_impl.h"
29 #include "net/disk_cache/simple/simple_synchronous_entry.h" 30 #include "net/disk_cache/simple/simple_synchronous_entry.h"
30 #include "net/disk_cache/simple/simple_test_util.h" 31 #include "net/disk_cache/simple/simple_test_util.h"
31 #include "net/disk_cache/simple/simple_util.h" 32 #include "net/disk_cache/simple/simple_util.h"
32 #include "net/test/gtest_util.h" 33 #include "net/test/gtest_util.h"
(...skipping 4260 matching lines...) Expand 10 before | Expand all | Expand 10 after
4293 entry->Close(); 4294 entry->Close();
4294 4295
4295 base::RunLoop().RunUntilIdle(); 4296 base::RunLoop().RunUntilIdle();
4296 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting(); 4297 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting();
4297 base::RunLoop().RunUntilIdle(); 4298 base::RunLoop().RunUntilIdle();
4298 4299
4299 EXPECT_TRUE( 4300 EXPECT_TRUE(
4300 disk_cache::simple_util::CorruptStream0LengthFromEntry(key, cache_path_)); 4301 disk_cache::simple_util::CorruptStream0LengthFromEntry(key, cache_path_));
4301 EXPECT_NE(net::OK, OpenEntry(key, &entry)); 4302 EXPECT_NE(net::OK, OpenEntry(key, &entry));
4302 } 4303 }
4304
4305 TEST_F(DiskCacheEntryTest, SimpleCacheCreateRecoverFromRmdir) {
4306 // This test runs as APP_CACHE to make operations more synchronous.
4307 // (in particular we want to see if create succeeded or not, so we don't
4308 // want an optimistic one).
4309 SetCacheType(net::APP_CACHE);
4310 SetSimpleCacheMode();
4311 InitCache();
4312
4313 // Pretend someone deleted the cache dir. This shouldn't be too scary in
4314 // the test since cache_path_ is set as:
4315 // CHECK(temp_dir_.CreateUniqueTempDir());
4316 // cache_path_ = temp_dir_.GetPath();
4317 disk_cache::DeleteCache(cache_path_,
4318 true /* delete the dir, what we really want*/);
4319
4320 disk_cache::Entry* entry;
4321 std::string key("a key");
4322 ASSERT_THAT(CreateEntry(key, &entry), IsOk());
4323 entry->Close();
4324 }
OLDNEW
« no previous file with comments | « no previous file | net/disk_cache/simple/simple_synchronous_entry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698