| 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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 | 123 |
| 124 ImportantFileWriter::ImportantFileWriter( | 124 ImportantFileWriter::ImportantFileWriter( |
| 125 const FilePath& path, | 125 const FilePath& path, |
| 126 const scoped_refptr<base::SequencedTaskRunner>& task_runner) | 126 const scoped_refptr<base::SequencedTaskRunner>& task_runner) |
| 127 : path_(path), | 127 : path_(path), |
| 128 task_runner_(task_runner), | 128 task_runner_(task_runner), |
| 129 serializer_(NULL), | 129 serializer_(NULL), |
| 130 commit_interval_(TimeDelta::FromMilliseconds(kDefaultCommitIntervalMs)), | 130 commit_interval_(TimeDelta::FromMilliseconds(kDefaultCommitIntervalMs)), |
| 131 weak_factory_(this) { | 131 weak_factory_(this) { |
| 132 DCHECK(CalledOnValidThread()); | 132 DCHECK(CalledOnValidThread()); |
| 133 DCHECK(task_runner_.get()); | 133 DCHECK(task_runner_); |
| 134 } | 134 } |
| 135 | 135 |
| 136 ImportantFileWriter::~ImportantFileWriter() { | 136 ImportantFileWriter::~ImportantFileWriter() { |
| 137 // We're usually a member variable of some other object, which also tends | 137 // We're usually a member variable of some other object, which also tends |
| 138 // to be our serializer. It may not be safe to call back to the parent object | 138 // to be our serializer. It may not be safe to call back to the parent object |
| 139 // being destructed. | 139 // being destructed. |
| 140 DCHECK(!HasPendingWrite()); | 140 DCHECK(!HasPendingWrite()); |
| 141 } | 141 } |
| 142 | 142 |
| 143 bool ImportantFileWriter::HasPendingWrite() const { | 143 bool ImportantFileWriter::HasPendingWrite() const { |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 | 217 |
| 218 void ImportantFileWriter::ForwardSuccessfulWrite(bool result) { | 218 void ImportantFileWriter::ForwardSuccessfulWrite(bool result) { |
| 219 DCHECK(CalledOnValidThread()); | 219 DCHECK(CalledOnValidThread()); |
| 220 if (result && !on_next_successful_write_.is_null()) { | 220 if (result && !on_next_successful_write_.is_null()) { |
| 221 on_next_successful_write_.Run(); | 221 on_next_successful_write_.Run(); |
| 222 on_next_successful_write_.Reset(); | 222 on_next_successful_write_.Reset(); |
| 223 } | 223 } |
| 224 } | 224 } |
| 225 | 225 |
| 226 } // namespace base | 226 } // namespace base |
| OLD | NEW |