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

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

Issue 16306003: Fix uninitialized read in the SimpleCache tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 6 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 | tools/valgrind/memcheck/suppressions.txt » ('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/file_util.h" 8 #include "base/file_util.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 2835 matching lines...) Expand 10 before | Expand all | Expand 10 after
2846 disk_cache::Entry* entry = NULL; 2846 disk_cache::Entry* entry = NULL;
2847 2847
2848 // First, an optimistic create. 2848 // First, an optimistic create.
2849 ASSERT_EQ(net::OK, 2849 ASSERT_EQ(net::OK,
2850 cache_->CreateEntry(key, &entry, net::CompletionCallback())); 2850 cache_->CreateEntry(key, &entry, net::CompletionCallback()));
2851 2851
2852 ASSERT_TRUE(entry); 2852 ASSERT_TRUE(entry);
2853 const int kWriteSize = 512; 2853 const int kWriteSize = 512;
2854 scoped_refptr<net::IOBuffer> buffer1(new net::IOBuffer(kWriteSize)); 2854 scoped_refptr<net::IOBuffer> buffer1(new net::IOBuffer(kWriteSize));
2855 EXPECT_TRUE(buffer1->HasOneRef()); 2855 EXPECT_TRUE(buffer1->HasOneRef());
2856 CacheTestFillBuffer(buffer1->data(), kWriteSize, false);
2856 2857
2857 // An optimistic write happens only when there is an empty queue of pending 2858 // An optimistic write happens only when there is an empty queue of pending
2858 // operations. To ensure the queue is empty, we issue a write and wait until 2859 // operations. To ensure the queue is empty, we issue a write and wait until
2859 // it completes. 2860 // it completes.
2860 EXPECT_EQ(kWriteSize, 2861 EXPECT_EQ(kWriteSize,
2861 WriteData(entry, 0, 0, buffer1, kWriteSize, false)); 2862 WriteData(entry, 0, 0, buffer1, kWriteSize, false));
2862 EXPECT_TRUE(buffer1->HasOneRef()); 2863 EXPECT_TRUE(buffer1->HasOneRef());
2863 2864
2864 // Finally, we should perform an optimistic write and confirm that all 2865 // Finally, we should perform an optimistic write and confirm that all
2865 // references to the IO buffer have been released. 2866 // references to the IO buffer have been released.
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
3119 net::TestCompletionCallback cb2; 3120 net::TestCompletionCallback cb2;
3120 int rv1 = cache_->OpenEntry("key", &entry1, cb1.callback()); 3121 int rv1 = cache_->OpenEntry("key", &entry1, cb1.callback());
3121 int rv2 = cache_->CreateEntry("key", &entry2, cb2.callback()); 3122 int rv2 = cache_->CreateEntry("key", &entry2, cb2.callback());
3122 3123
3123 ASSERT_EQ(net::OK, cb2.GetResult(rv2)); 3124 ASSERT_EQ(net::OK, cb2.GetResult(rv2));
3124 EXPECT_EQ(net::ERR_FAILED, cb1.GetResult(rv1)); 3125 EXPECT_EQ(net::ERR_FAILED, cb1.GetResult(rv1));
3125 entry2->Close(); 3126 entry2->Close();
3126 } 3127 }
3127 3128
3128 #endif // defined(OS_POSIX) 3129 #endif // defined(OS_POSIX)
OLDNEW
« no previous file with comments | « no previous file | tools/valgrind/memcheck/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698