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

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

Issue 10272006: gdata: Fix GDataFileSystem::GetCacheStateOnUIThread to acquire lock for cache initialization. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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 | « no previous file | chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/gdata/gdata_file_system.cc
diff --git a/chrome/browser/chromeos/gdata/gdata_file_system.cc b/chrome/browser/chromeos/gdata/gdata_file_system.cc
index 19d26ef89c28d9856623f832d5164e8aeddfff90..971b8d971464e7183a3d16cd12beeeb8ded2ec5b 100644
--- a/chrome/browser/chromeos/gdata/gdata_file_system.cc
+++ b/chrome/browser/chromeos/gdata/gdata_file_system.cc
@@ -2138,23 +2138,21 @@ GDataEntry* GDataFileSystem::GetGDataEntryByPath(
void GDataFileSystem::GetCacheState(const std::string& resource_id,
const std::string& md5,
const GetCacheStateCallback& callback) {
- if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) {
- DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- const bool posted = BrowserThread::PostTask(
- BrowserThread::UI,
- FROM_HERE,
- base::Bind(&GDataFileSystem::GetCacheStateOnUIThread,
- ui_weak_ptr_,
- resource_id,
- md5,
- base::Bind(&RelayGetCacheStateCallback,
- base::MessageLoopProxy::current(),
- callback)));
- DCHECK(posted);
- return;
- }
-
- GetCacheStateOnUIThread(resource_id, md5, callback);
+ // Always post a task to the UI thread to call GetCacheStateOnUIThread even if
Ben Chan 2012/04/30 04:37:21 Another way to fix this issue is to have GetCacheS
satorux1 2012/04/30 05:52:06 Sounds good. Please add DCHECK(BrowserThread::Cur
Ben Chan 2012/04/30 06:18:58 Done.
+ // GetCacheState is called on the UI thread. This ensures that, regardless of
+ // whether GDataFileSystem is locked or not, GDataFileSystem is unlocked when
+ // GetCacheStateOnUIThread is called.
+ const bool posted = BrowserThread::PostTask(
+ BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&GDataFileSystem::GetCacheStateOnUIThread,
+ ui_weak_ptr_,
+ resource_id,
+ md5,
+ base::Bind(&RelayGetCacheStateCallback,
+ base::MessageLoopProxy::current(),
+ callback)));
+ DCHECK(posted);
}
void GDataFileSystem::GetCacheStateOnUIThread(
@@ -2163,9 +2161,7 @@ void GDataFileSystem::GetCacheStateOnUIThread(
const GetCacheStateCallback& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
- // This method originates from GDataFile::GetCacheState, which already locks,
- // so we shouldn't lock here.
- UnsafeInitializeCacheIfNecessary();
+ InitializeCacheIfNecessary();
base::PlatformFileError* error =
new base::PlatformFileError(base::PLATFORM_FILE_OK);
« no previous file with comments | « no previous file | chrome/browser/chromeos/gdata/gdata_file_system_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698