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

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

Issue 683113005: Update from chromium https://crrev.com/302282 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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 | « net/disk_cache/cache_creator.cc ('k') | net/disk_cache/simple/simple_index_file.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 "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"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "base/threading/platform_thread.h" 12 #include "base/threading/platform_thread.h"
13 #include "base/timer/timer.h"
14 #include "net/base/completion_callback.h" 13 #include "net/base/completion_callback.h"
15 #include "net/base/io_buffer.h" 14 #include "net/base/io_buffer.h"
16 #include "net/base/net_errors.h" 15 #include "net/base/net_errors.h"
17 #include "net/base/test_completion_callback.h" 16 #include "net/base/test_completion_callback.h"
18 #include "net/disk_cache/blockfile/backend_impl.h" 17 #include "net/disk_cache/blockfile/backend_impl.h"
19 #include "net/disk_cache/blockfile/entry_impl.h" 18 #include "net/disk_cache/blockfile/entry_impl.h"
20 #include "net/disk_cache/disk_cache_test_base.h" 19 #include "net/disk_cache/disk_cache_test_base.h"
21 #include "net/disk_cache/disk_cache_test_util.h" 20 #include "net/disk_cache/disk_cache_test_util.h"
22 #include "net/disk_cache/memory/mem_entry_impl.h" 21 #include "net/disk_cache/memory/mem_entry_impl.h"
23 #include "net/disk_cache/simple/simple_entry_format.h" 22 #include "net/disk_cache/simple/simple_entry_format.h"
(...skipping 2300 matching lines...) Expand 10 before | Expand all | Expand 10 after
2324 memset(store->key + key.size(), 'k', sizeof(store->key) - key.size()); 2323 memset(store->key + key.size(), 'k', sizeof(store->key) - key.size());
2325 entry_impl->entry()->set_modified(); 2324 entry_impl->entry()->set_modified();
2326 entry->Close(); 2325 entry->Close();
2327 2326
2328 // We have a corrupt entry. Now reload it. We should NOT read beyond the 2327 // We have a corrupt entry. Now reload it. We should NOT read beyond the
2329 // allocated buffer here. 2328 // allocated buffer here.
2330 ASSERT_NE(net::OK, OpenEntry(key, &entry)); 2329 ASSERT_NE(net::OK, OpenEntry(key, &entry));
2331 DisableIntegrityCheck(); 2330 DisableIntegrityCheck();
2332 } 2331 }
2333 2332
2334 // The Simple Cache backend requires a few guarantees from the filesystem like
2335 // atomic renaming of recently open files. Those guarantees are not provided in
2336 // general on Windows.
2337 #if defined(OS_POSIX)
2338
2339 TEST_F(DiskCacheEntryTest, SimpleCacheInternalAsyncIO) { 2333 TEST_F(DiskCacheEntryTest, SimpleCacheInternalAsyncIO) {
2340 SetSimpleCacheMode(); 2334 SetSimpleCacheMode();
2341 InitCache(); 2335 InitCache();
2342 InternalAsyncIO(); 2336 InternalAsyncIO();
2343 } 2337 }
2344 2338
2345 TEST_F(DiskCacheEntryTest, SimpleCacheExternalAsyncIO) { 2339 TEST_F(DiskCacheEntryTest, SimpleCacheExternalAsyncIO) {
2346 SetSimpleCacheMode(); 2340 SetSimpleCacheMode();
2347 InitCache(); 2341 InitCache();
2348 ExternalAsyncIO(); 2342 ExternalAsyncIO();
(...skipping 1707 matching lines...) Expand 10 before | Expand all | Expand 10 after
4056 4050
4057 ret = entry->ReadSparseData(kSize, buffer.get(), kSize, callback.callback()); 4051 ret = entry->ReadSparseData(kSize, buffer.get(), kSize, callback.callback());
4058 EXPECT_EQ(kSize, callback.GetResult(ret)); 4052 EXPECT_EQ(kSize, callback.GetResult(ret));
4059 4053
4060 // Make sure the first range was removed when the second was written. 4054 // Make sure the first range was removed when the second was written.
4061 ret = entry->ReadSparseData(0, buffer.get(), kSize, callback.callback()); 4055 ret = entry->ReadSparseData(0, buffer.get(), kSize, callback.callback());
4062 EXPECT_EQ(0, callback.GetResult(ret)); 4056 EXPECT_EQ(0, callback.GetResult(ret));
4063 4057
4064 entry->Close(); 4058 entry->Close();
4065 } 4059 }
4066
4067 #endif // defined(OS_POSIX)
OLDNEW
« no previous file with comments | « net/disk_cache/cache_creator.cc ('k') | net/disk_cache/simple/simple_index_file.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698