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

Side by Side Diff: net/disk_cache/simple/simple_index_file_unittest.cc

Issue 1460053003: SimpleCache: Fix race condition in simple_index_file_unittest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove the suppression Created 5 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 | « build/sanitizers/tsan_suppressions.cc ('k') | no next file » | 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 "base/files/file.h" 5 #include "base/files/file.h"
6 #include "base/files/file_util.h" 6 #include "base/files/file_util.h"
7 #include "base/files/scoped_temp_dir.h" 7 #include "base/files/scoped_temp_dir.h"
8 #include "base/hash.h" 8 #include "base/hash.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 EXPECT_EQ(net::OK, cb.GetResult(rv)); 285 EXPECT_EQ(net::OK, cb.GetResult(rv));
286 rv = simple_cache->index()->ExecuteWhenReady(cb.callback()); 286 rv = simple_cache->index()->ExecuteWhenReady(cb.callback());
287 EXPECT_EQ(net::OK, cb.GetResult(rv)); 287 EXPECT_EQ(net::OK, cb.GetResult(rv));
288 delete simple_cache; 288 delete simple_cache;
289 289
290 // The backend flushes the index on destruction and does so on the cache 290 // The backend flushes the index on destruction and does so on the cache
291 // thread, wait for the flushing to finish by posting a callback to the cache 291 // thread, wait for the flushing to finish by posting a callback to the cache
292 // thread after that. 292 // thread after that.
293 MessageLoopHelper helper; 293 MessageLoopHelper helper;
294 CallbackTest cb_shutdown(&helper, false); 294 CallbackTest cb_shutdown(&helper, false);
295 cache_thread.task_runner()->PostTask( 295 cache_thread.task_runner()->PostTaskAndReply(
296 FROM_HERE, 296 FROM_HERE, base::Bind(&base::DoNothing),
297 base::Bind(&CallbackTest::Run, base::Unretained(&cb_shutdown), net::OK)); 297 base::Bind(&CallbackTest::Run, base::Unretained(&cb_shutdown), net::OK));
298 helper.WaitUntilCacheIoFinished(1); 298 helper.WaitUntilCacheIoFinished(1);
299 299
300 // Verify that the index file exists. 300 // Verify that the index file exists.
301 const base::FilePath& index_file_path = 301 const base::FilePath& index_file_path =
302 cache_path.AppendASCII("index-dir").AppendASCII("the-real-index"); 302 cache_path.AppendASCII("index-dir").AppendASCII("the-real-index");
303 EXPECT_TRUE(base::PathExists(index_file_path)); 303 EXPECT_TRUE(base::PathExists(index_file_path));
304 304
305 // Verify that the version of the index file is correct. 305 // Verify that the version of the index file is correct.
306 std::string contents; 306 std::string contents;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 closure.WaitForResult(); 339 closure.WaitForResult();
340 340
341 // Check that the temporary file was deleted and the index file was created. 341 // Check that the temporary file was deleted and the index file was created.
342 EXPECT_FALSE(base::PathExists(simple_index_file.GetTempIndexFilePath())); 342 EXPECT_FALSE(base::PathExists(simple_index_file.GetTempIndexFilePath()));
343 EXPECT_TRUE(base::PathExists(simple_index_file.GetIndexFilePath())); 343 EXPECT_TRUE(base::PathExists(simple_index_file.GetIndexFilePath()));
344 } 344 }
345 345
346 #endif // defined(OS_POSIX) 346 #endif // defined(OS_POSIX)
347 347
348 } // namespace disk_cache 348 } // namespace disk_cache
OLDNEW
« no previous file with comments | « build/sanitizers/tsan_suppressions.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698