Index: base/files/important_file_writer.cc |
diff --git a/base/files/important_file_writer.cc b/base/files/important_file_writer.cc |
index 814fc7b9add0eb8e30d951b5784e8ec817c64055..e6fa3a3e896a657ecf04b7820f738ee477b2f46a 100644 |
--- a/base/files/important_file_writer.cc |
+++ b/base/files/important_file_writer.cc |
@@ -54,14 +54,14 @@ void LogFailure(const FilePath& path, TempFileFailure failure_code, |
// Helper function to call WriteFileAtomically() with a scoped_ptr<std::string>. |
bool WriteScopedStringToFileAtomically(const FilePath& path, |
scoped_ptr<std::string> data) { |
- return ImportantFileWriter::WriteFileAtomically(path, *data); |
+ return ImportantFileWriterImpl::WriteFileAtomically(path, *data); |
} |
} // namespace |
// static |
-bool ImportantFileWriter::WriteFileAtomically(const FilePath& path, |
- const std::string& data) { |
+bool ImportantFileWriterImpl::WriteFileAtomically(const FilePath& path, |
+ const std::string& data) { |
#if defined(OS_CHROMEOS) |
// On Chrome OS, chrome gets killed when it cannot finish shutdown quickly, |
// and this function seems to be one of the slowest shutdown steps. |
@@ -121,7 +121,7 @@ bool ImportantFileWriter::WriteFileAtomically(const FilePath& path, |
return true; |
} |
-ImportantFileWriter::ImportantFileWriter( |
+ImportantFileWriterImpl::ImportantFileWriterImpl( |
const FilePath& path, |
const scoped_refptr<base::SequencedTaskRunner>& task_runner) |
: path_(path), |
@@ -133,19 +133,19 @@ ImportantFileWriter::ImportantFileWriter( |
DCHECK(task_runner_); |
} |
-ImportantFileWriter::~ImportantFileWriter() { |
+ImportantFileWriterImpl::~ImportantFileWriterImpl() { |
// We're usually a member variable of some other object, which also tends |
// to be our serializer. It may not be safe to call back to the parent object |
// being destructed. |
DCHECK(!HasPendingWrite()); |
} |
-bool ImportantFileWriter::HasPendingWrite() const { |
+bool ImportantFileWriterImpl::HasPendingWrite() const { |
DCHECK(CalledOnValidThread()); |
return timer_.IsRunning(); |
} |
-void ImportantFileWriter::WriteNow(scoped_ptr<std::string> data) { |
+void ImportantFileWriterImpl::WriteNow(scoped_ptr<std::string> data) { |
DCHECK(CalledOnValidThread()); |
if (data->length() > static_cast<size_t>(kint32max)) { |
NOTREACHED(); |
@@ -166,7 +166,7 @@ void ImportantFileWriter::WriteNow(scoped_ptr<std::string> data) { |
} |
} |
-void ImportantFileWriter::ScheduleWrite(DataSerializer* serializer) { |
+void ImportantFileWriterImpl::ScheduleWrite(DataSerializer* serializer) { |
DCHECK(CalledOnValidThread()); |
DCHECK(serializer); |
@@ -174,11 +174,11 @@ void ImportantFileWriter::ScheduleWrite(DataSerializer* serializer) { |
if (!timer_.IsRunning()) { |
timer_.Start(FROM_HERE, commit_interval_, this, |
- &ImportantFileWriter::DoScheduledWrite); |
+ &ImportantFileWriterImpl::DoScheduledWrite); |
} |
} |
-void ImportantFileWriter::DoScheduledWrite() { |
+void ImportantFileWriterImpl::DoScheduledWrite() { |
DCHECK(serializer_); |
scoped_ptr<std::string> data(new std::string); |
if (serializer_->SerializeData(data.get())) { |
@@ -190,13 +190,17 @@ void ImportantFileWriter::DoScheduledWrite() { |
serializer_ = NULL; |
} |
-void ImportantFileWriter::RegisterOnNextSuccessfulWriteCallback( |
+void ImportantFileWriterImpl::RegisterOnNextSuccessfulWriteCallback( |
const base::Closure& on_next_successful_write) { |
DCHECK(on_next_successful_write_.is_null()); |
on_next_successful_write_ = on_next_successful_write; |
} |
-bool ImportantFileWriter::PostWriteTask(const Callback<bool()>& task) { |
+TimeDelta ImportantFileWriterImpl::CommitInterval() const { |
+ return commit_interval_; |
+} |
+ |
+bool ImportantFileWriterImpl::PostWriteTask(const Callback<bool()>& task) { |
// TODO(gab): This code could always use PostTaskAndReplyWithResult and let |
// ForwardSuccessfulWrite() no-op if |on_next_successful_write_| is null, but |
// PostTaskAndReply causes memory leaks in tests (crbug.com/371974) and |
@@ -204,10 +208,8 @@ bool ImportantFileWriter::PostWriteTask(const Callback<bool()>& task) { |
// using PostTask() in the typical scenario below. |
if (!on_next_successful_write_.is_null()) { |
return base::PostTaskAndReplyWithResult( |
- task_runner_.get(), |
- FROM_HERE, |
- MakeCriticalClosure(task), |
- Bind(&ImportantFileWriter::ForwardSuccessfulWrite, |
+ task_runner_.get(), FROM_HERE, MakeCriticalClosure(task), |
+ Bind(&ImportantFileWriterImpl::ForwardSuccessfulWrite, |
weak_factory_.GetWeakPtr())); |
} |
return task_runner_->PostTask( |
@@ -215,7 +217,7 @@ bool ImportantFileWriter::PostWriteTask(const Callback<bool()>& task) { |
MakeCriticalClosure(base::Bind(IgnoreResult(task)))); |
} |
-void ImportantFileWriter::ForwardSuccessfulWrite(bool result) { |
+void ImportantFileWriterImpl::ForwardSuccessfulWrite(bool result) { |
DCHECK(CalledOnValidThread()); |
if (result && !on_next_successful_write_.is_null()) { |
on_next_successful_write_.Run(); |