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

Unified Diff: components/prefs/json_pref_store.h

Issue 2876643003: [reland] Add a default task runner argument to the constructor of JsonPrefStore. (Closed)
Patch Set: include preffilter Created 3 years, 7 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 | components/prefs/json_pref_store.cc » ('j') | components/prefs/json_pref_store.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/prefs/json_pref_store.h
diff --git a/components/prefs/json_pref_store.h b/components/prefs/json_pref_store.h
index 6284b8d5478df39110f532e564d76e44bffc3e3d..b298d30e6915cfa68a12dcd5bf5d6f6b0bfcef5f 100644
--- a/components/prefs/json_pref_store.h
+++ b/components/prefs/json_pref_store.h
@@ -19,9 +19,11 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/observer_list.h"
+#include "base/task_scheduler/post_task.h"
#include "base/threading/non_thread_safe.h"
#include "components/prefs/base_prefs_export.h"
#include "components/prefs/persistent_pref_store.h"
+#include "components/prefs/pref_filter.h"
class PrefFilter;
@@ -62,13 +64,18 @@ class COMPONENTS_PREFS_EXPORT JsonPrefStore
const base::FilePath& pref_filename,
base::SequencedWorkerPool* worker_pool);
- // |sequenced_task_runner| must be a shutdown-blocking task runner, ideally
- // created by the GetTaskRunnerForFile() method above.
- // |pref_filename| is the path to the file to read prefs from.
- JsonPrefStore(
- const base::FilePath& pref_filename,
- const scoped_refptr<base::SequencedTaskRunner>& sequenced_task_runner,
- std::unique_ptr<PrefFilter> pref_filter);
+ // |pref_filename| is the path to the file to read prefs from. It is incorrect
+ // to create multiple JsonPrefStore with the same |pref_filename|.
+ // |sequenced_task_runner| is used for asynchronous reads and writes. It must
+ // have the base::TaskShutdownBehavior::BLOCK_SHUTDOWN and base::MayBlock()
+ // traits. Unless external tasks need to run on the same sequence as
+ // JsonPrefStore tasks, keep the default value.
+ JsonPrefStore(const base::FilePath& pref_filename,
+ scoped_refptr<base::SequencedTaskRunner> sequenced_task_runner =
+ base::CreateSequencedTaskRunnerWithTraits(
+ {base::MayBlock(),
+ base::TaskShutdownBehavior::BLOCK_SHUTDOWN}),
+ std::unique_ptr<PrefFilter> pref_filter = nullptr);
// PrefStore overrides:
bool GetValue(const std::string& key,
« no previous file with comments | « no previous file | components/prefs/json_pref_store.cc » ('j') | components/prefs/json_pref_store.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698