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

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

Issue 7583053: Add MessageLoopProxy::current (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: No need for MessageLoopProxy destruction observer. Created 9 years, 4 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/base/host_resolver_impl.cc ('k') | net/disk_cache/disk_cache_test_base.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) 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/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/file_util.h" 6 #include "base/file_util.h"
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "base/third_party/dynamic_annotations/dynamic_annotations.h" 9 #include "base/third_party/dynamic_annotations/dynamic_annotations.h"
10 #include "base/threading/platform_thread.h" 10 #include "base/threading/platform_thread.h"
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 { 259 {
260 FilePath path = GetCacheFilePath(); 260 FilePath path = GetCacheFilePath();
261 ASSERT_TRUE(DeleteCache(path)); 261 ASSERT_TRUE(DeleteCache(path));
262 base::Thread cache_thread("CacheThread"); 262 base::Thread cache_thread("CacheThread");
263 ASSERT_TRUE(cache_thread.StartWithOptions( 263 ASSERT_TRUE(cache_thread.StartWithOptions(
264 base::Thread::Options(MessageLoop::TYPE_IO, 0))); 264 base::Thread::Options(MessageLoop::TYPE_IO, 0)));
265 265
266 disk_cache::Backend* cache; 266 disk_cache::Backend* cache;
267 int rv = disk_cache::BackendImpl::CreateBackend( 267 int rv = disk_cache::BackendImpl::CreateBackend(
268 path, false, 0, net::DISK_CACHE, disk_cache::kNoRandom, 268 path, false, 0, net::DISK_CACHE, disk_cache::kNoRandom,
269 base::MessageLoopProxy::CreateForCurrentThread(), NULL, 269 base::MessageLoopProxy::current(), NULL,
270 &cache, &cb); 270 &cache, &cb);
271 ASSERT_EQ(net::OK, cb.GetResult(rv)); 271 ASSERT_EQ(net::OK, cb.GetResult(rv));
272 272
273 disk_cache::EntryImpl* entry; 273 disk_cache::EntryImpl* entry;
274 rv = cache->CreateEntry("some key", 274 rv = cache->CreateEntry("some key",
275 reinterpret_cast<disk_cache::Entry**>(&entry), &cb); 275 reinterpret_cast<disk_cache::Entry**>(&entry), &cb);
276 ASSERT_EQ(net::OK, cb.GetResult(rv)); 276 ASSERT_EQ(net::OK, cb.GetResult(rv));
277 277
278 const int kSize = 25000; 278 const int kSize = 25000;
279 scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(kSize)); 279 scoped_refptr<net::IOBuffer> buffer(new net::IOBuffer(kSize));
(...skipping 1531 matching lines...) Expand 10 before | Expand all | Expand 10 after
1811 BackendDisable4(); 1811 BackendDisable4();
1812 } 1812 }
1813 1813
1814 TEST_F(DiskCacheTest, Backend_UsageStats) { 1814 TEST_F(DiskCacheTest, Backend_UsageStats) {
1815 MessageLoopHelper helper; 1815 MessageLoopHelper helper;
1816 1816
1817 FilePath path = GetCacheFilePath(); 1817 FilePath path = GetCacheFilePath();
1818 ASSERT_TRUE(DeleteCache(path)); 1818 ASSERT_TRUE(DeleteCache(path));
1819 scoped_ptr<disk_cache::BackendImpl> cache; 1819 scoped_ptr<disk_cache::BackendImpl> cache;
1820 cache.reset(new disk_cache::BackendImpl( 1820 cache.reset(new disk_cache::BackendImpl(
1821 path, base::MessageLoopProxy::CreateForCurrentThread(), 1821 path, base::MessageLoopProxy::current(),
1822 NULL)); 1822 NULL));
1823 ASSERT_TRUE(NULL != cache.get()); 1823 ASSERT_TRUE(NULL != cache.get());
1824 cache->SetUnitTestMode(); 1824 cache->SetUnitTestMode();
1825 ASSERT_EQ(net::OK, cache->SyncInit()); 1825 ASSERT_EQ(net::OK, cache->SyncInit());
1826 1826
1827 // Wait for a callback that never comes... about 2 secs :). The message loop 1827 // Wait for a callback that never comes... about 2 secs :). The message loop
1828 // has to run to allow invocation of the usage timer. 1828 // has to run to allow invocation of the usage timer.
1829 helper.WaitUntilCacheIoFinished(1); 1829 helper.WaitUntilCacheIoFinished(1);
1830 } 1830 }
1831 1831
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
2134 // Ping the oldest entry. 2134 // Ping the oldest entry.
2135 cache_->OnExternalCacheHit("key0"); 2135 cache_->OnExternalCacheHit("key0");
2136 2136
2137 TrimForTest(false); 2137 TrimForTest(false);
2138 2138
2139 // Make sure the older key remains. 2139 // Make sure the older key remains.
2140 EXPECT_EQ(1, cache_->GetEntryCount()); 2140 EXPECT_EQ(1, cache_->GetEntryCount());
2141 ASSERT_EQ(net::OK, OpenEntry("key0", &entry)); 2141 ASSERT_EQ(net::OK, OpenEntry("key0", &entry));
2142 entry->Close(); 2142 entry->Close();
2143 } 2143 }
OLDNEW
« no previous file with comments | « net/base/host_resolver_impl.cc ('k') | net/disk_cache/disk_cache_test_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698