| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef BASE_FILES_IMPORTANT_FILE_WRITER_H_ | 5 #ifndef BASE_FILES_IMPORTANT_FILE_WRITER_H_ |
| 6 #define BASE_FILES_IMPORTANT_FILE_WRITER_H_ | 6 #define BASE_FILES_IMPORTANT_FILE_WRITER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/base_export.h" | 10 #include "base/base_export.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/files/file_path.h" | 12 #include "base/files/file_path.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/memory/ref_counted.h" | 14 #include "base/memory/ref_counted.h" |
| 15 #include "base/strings/string_piece.h" | 15 #include "base/strings/string_piece.h" |
| 16 #include "base/threading/non_thread_safe.h" | 16 #include "base/threading/non_thread_safe.h" |
| 17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 18 #include "base/timer/timer.h" | 18 #include "base/timer/timer.h" |
| 19 | 19 |
| 20 namespace base { | 20 namespace base { |
| 21 | 21 |
| 22 class SequencedTaskRunner; | 22 class SequencedTaskRunner; |
| 23 class Thread; | |
| 24 | 23 |
| 25 // Helper for atomically writing a file to ensure that it won't be corrupted by | 24 // Helper for atomically writing a file to ensure that it won't be corrupted by |
| 26 // *application* crash during write (implemented as create, flush, rename). | 25 // *application* crash during write (implemented as create, flush, rename). |
| 27 // | 26 // |
| 28 // As an added benefit, ImportantFileWriter makes it less likely that the file | 27 // As an added benefit, ImportantFileWriter makes it less likely that the file |
| 29 // is corrupted by *system* crash, though even if the ImportantFileWriter call | 28 // is corrupted by *system* crash, though even if the ImportantFileWriter call |
| 30 // has already returned at the time of the crash it is not specified which | 29 // has already returned at the time of the crash it is not specified which |
| 31 // version of the file (old or new) is preserved. And depending on system | 30 // version of the file (old or new) is preserved. And depending on system |
| 32 // configuration (hardware and software) a significant likelihood of file | 31 // configuration (hardware and software) a significant likelihood of file |
| 33 // corruption may remain, thus using ImportantFileWriter is not a valid | 32 // corruption may remain, thus using ImportantFileWriter is not a valid |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 const TimeDelta commit_interval_; | 130 const TimeDelta commit_interval_; |
| 132 | 131 |
| 133 WeakPtrFactory<ImportantFileWriter> weak_factory_; | 132 WeakPtrFactory<ImportantFileWriter> weak_factory_; |
| 134 | 133 |
| 135 DISALLOW_COPY_AND_ASSIGN(ImportantFileWriter); | 134 DISALLOW_COPY_AND_ASSIGN(ImportantFileWriter); |
| 136 }; | 135 }; |
| 137 | 136 |
| 138 } // namespace base | 137 } // namespace base |
| 139 | 138 |
| 140 #endif // BASE_FILES_IMPORTANT_FILE_WRITER_H_ | 139 #endif // BASE_FILES_IMPORTANT_FILE_WRITER_H_ |
| OLD | NEW |