gdata: Get rid of GDataFileSystem::GetCacheState()

Instead, add GDataCache::GetCacheEntryOnUIThread().

BUG=133552
TEST=the existing testis covered this functionality

Review URL: https://chromiumcodereview.appspot.com/10690028

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@144878 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/chromeos/gdata/gdata_cache.cc b/chrome/browser/chromeos/gdata/gdata_cache.cc
index 24f4b9b..2737fe2 100644
--- a/chrome/browser/chromeos/gdata/gdata_cache.cc
+++ b/chrome/browser/chromeos/gdata/gdata_cache.cc
@@ -346,7 +346,7 @@
 }
 
 // Runs callback with pointers dereferenced.
-// Used to implement GetResourceIdsOfBacklog().
+// Used to implement GetResourceIdsOfBacklogOnUIThread().
 void RunGetResourceIdsCallback(const GetResourceIdsCallback& callback,
                                std::vector<std::string>* to_fetch,
                                std::vector<std::string>* to_upload) {
@@ -358,6 +358,19 @@
     callback.Run(*to_fetch, *to_upload);
 }
 
+// Runs callback with pointers dereferenced.
+// Used to implement GetCacheEntryOnUIThread().
+void RunGetCacheEntryCallback(
+    const GDataCache::GetCacheEntryCallback& callback,
+    bool* success,
+    GDataCache::CacheEntry* cache_entry) {
+  DCHECK(success);
+  DCHECK(cache_entry);
+
+  if (!callback.is_null())
+    callback.Run(*success, *cache_entry);
+}
+
 }  // namespace
 
 std::string GDataCache::CacheEntry::ToString() const {
@@ -445,6 +458,28 @@
   observers_.RemoveObserver(observer);
 }
 
+void GDataCache::GetCacheEntryOnUIThread(
+    const std::string& resource_id,
+    const std::string& md5,
+    const GetCacheEntryCallback& callback) {
+  DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+
+  bool* success = new bool(false);
+  GDataCache::CacheEntry* cache_entry = new GDataCache::CacheEntry;
+  pool_->GetSequencedTaskRunner(sequence_token_)->PostTaskAndReply(
+      FROM_HERE,
+      base::Bind(&GDataCache::GetCacheEntryHelper,
+                 base::Unretained(this),
+                 resource_id,
+                 md5,
+                 success,
+                 cache_entry),
+      base::Bind(&RunGetCacheEntryCallback,
+                 callback,
+                 base::Owned(success),
+                 base::Owned(cache_entry)));
+}
+
 void GDataCache::GetResourceIdsOfBacklogOnUIThread(
     const GetResourceIdsCallback& callback) {
   DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
@@ -1463,6 +1498,20 @@
     FOR_EACH_OBSERVER(Observer, observers_, OnCacheCommitted(resource_id));
 }
 
+void GDataCache::GetCacheEntryHelper(const std::string& resource_id,
+                                     const std::string& md5,
+                                     bool* success,
+                                     GDataCache::CacheEntry* cache_entry) {
+  AssertOnSequencedWorkerPool();
+  DCHECK(success);
+  DCHECK(cache_entry);
+
+  scoped_ptr<GDataCache::CacheEntry> value(GetCacheEntry(resource_id, md5));
+  *success = value.get();
+  if (*success)
+    *cache_entry = *value;
+}
+
 // static
 FilePath GDataCache::GetCacheRootPath(Profile* profile) {
   FilePath cache_base_path;