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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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. |
81 bool HasPendingWrite() const; | 81 bool HasPendingWrite() const; |
82 | 82 |
83 // Save |data| to target filename. Does not block. If there is a pending write | 83 // Save |data| to target filename. Does not block. If there is a pending write |
84 // scheduled by ScheduleWrite(), it is cancelled. | 84 // scheduled by ScheduleWrite(), it is cancelled. |
85 void WriteNow(scoped_ptr<std::string> data); | 85 void WriteNow(std::unique_ptr<std::string> data); |
86 | 86 |
87 // Schedule a save to target filename. Data will be serialized and saved | 87 // Schedule a save to target filename. Data will be serialized and saved |
88 // to disk after the commit interval. If another ScheduleWrite is issued | 88 // to disk after the commit interval. If another ScheduleWrite is issued |
89 // before that, only one serialization and write to disk will happen, and | 89 // before that, only one serialization and write to disk will happen, and |
90 // the most recent |serializer| will be used. This operation does not block. | 90 // the most recent |serializer| will be used. This operation does not block. |
91 // |serializer| should remain valid through the lifetime of | 91 // |serializer| should remain valid through the lifetime of |
92 // ImportantFileWriter. | 92 // ImportantFileWriter. |
93 void ScheduleWrite(DataSerializer* serializer); | 93 void ScheduleWrite(DataSerializer* serializer); |
94 | 94 |
95 // Serialize data pending to be saved and execute write on backend thread. | 95 // Serialize data pending to be saved and execute write on backend thread. |
(...skipping 35 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 |