diff options
author | zelidrag@chromium.org <zelidrag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-08 04:40:59 +0000 |
---|---|---|
committer | zelidrag@chromium.org <zelidrag@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-08 04:40:59 +0000 |
commit | 0de615a09db2bc15d4395063ec9683c1499c59a1 (patch) | |
tree | cadb1ae00204ebd53756a6dbb19d17832cb9fa84 /base/files | |
parent | 667be6ec365f627ba2a5628cfc8de0054a111b2f (diff) | |
download | chromium_src-0de615a09db2bc15d4395063ec9683c1499c59a1.zip chromium_src-0de615a09db2bc15d4395063ec9683c1499c59a1.tar.gz chromium_src-0de615a09db2bc15d4395063ec9683c1499c59a1.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@166603 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/files')
-rw-r--r-- | base/files/important_file_writer.cc | 12 | ||||
-rw-r--r-- | base/files/important_file_writer.h | 12 |
2 files changed, 12 insertions, 12 deletions
diff --git a/base/files/important_file_writer.cc b/base/files/important_file_writer.cc index 5663bdd..536b0fb 100644 --- a/base/files/important_file_writer.cc +++ b/base/files/important_file_writer.cc @@ -13,7 +13,7 @@ #include "base/file_path.h" #include "base/file_util.h" #include "base/logging.h" -#include "base/message_loop_proxy.h" +#include "base/task_runner.h" #include "base/metrics/histogram.h" #include "base/string_number_conversions.h" #include "base/threading/thread.h" @@ -90,14 +90,14 @@ void WriteToDiskTask(const FilePath& path, const std::string& data) { } // namespace ImportantFileWriter::ImportantFileWriter( - const FilePath& path, MessageLoopProxy* file_message_loop_proxy) + const FilePath& path, base::SequencedTaskRunner* task_runner) : path_(path), - file_message_loop_proxy_(file_message_loop_proxy), + task_runner_(task_runner), serializer_(NULL), commit_interval_(TimeDelta::FromMilliseconds( kDefaultCommitIntervalMs)) { DCHECK(CalledOnValidThread()); - DCHECK(file_message_loop_proxy_.get()); + DCHECK(task_runner_.get()); } ImportantFileWriter::~ImportantFileWriter() { @@ -122,8 +122,8 @@ void ImportantFileWriter::WriteNow(const std::string& data) { if (HasPendingWrite()) timer_.Stop(); - if (!file_message_loop_proxy_->PostTask( - FROM_HERE, MakeCriticalClosure(Bind(&WriteToDiskTask, path_, data)))) { + if (!task_runner_->PostTask(FROM_HERE, + MakeCriticalClosure(Bind(&WriteToDiskTask, path_, data)))) { // Posting the task to background message loop is not expected // to fail, but if it does, avoid losing data and just hit the disk // on the current thread. diff --git a/base/files/important_file_writer.h b/base/files/important_file_writer.h index 290813c..ae814d5 100644 --- a/base/files/important_file_writer.h +++ b/base/files/important_file_writer.h @@ -17,7 +17,7 @@ namespace base { -class MessageLoopProxy; +class SequencedTaskRunner; class Thread; // Helper to ensure that a file won't be corrupted by the write (for example on @@ -53,11 +53,11 @@ class BASE_EXPORT ImportantFileWriter : public NonThreadSafe { // Initialize the writer. // |path| is the name of file to write. - // |file_message_loop_proxy| is the MessageLoopProxy for a thread on which - // file I/O can be done. + // |task_runner| is the SequencedTaskRunner instance where on which we will + // execute file I/O operations. // All non-const methods, ctor and dtor must be called on the same thread. ImportantFileWriter(const FilePath& path, - MessageLoopProxy* file_message_loop_proxy); + base::SequencedTaskRunner* task_runner); // You have to ensure that there are no pending writes at the moment // of destruction. @@ -96,8 +96,8 @@ class BASE_EXPORT ImportantFileWriter : public NonThreadSafe { // Path being written to. const FilePath path_; - // MessageLoopProxy for the thread on which file I/O can be done. - scoped_refptr<MessageLoopProxy> file_message_loop_proxy_; + // TaskRunner for the thread on which file I/O can be done. + const scoped_refptr<base::SequencedTaskRunner> task_runner_; // Timer used to schedule commit after ScheduleWrite. OneShotTimer<ImportantFileWriter> timer_; |