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

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

Issue 22859060: Fix race condition for non-open/create operations happening after a doom. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 | « no previous file | net/disk_cache/entry_unittest.cc » ('j') | net/disk_cache/entry_unittest.cc » ('J')
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/file_util.h" 6 #include "base/file_util.h"
7 #include "base/metrics/field_trial.h" 7 #include "base/metrics/field_trial.h"
8 #include "base/port.h" 8 #include "base/port.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 2664 matching lines...) Expand 10 before | Expand all | Expand 10 after
2675 ASSERT_EQ(net::OK, CreateEntry("fourth", &entry2)); 2675 ASSERT_EQ(net::OK, CreateEntry("fourth", &entry2));
2676 2676
2677 ASSERT_EQ(4, cache_->GetEntryCount()); 2677 ASSERT_EQ(4, cache_->GetEntryCount());
2678 EXPECT_EQ(net::OK, DoomAllEntries()); 2678 EXPECT_EQ(net::OK, DoomAllEntries());
2679 ASSERT_EQ(0, cache_->GetEntryCount()); 2679 ASSERT_EQ(0, cache_->GetEntryCount());
2680 2680
2681 // We should stop posting tasks at some point (if we post any). 2681 // We should stop posting tasks at some point (if we post any).
2682 base::MessageLoop::current()->RunUntilIdle(); 2682 base::MessageLoop::current()->RunUntilIdle();
2683 2683
2684 disk_cache::Entry *entry3, *entry4; 2684 disk_cache::Entry *entry3, *entry4;
2685 entry1->Close();
gavinp 2013/08/26 20:36:50 Why this?
Philippe 2013/08/27 11:33:30 Good question. I needed this (and the change below
gavinp 2013/08/27 15:48:02 I think this breaks the API; it's legal and should
Philippe 2013/08/27 16:11:21 Ok, thanks I will address that then :)
2685 EXPECT_NE(net::OK, OpenEntry("third", &entry3)); 2686 EXPECT_NE(net::OK, OpenEntry("third", &entry3));
2686 ASSERT_EQ(net::OK, CreateEntry("third", &entry3)); 2687 ASSERT_EQ(net::OK, CreateEntry("third", &entry3));
2688 entry2->Close();
2687 ASSERT_EQ(net::OK, CreateEntry("fourth", &entry4)); 2689 ASSERT_EQ(net::OK, CreateEntry("fourth", &entry4));
2688 2690
2689 EXPECT_EQ(net::OK, DoomAllEntries()); 2691 EXPECT_EQ(net::OK, DoomAllEntries());
2690 ASSERT_EQ(0, cache_->GetEntryCount()); 2692 ASSERT_EQ(0, cache_->GetEntryCount());
2691 2693
2692 entry1->Close();
2693 entry2->Close();
2694 entry3->Doom(); // The entry should be already doomed, but this must work. 2694 entry3->Doom(); // The entry should be already doomed, but this must work.
2695 entry3->Close(); 2695 entry3->Close();
2696 entry4->Close(); 2696 entry4->Close();
2697 2697
2698 // Now try with all references released. 2698 // Now try with all references released.
2699 ASSERT_EQ(net::OK, CreateEntry("third", &entry1)); 2699 ASSERT_EQ(net::OK, CreateEntry("third", &entry1));
2700 ASSERT_EQ(net::OK, CreateEntry("fourth", &entry2)); 2700 ASSERT_EQ(net::OK, CreateEntry("fourth", &entry2));
2701 entry1->Close(); 2701 entry1->Close();
2702 entry2->Close(); 2702 entry2->Close();
2703 2703
(...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after
3406 void* iter = NULL; 3406 void* iter = NULL;
3407 size_t count = 0; 3407 size_t count = 0;
3408 ASSERT_TRUE(EnumerateAndMatchKeys(-1, &iter, &keys_to_match, &count)); 3408 ASSERT_TRUE(EnumerateAndMatchKeys(-1, &iter, &keys_to_match, &count));
3409 cache_->EndEnumeration(&iter); 3409 cache_->EndEnumeration(&iter);
3410 3410
3411 EXPECT_EQ(key_pool.size(), count); 3411 EXPECT_EQ(key_pool.size(), count);
3412 EXPECT_TRUE(keys_to_match.empty()); 3412 EXPECT_TRUE(keys_to_match.empty());
3413 } 3413 }
3414 3414
3415 #endif // !defined(OS_WIN) 3415 #endif // !defined(OS_WIN)
OLDNEW
« no previous file with comments | « no previous file | net/disk_cache/entry_unittest.cc » ('j') | net/disk_cache/entry_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698