OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/files/important_file_writer.h" | 5 #include "base/files/important_file_writer.h" |
6 | 6 |
7 #include <stdio.h> | 7 #include <stdio.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 | 81 |
82 if (!base::ReplaceFile(tmp_file_path, path, NULL)) { | 82 if (!base::ReplaceFile(tmp_file_path, path, NULL)) { |
83 LogFailure(path, FAILED_RENAMING, "could not rename temporary file"); | 83 LogFailure(path, FAILED_RENAMING, "could not rename temporary file"); |
84 base::DeleteFile(tmp_file_path, false); | 84 base::DeleteFile(tmp_file_path, false); |
85 return false; | 85 return false; |
86 } | 86 } |
87 | 87 |
88 return true; | 88 return true; |
89 } | 89 } |
90 | 90 |
91 ImportantFileWriter::ImportantFileWriter(const FilePath& path, | 91 ImportantFileWriter::ImportantFileWriter( |
92 base::SequencedTaskRunner* task_runner) | 92 const FilePath& path, |
| 93 const scoped_refptr<base::SequencedTaskRunner>& task_runner) |
93 : path_(path), | 94 : path_(path), |
94 task_runner_(task_runner), | 95 task_runner_(task_runner), |
95 serializer_(NULL), | 96 serializer_(NULL), |
96 commit_interval_(TimeDelta::FromMilliseconds(kDefaultCommitIntervalMs)), | 97 commit_interval_(TimeDelta::FromMilliseconds(kDefaultCommitIntervalMs)), |
97 weak_factory_(this) { | 98 weak_factory_(this) { |
98 DCHECK(CalledOnValidThread()); | 99 DCHECK(CalledOnValidThread()); |
99 DCHECK(task_runner_.get()); | 100 DCHECK(task_runner_.get()); |
100 } | 101 } |
101 | 102 |
102 ImportantFileWriter::~ImportantFileWriter() { | 103 ImportantFileWriter::~ImportantFileWriter() { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 | 186 |
186 void ImportantFileWriter::ForwardSuccessfulWrite(bool result) { | 187 void ImportantFileWriter::ForwardSuccessfulWrite(bool result) { |
187 DCHECK(CalledOnValidThread()); | 188 DCHECK(CalledOnValidThread()); |
188 if (result && !on_next_successful_write_.is_null()) { | 189 if (result && !on_next_successful_write_.is_null()) { |
189 on_next_successful_write_.Run(); | 190 on_next_successful_write_.Run(); |
190 on_next_successful_write_.Reset(); | 191 on_next_successful_write_.Reset(); |
191 } | 192 } |
192 } | 193 } |
193 | 194 |
194 } // namespace base | 195 } // namespace base |
OLD | NEW |