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 | |
9 #include <string> | 8 #include <string> |
| 9 #include <utility> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/critical_closure.h" | 12 #include "base/critical_closure.h" |
13 #include "base/debug/alias.h" | 13 #include "base/debug/alias.h" |
14 #include "base/files/file.h" | 14 #include "base/files/file.h" |
15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
16 #include "base/files/file_util.h" | 16 #include "base/files/file_util.h" |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
18 #include "base/metrics/histogram.h" | 18 #include "base/metrics/histogram.h" |
19 #include "base/numerics/safe_conversions.h" | 19 #include "base/numerics/safe_conversions.h" |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 if (!timer_.IsRunning()) { | 184 if (!timer_.IsRunning()) { |
185 timer_.Start(FROM_HERE, commit_interval_, this, | 185 timer_.Start(FROM_HERE, commit_interval_, this, |
186 &ImportantFileWriter::DoScheduledWrite); | 186 &ImportantFileWriter::DoScheduledWrite); |
187 } | 187 } |
188 } | 188 } |
189 | 189 |
190 void ImportantFileWriter::DoScheduledWrite() { | 190 void ImportantFileWriter::DoScheduledWrite() { |
191 DCHECK(serializer_); | 191 DCHECK(serializer_); |
192 scoped_ptr<std::string> data(new std::string); | 192 scoped_ptr<std::string> data(new std::string); |
193 if (serializer_->SerializeData(data.get())) { | 193 if (serializer_->SerializeData(data.get())) { |
194 WriteNow(data.Pass()); | 194 WriteNow(std::move(data)); |
195 } else { | 195 } else { |
196 DLOG(WARNING) << "failed to serialize data to be saved in " | 196 DLOG(WARNING) << "failed to serialize data to be saved in " |
197 << path_.value(); | 197 << path_.value(); |
198 } | 198 } |
199 serializer_ = nullptr; | 199 serializer_ = nullptr; |
200 } | 200 } |
201 | 201 |
202 void ImportantFileWriter::RegisterOnNextSuccessfulWriteCallback( | 202 void ImportantFileWriter::RegisterOnNextSuccessfulWriteCallback( |
203 const Closure& on_next_successful_write) { | 203 const Closure& on_next_successful_write) { |
204 DCHECK(on_next_successful_write_.is_null()); | 204 DCHECK(on_next_successful_write_.is_null()); |
(...skipping 21 matching lines...) Expand all Loading... |
226 | 226 |
227 void ImportantFileWriter::ForwardSuccessfulWrite(bool result) { | 227 void ImportantFileWriter::ForwardSuccessfulWrite(bool result) { |
228 DCHECK(CalledOnValidThread()); | 228 DCHECK(CalledOnValidThread()); |
229 if (result && !on_next_successful_write_.is_null()) { | 229 if (result && !on_next_successful_write_.is_null()) { |
230 on_next_successful_write_.Run(); | 230 on_next_successful_write_.Run(); |
231 on_next_successful_write_.Reset(); | 231 on_next_successful_write_.Reset(); |
232 } | 232 } |
233 } | 233 } |
234 | 234 |
235 } // namespace base | 235 } // namespace base |
OLD | NEW |