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

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

Issue 2015263002: Simple Cache: avoid extraneous stream 0 (http header) writes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
« no previous file with comments | « no previous file | net/disk_cache/simple/simple_synchronous_entry.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 <utility> 5 #include <utility>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/files/file.h" 9 #include "base/files/file.h"
10 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
(...skipping 4202 matching lines...) Expand 10 before | Expand all | Expand 10 after
4213 scoped_refptr<net::IOBuffer> check_stream_1_data( 4213 scoped_refptr<net::IOBuffer> check_stream_1_data(
4214 new net::IOBuffer(stream_1_data.size())); 4214 new net::IOBuffer(stream_1_data.size()));
4215 EXPECT_EQ( 4215 EXPECT_EQ(
4216 static_cast<int>(stream_1_data.size()), 4216 static_cast<int>(stream_1_data.size()),
4217 ReadData(entry, 1, 0, check_stream_1_data.get(), stream_1_data.size())); 4217 ReadData(entry, 1, 0, check_stream_1_data.get(), stream_1_data.size()));
4218 EXPECT_EQ(0, stream_1_data.compare(0, std::string::npos, 4218 EXPECT_EQ(0, stream_1_data.compare(0, std::string::npos,
4219 check_stream_1_data->data(), 4219 check_stream_1_data->data(),
4220 stream_1_data.size())); 4220 stream_1_data.size()));
4221 } 4221 }
4222 4222
4223 TEST_F(DiskCacheEntryTest, SimpleCacheDoubleOpenWithoutKeySHA256) {
4224 // This test runs as APP_CACHE to make operations more synchronous.
4225 SetCacheType(net::APP_CACHE);
4226 SetSimpleCacheMode();
4227 InitCache();
4228 disk_cache::Entry* entry;
4229 std::string key("a key");
4230 ASSERT_EQ(net::OK, CreateEntry(key, &entry));
4231 entry->Close();
4232
4233 base::RunLoop().RunUntilIdle();
4234 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting();
4235 base::RunLoop().RunUntilIdle();
4236
4237 EXPECT_TRUE(
4238 disk_cache::simple_util::RemoveKeySHA256FromEntry(key, cache_path_));
4239 ASSERT_EQ(net::OK, OpenEntry(key, &entry));
4240 entry->Close();
4241
4242 base::RunLoop().RunUntilIdle();
4243 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting();
4244 base::RunLoop().RunUntilIdle();
4245
4246 ASSERT_EQ(net::OK, OpenEntry(key, &entry));
4247 entry->Close();
4248 }
4249
4223 TEST_F(DiskCacheEntryTest, SimpleCacheReadCorruptKeySHA256) { 4250 TEST_F(DiskCacheEntryTest, SimpleCacheReadCorruptKeySHA256) {
4224 // This test runs as APP_CACHE to make operations more synchronous. 4251 // This test runs as APP_CACHE to make operations more synchronous.
4225 SetCacheType(net::APP_CACHE); 4252 SetCacheType(net::APP_CACHE);
4226 SetSimpleCacheMode(); 4253 SetSimpleCacheMode();
4227 InitCache(); 4254 InitCache();
4228 disk_cache::Entry* entry; 4255 disk_cache::Entry* entry;
4229 std::string key("a key"); 4256 std::string key("a key");
4230 ASSERT_EQ(net::OK, CreateEntry(key, &entry)); 4257 ASSERT_EQ(net::OK, CreateEntry(key, &entry));
4231 entry->Close(); 4258 entry->Close();
4232 4259
4233 base::RunLoop().RunUntilIdle(); 4260 base::RunLoop().RunUntilIdle();
4234 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting(); 4261 disk_cache::SimpleBackendImpl::FlushWorkerPoolForTesting();
4235 base::RunLoop().RunUntilIdle(); 4262 base::RunLoop().RunUntilIdle();
4236 4263
4237 EXPECT_TRUE( 4264 EXPECT_TRUE(
4238 disk_cache::simple_util::CorruptKeySHA256FromEntry(key, cache_path_)); 4265 disk_cache::simple_util::CorruptKeySHA256FromEntry(key, cache_path_));
4239 EXPECT_NE(net::OK, OpenEntry(key, &entry)); 4266 EXPECT_NE(net::OK, OpenEntry(key, &entry));
4240 } 4267 }
OLDNEW
« no previous file with comments | « no previous file | net/disk_cache/simple/simple_synchronous_entry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698