Index: chrome/browser/profiles/profile_impl.cc |
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc |
index 735cba8acb25dc9e8cff36bb2870cc7a987155a7..d165de12d6a9cf8d1cd2b67ba07c21cba695a1e3 100644 |
--- a/chrome/browser/profiles/profile_impl.cc |
+++ b/chrome/browser/profiles/profile_impl.cc |
@@ -16,6 +16,7 @@ |
#include "base/string_tokenizer.h" |
#include "base/string_util.h" |
#include "base/stringprintf.h" |
+#include "base/threading/sequenced_worker_pool.h" |
#include "base/utf_string_conversions.h" |
#include "base/version.h" |
#include "chrome/browser/autocomplete/autocomplete_classifier.h" |
@@ -208,12 +209,22 @@ std::string ExitTypeToSessionTypePrefValue(Profile::ExitType type) { |
Profile* Profile::CreateProfile(const FilePath& path, |
Delegate* delegate, |
CreateMode create_mode) { |
+ // Get sequenced task runner for making sure that file operations of |
+ // this profile (defined by |path|) are executed in expected order |
+ // (what was previously assured by the FILE thread). |
+ scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner = |
akalin
2012/10/19 02:00:51
use JsonPrefStore::CreateTaskRunnerForFile() here?
zel
2012/10/19 18:45:07
Done.
|
+ BrowserThread::GetBlockingPool()-> |
+ GetSequencedTaskRunnerWithShutdownBehavior( |
+ BrowserThread::GetBlockingPool()->GetNamedSequenceToken( |
+ path.AsUTF8Unsafe()), |
+ base::SequencedWorkerPool::BLOCK_SHUTDOWN); |
if (create_mode == CREATE_MODE_ASYNCHRONOUS) { |
DCHECK(delegate); |
- // This is safe while all file operations are done on the FILE thread. |
- BrowserThread::PostTask( |
- BrowserThread::FILE, FROM_HERE, |
- base::Bind(&CreateDirectoryNoResult, path)); |
+ // We need to make sure that profile directory is created on the same |
+ // blocking pool where we will run all its important file serialization |
+ // tasks (i.e. JsonPrefStore). |
+ sequenced_task_runner->PostTask(FROM_HERE, |
+ base::Bind(&CreateDirectoryNoResult, path)); |
} else if (create_mode == CREATE_MODE_SYNCHRONOUS) { |
if (!file_util::PathExists(path)) { |
// TODO(tc): http://b/1094718 Bad things happen if we can't write to the |
@@ -226,7 +237,7 @@ Profile* Profile::CreateProfile(const FilePath& path, |
NOTREACHED(); |
} |
- return new ProfileImpl(path, delegate, create_mode); |
+ return new ProfileImpl(path, delegate, create_mode, sequenced_task_runner); |
} |
// static |
@@ -279,9 +290,11 @@ void ProfileImpl::RegisterUserPrefs(PrefService* prefs) { |
PrefService::SYNCABLE_PREF); |
} |
-ProfileImpl::ProfileImpl(const FilePath& path, |
- Delegate* delegate, |
- CreateMode create_mode) |
+ProfileImpl::ProfileImpl( |
+ const FilePath& path, |
+ Delegate* delegate, |
+ CreateMode create_mode, |
+ scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner) |
: path_(path), |
ALLOW_THIS_IN_INITIALIZER_LIST(visited_link_event_listener_( |
new VisitedLinkEventListener(this))), |
@@ -331,7 +344,8 @@ ProfileImpl::ProfileImpl(const FilePath& path, |
policy_service_.get(), |
new ExtensionPrefStore( |
ExtensionPrefValueMapFactory::GetForProfile(this), false), |
- true)); |
+ true, |
+ sequenced_task_runner)); |
// Wait for the notification that prefs has been loaded (successfully or |
// not). |
registrar_.Add(this, chrome::NOTIFICATION_PREF_INITIALIZATION_COMPLETED, |
@@ -343,7 +357,8 @@ ProfileImpl::ProfileImpl(const FilePath& path, |
policy_service_.get(), |
new ExtensionPrefStore( |
ExtensionPrefValueMapFactory::GetForProfile(this), false), |
- false)); |
+ false, |
+ sequenced_task_runner)); |
OnPrefsLoaded(true); |
} else { |
NOTREACHED(); |