summaryrefslogtreecommitdiffstats
path: root/chrome/browser/prefs
diff options
context:
space:
mode:
authorzelidrag@chromium.org <zelidrag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-30 23:32:26 +0000
committerzelidrag@chromium.org <zelidrag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-30 23:32:26 +0000
commit782c3ac24bf9e59900df1df5c707281623e5e3fc (patch)
tree7179504192e3eb4307fa4755bc5eadff6201562e /chrome/browser/prefs
parenteba4b810a15cc813333aa24e21a451f649214079 (diff)
downloadchromium_src-782c3ac24bf9e59900df1df5c707281623e5e3fc.zip
chromium_src-782c3ac24bf9e59900df1df5c707281623e5e3fc.tar.gz
chromium_src-782c3ac24bf9e59900df1df5c707281623e5e3fc.tar.bz2
Moved JsonPrefStore to use SequencedWorkerPool instead of FILE thread. The pool also ensures that the same file requests are written in order received and that they block on shutdown.
BUG=153367 TEST=existing unit/browser tests Review URL: https://codereview.chromium.org/11027070 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@165062 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/prefs')
-rw-r--r--chrome/browser/prefs/pref_service.cc4
-rw-r--r--chrome/browser/prefs/pref_service.h14
-rw-r--r--chrome/browser/prefs/pref_service_mock_builder.cc11
-rw-r--r--chrome/browser/prefs/pref_service_mock_builder.h5
-rw-r--r--chrome/browser/prefs/pref_service_unittest.cc4
5 files changed, 23 insertions, 15 deletions
diff --git a/chrome/browser/prefs/pref_service.cc b/chrome/browser/prefs/pref_service.cc
index 8862f7f..eedef9b 100644
--- a/chrome/browser/prefs/pref_service.cc
+++ b/chrome/browser/prefs/pref_service.cc
@@ -123,6 +123,7 @@ PrefServiceBase* PrefServiceBase::FromBrowserContext(BrowserContext* context) {
// static
PrefService* PrefService::CreatePrefService(
const FilePath& pref_filename,
+ base::SequencedTaskRunner* pref_io_task_runner,
policy::PolicyService* policy_service,
PrefStore* extension_prefs,
bool async) {
@@ -156,8 +157,7 @@ PrefService* PrefService::CreatePrefService(
CommandLinePrefStore* command_line =
new CommandLinePrefStore(CommandLine::ForCurrentProcess());
JsonPrefStore* user = new JsonPrefStore(
- pref_filename,
- BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE));
+ pref_filename, pref_io_task_runner);
DefaultPrefStore* default_pref_store = new DefaultPrefStore();
PrefNotifierImpl* pref_notifier = new PrefNotifierImpl();
diff --git a/chrome/browser/prefs/pref_service.h b/chrome/browser/prefs/pref_service.h
index 82b9167..c855ef1 100644
--- a/chrome/browser/prefs/pref_service.h
+++ b/chrome/browser/prefs/pref_service.h
@@ -31,6 +31,10 @@ class PrefServiceObserver;
class PrefStore;
class PrefValueStore;
+namespace base {
+ class SequencedTaskRunner;
+}
+
namespace syncer {
class SyncableService;
}
@@ -108,10 +112,12 @@ class PrefService : public PrefServiceBase, public base::NonThreadSafe {
// the created PrefService or NULL if creation has failed. Note, it is
// guaranteed that in asynchronous version initialization happens after this
// function returned.
- static PrefService* CreatePrefService(const FilePath& pref_filename,
- policy::PolicyService* policy_service,
- PrefStore* extension_pref_store,
- bool async);
+ static PrefService* CreatePrefService(
+ const FilePath& pref_filename,
+ base::SequencedTaskRunner* pref_io_task_runner,
+ policy::PolicyService* policy_service,
+ PrefStore* extension_pref_store,
+ bool async);
// Creates an incognito copy of the pref service that shares most pref stores
// but uses a fresh non-persistent overlay for the user pref store and an
diff --git a/chrome/browser/prefs/pref_service_mock_builder.cc b/chrome/browser/prefs/pref_service_mock_builder.cc
index 2782882..77d8080 100644
--- a/chrome/browser/prefs/pref_service_mock_builder.cc
+++ b/chrome/browser/prefs/pref_service_mock_builder.cc
@@ -77,16 +77,17 @@ PrefServiceMockBuilder::WithCommandLine(CommandLine* command_line) {
PrefServiceMockBuilder&
PrefServiceMockBuilder::WithUserFilePrefs(const FilePath& prefs_file) {
- return WithUserFilePrefs(prefs_file,
- BrowserThread::GetMessageLoopProxyForThread(
- BrowserThread::FILE));
+ return WithUserFilePrefs(
+ prefs_file,
+ JsonPrefStore::GetTaskRunnerForFile(prefs_file,
+ BrowserThread::GetBlockingPool()));
}
PrefServiceMockBuilder&
PrefServiceMockBuilder::WithUserFilePrefs(
const FilePath& prefs_file,
- base::MessageLoopProxy* message_loop_proxy) {
- user_prefs_ = new JsonPrefStore(prefs_file, message_loop_proxy);
+ base::SequencedTaskRunner* task_runner) {
+ user_prefs_ = new JsonPrefStore(prefs_file, task_runner);
return *this;
}
diff --git a/chrome/browser/prefs/pref_service_mock_builder.h b/chrome/browser/prefs/pref_service_mock_builder.h
index b939ca6..708b622 100644
--- a/chrome/browser/prefs/pref_service_mock_builder.h
+++ b/chrome/browser/prefs/pref_service_mock_builder.h
@@ -15,7 +15,7 @@ class FilePath;
class PrefService;
namespace base {
-class MessageLoopProxy;
+class SequencedTaskRunner;
}
namespace policy {
@@ -48,10 +48,11 @@ class PrefServiceMockBuilder {
PrefServiceMockBuilder& WithCommandLine(CommandLine* command_line);
// Specifies to use an actual file-backed user pref store.
+ // TODO(zelidrag): Remove the first overloaded method below.
PrefServiceMockBuilder& WithUserFilePrefs(const FilePath& prefs_file);
PrefServiceMockBuilder& WithUserFilePrefs(
const FilePath& prefs_file,
- base::MessageLoopProxy* message_loop_proxy);
+ base::SequencedTaskRunner* task_runner);
// Creates the PrefService, invalidating the entire builder configuration.
PrefService* Create();
diff --git a/chrome/browser/prefs/pref_service_unittest.cc b/chrome/browser/prefs/pref_service_unittest.cc
index 2dc90a8..cd046e8 100644
--- a/chrome/browser/prefs/pref_service_unittest.cc
+++ b/chrome/browser/prefs/pref_service_unittest.cc
@@ -315,7 +315,7 @@ TEST_F(PrefServiceUserFilePrefsTest, PreserveEmptyValue) {
pref_file));
PrefServiceMockBuilder builder;
- builder.WithUserFilePrefs(pref_file, base::MessageLoopProxy::current());
+ builder.WithUserFilePrefs(pref_file, message_loop_.message_loop_proxy());
scoped_ptr<PrefService> prefs(builder.Create());
// Register testing prefs.
@@ -344,7 +344,7 @@ TEST_F(PrefServiceUserFilePrefsTest, PreserveEmptyValue) {
// Write to file.
prefs->CommitPendingWrite();
- MessageLoop::current()->RunAllPending();
+ message_loop_.RunAllPending();
// Compare to expected output.
FilePath golden_output_file =