diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-27 03:59:31 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-27 03:59:31 +0000 |
commit | d85cf074f2186dbe1cf8a9db5d89a2b817ffb0e1 (patch) | |
tree | e03156e3142955f7cf637fe404a1ce2c6f7aaaf4 /chrome/browser/user_data_manager.cc | |
parent | 76a188be4e3ddc42c42beabfeeeb618b2adae11e (diff) | |
download | chromium_src-d85cf074f2186dbe1cf8a9db5d89a2b817ffb0e1.zip chromium_src-d85cf074f2186dbe1cf8a9db5d89a2b817ffb0e1.tar.gz chromium_src-d85cf074f2186dbe1cf8a9db5d89a2b817ffb0e1.tar.bz2 |
Simplify threading in browser thread by making only ChromeThread deal with different thread lifetimes.The rest of the code doesn't get MessageLoop pointers since they're not thread-safe and instead just call PostTask on ChromeThread. If the target thread is not alive, then the task is simply deleted.In a followup change, I'll remove any remaining MessageLoop* caching. With this change, there's little to be gained by caching since no locks are involved if the target MessageLoop is guaranteed to outlive the current thread (inferred automatically by the order of the chrome_threads_ array).BUG=25354
Review URL: http://codereview.chromium.org/306032
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30163 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/user_data_manager.cc')
-rw-r--r-- | chrome/browser/user_data_manager.cc | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/chrome/browser/user_data_manager.cc b/chrome/browser/user_data_manager.cc index 5e9e0e6..bd2ba88 100644 --- a/chrome/browser/user_data_manager.cc +++ b/chrome/browser/user_data_manager.cc @@ -210,8 +210,7 @@ void UserDataManager::LaunchChromeForProfile(int index) const { void UserDataManager::GetProfiles(std::vector<std::wstring>* profiles) const { // This function should be called on the file thread. - DCHECK(MessageLoop::current() == - ChromeThread::GetMessageLoop(ChromeThread::FILE)); + DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE)); file_util::FileEnumerator file_enum( FilePath::FromWStringHack(user_data_root_), false, file_util::FileEnumerator::DIRECTORIES); @@ -281,9 +280,8 @@ void GetProfilesHelper::GetProfiles(MessageLoop* target_loop) { message_loop_ = MessageLoop::current(); } DCHECK(message_loop_); - MessageLoop* file_loop = ChromeThread::GetMessageLoop(ChromeThread::FILE); - file_loop->PostTask( - FROM_HERE, + ChromeThread::PostTask( + ChromeThread::FILE, FROM_HERE, NewRunnableMethod(this, &GetProfilesHelper::GetProfilesFromManager)); } @@ -294,8 +292,7 @@ void GetProfilesHelper::OnDelegateDeleted() { void GetProfilesHelper::GetProfilesFromManager() { // This function should be called on the file thread. - DCHECK(MessageLoop::current() == - ChromeThread::GetMessageLoop(ChromeThread::FILE)); + DCHECK(ChromeThread::CurrentlyOn(ChromeThread::FILE)); // If the delegate is gone by now, no need to do any work. if (!delegate_) |