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

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

Issue 127083002: **STILLBAKING** Decouple disk cache tests from backends. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: upstream rebase Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « net/disk_cache/disk_cache_test_util.h ('k') | net/disk_cache/entry_sync_tests.h » ('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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "net/disk_cache/disk_cache_test_util.h" 5 #include "net/disk_cache/disk_cache_test_util.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/message_loop/message_loop_proxy.h" 9 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 28 matching lines...) Expand all
39 } 39 }
40 if (len && !buffer[0]) 40 if (len && !buffer[0])
41 buffer[0] = 'g'; 41 buffer[0] = 'g';
42 } 42 }
43 43
44 bool CreateCacheTestFile(const base::FilePath& name) { 44 bool CreateCacheTestFile(const base::FilePath& name) {
45 int flags = base::PLATFORM_FILE_CREATE_ALWAYS | 45 int flags = base::PLATFORM_FILE_CREATE_ALWAYS |
46 base::PLATFORM_FILE_READ | 46 base::PLATFORM_FILE_READ |
47 base::PLATFORM_FILE_WRITE; 47 base::PLATFORM_FILE_WRITE;
48 48
49 scoped_refptr<disk_cache::File> file(new disk_cache::File( 49 base::PlatformFile file = base::CreatePlatformFile(name, flags, NULL, NULL);
50 base::CreatePlatformFile(name, flags, NULL, NULL))); 50 if (file == base::kInvalidPlatformFileValue)
51 if (!file->IsValid())
52 return false; 51 return false;
53 52
54 file->SetLength(4 * 1024 * 1024); 53 base::TruncatePlatformFile(file, 4 * 1024 * 1024);
55 return true; 54 return true;
56 } 55 }
57 56
58 bool DeleteCache(const base::FilePath& path) { 57 bool DeleteCache(const base::FilePath& path) {
59 disk_cache::DeleteCache(path, false); 58 disk_cache::DeleteCache(path, false);
60 return true; 59 return true;
61 } 60 }
62 61
63 bool CheckCacheIntegrity(const base::FilePath& path, bool new_eviction,
64 uint32 mask) {
65 scoped_ptr<disk_cache::BackendImpl> cache(new disk_cache::BackendImpl(
66 path, mask, base::MessageLoopProxy::current().get(), NULL));
67 if (!cache.get())
68 return false;
69 if (new_eviction)
70 cache->SetNewEviction();
71 cache->SetFlags(disk_cache::kNoRandom);
72 if (cache->SyncInit() != net::OK)
73 return false;
74 return cache->SelfCheck() >= 0;
75 }
76
77 // ----------------------------------------------------------------------- 62 // -----------------------------------------------------------------------
78 63
79 MessageLoopHelper::MessageLoopHelper() 64 MessageLoopHelper::MessageLoopHelper()
80 : num_callbacks_(0), 65 : num_callbacks_(0),
81 num_iterations_(0), 66 num_iterations_(0),
82 last_(0), 67 last_(0),
83 completed_(false), 68 completed_(false),
84 callback_reused_error_(false), 69 callback_reused_error_(false),
85 callbacks_called_(0) { 70 callbacks_called_(0) {
86 } 71 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 122
138 if (reuse_) { 123 if (reuse_) {
139 DCHECK_EQ(1, reuse_); 124 DCHECK_EQ(1, reuse_);
140 if (2 == reuse_) 125 if (2 == reuse_)
141 helper_->set_callback_reused_error(true); 126 helper_->set_callback_reused_error(true);
142 reuse_++; 127 reuse_++;
143 } 128 }
144 129
145 helper_->CallbackWasCalled(); 130 helper_->CallbackWasCalled();
146 } 131 }
OLDNEW
« no previous file with comments | « net/disk_cache/disk_cache_test_util.h ('k') | net/disk_cache/entry_sync_tests.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698