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

Unified Diff: chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc

Issue 10535145: chromeos: Stop calling gdata::GDataCache::GetCacheEntry on UI thread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_file_system.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc
diff --git a/chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc b/chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc
index ab148f1c5d9db09253c497774ccf82b3ec5e3e06..b295aad15da65c00a72adf81377c338c81d44047 100644
--- a/chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc
+++ b/chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc
@@ -426,10 +426,37 @@ class GDataFileSystemTest : public testing::Test {
file_origin);
}
+ // Helper function to call GetCacheEntry from origin thread.
+ // Note: This method calls RunAllPendingForIO.
+ scoped_ptr<GDataCache::CacheEntry> GetCacheEntryFromOriginThread(
+ const std::string& resource_id,
+ const std::string& md5) {
+ scoped_ptr<GDataCache::CacheEntry> cache_entry;
+ content::BrowserThread::GetBlockingPool()
+ ->GetSequencedTaskRunner(sequence_token_)->PostTask(
+ FROM_HERE,
+ base::Bind(
+ &GDataFileSystemTest::GetCacheEntryFromOriginThreadInternal,
+ base::Unretained(this),
+ resource_id,
+ md5,
+ &cache_entry));
+ RunAllPendingForIO();
+ return cache_entry.Pass();
+ }
+
+ // Used to implement GetCacheEntry.
+ void GetCacheEntryFromOriginThreadInternal(
+ const std::string& resource_id,
+ const std::string& md5,
+ scoped_ptr<GDataCache::CacheEntry>* cache_entry) {
+ cache_entry->reset(cache_->GetCacheEntry(resource_id, md5).release());
+ }
+
// Returns true if the cache entry exists for the given resource ID and MD5.
bool CacheEntryExists(const std::string& resource_id,
const std::string& md5) {
- return file_system_->cache_->GetCacheEntry(resource_id, md5).get();
+ return GetCacheEntryFromOriginThread(resource_id, md5).get();
}
// Returns true if the cache file exists for the given resource ID and MD5.
@@ -543,7 +570,7 @@ class GDataFileSystemTest : public testing::Test {
// Verify cache map.
scoped_ptr<GDataCache::CacheEntry> cache_entry =
- file_system_->cache_->GetCacheEntry(resource_id, md5);
+ GetCacheEntryFromOriginThread(resource_id, md5);
if (cache_entry.get())
EXPECT_TRUE(cache_entry->IsDirty());
@@ -917,7 +944,7 @@ class GDataFileSystemTest : public testing::Test {
if (GDataCache::IsCachePresent(resource.cache_state))
md5 = resource.md5;
scoped_ptr<GDataCache::CacheEntry> cache_entry =
- file_system_->cache_->GetCacheEntry(resource.resource_id, md5);
+ GetCacheEntryFromOriginThread(resource.resource_id, md5);
ASSERT_TRUE(cache_entry.get());
EXPECT_EQ(resource.cache_state, cache_entry->cache_state);
EXPECT_EQ(resource.expected_sub_dir_type, cache_entry->sub_dir_type);
@@ -933,7 +960,7 @@ class GDataFileSystemTest : public testing::Test {
// Verify cache map.
scoped_ptr<GDataCache::CacheEntry> cache_entry =
- file_system_->cache_->GetCacheEntry(resource_id, md5);
+ GetCacheEntryFromOriginThread(resource_id, md5);
if (GDataCache::IsCachePresent(expected_cache_state_) ||
GDataCache::IsCachePinned(expected_cache_state_)) {
ASSERT_TRUE(cache_entry.get());
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_file_system.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698