| 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" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 // Blocks and writes data on the current thread. | 56 // Blocks and writes data on the current thread. |
| 57 static bool WriteFileAtomically(const FilePath& path, | 57 static bool WriteFileAtomically(const FilePath& path, |
| 58 const std::string& data); | 58 const std::string& data); |
| 59 | 59 |
| 60 // Initialize the writer. | 60 // Initialize the writer. |
| 61 // |path| is the name of file to write. | 61 // |path| is the name of file to write. |
| 62 // |task_runner| is the SequencedTaskRunner instance where on which we will | 62 // |task_runner| is the SequencedTaskRunner instance where on which we will |
| 63 // execute file I/O operations. | 63 // execute file I/O operations. |
| 64 // All non-const methods, ctor and dtor must be called on the same thread. | 64 // All non-const methods, ctor and dtor must be called on the same thread. |
| 65 ImportantFileWriter(const FilePath& path, | 65 ImportantFileWriter(const FilePath& path, |
| 66 const scoped_refptr<SequencedTaskRunner>& task_runner); | 66 scoped_refptr<SequencedTaskRunner> task_runner); |
| 67 | 67 |
| 68 // Same as above, but with a custom commit interval. | 68 // Same as above, but with a custom commit interval. |
| 69 ImportantFileWriter(const FilePath& path, | 69 ImportantFileWriter(const FilePath& path, |
| 70 const scoped_refptr<SequencedTaskRunner>& task_runner, | 70 scoped_refptr<SequencedTaskRunner> task_runner, |
| 71 TimeDelta interval); | 71 TimeDelta interval); |
| 72 | 72 |
| 73 // You have to ensure that there are no pending writes at the moment | 73 // You have to ensure that there are no pending writes at the moment |
| 74 // of destruction. | 74 // of destruction. |
| 75 ~ImportantFileWriter(); | 75 ~ImportantFileWriter(); |
| 76 | 76 |
| 77 const FilePath& path() const { return path_; } | 77 const FilePath& path() const { return path_; } |
| 78 | 78 |
| 79 // Returns true if there is a scheduled write pending which has not yet | 79 // Returns true if there is a scheduled write pending which has not yet |
| 80 // been started. | 80 // been started. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 const TimeDelta commit_interval_; | 131 const TimeDelta commit_interval_; |
| 132 | 132 |
| 133 WeakPtrFactory<ImportantFileWriter> weak_factory_; | 133 WeakPtrFactory<ImportantFileWriter> weak_factory_; |
| 134 | 134 |
| 135 DISALLOW_COPY_AND_ASSIGN(ImportantFileWriter); | 135 DISALLOW_COPY_AND_ASSIGN(ImportantFileWriter); |
| 136 }; | 136 }; |
| 137 | 137 |
| 138 } // namespace base | 138 } // namespace base |
| 139 | 139 |
| 140 #endif // BASE_FILES_IMPORTANT_FILE_WRITER_H_ | 140 #endif // BASE_FILES_IMPORTANT_FILE_WRITER_H_ |
| OLD | NEW |