Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1283)

Side by Side Diff: base/files/important_file_writer.h

Issue 2204943002: Integrate registry_hash_store_contents with the rest of tracked prefs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove a lost include statement Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
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.
96 void DoScheduledWrite(); 96 void DoScheduledWrite();
97 97
98 // Registers |on_next_successful_write| to be called once, on the next 98 // Registers |on_next_successful_write_reply| to be invoked on the sequence
99 // successful write event. Only one callback can be set at once. 99 // owning this ImportantFileWriter in reply to the next successful write.
gab 2016/08/08 04:37:44 + "Only one such callback can be set at once." he
proberge 2016/08/31 17:30:15 Done.
100 void RegisterOnNextSuccessfulWriteCallback( 100 void RegisterOnNextSuccessfulWriteReply(
gab 2016/08/08 04:37:44 Need to update important_file_writer_unittest.cc
proberge 2016/08/31 17:30:15 Done.
101 const Closure& on_next_successful_write); 101 const Closure& on_next_successful_write_reply);
102
103 // Registers |on_next_write_callback| to be synchronously invoked from
104 // WriteFileAtomically() on its next write (i.e. from |task_runner_|), with
105 // |success| indicating whether it succeeded or not.
106 void RegisterOnNextWriteSynchronousCallback(
gab 2016/08/08 04:37:44 Update CL description to explain why this is requi
proberge 2016/08/31 17:30:15 Acknowledged. Will be done in precursor CL.
107 const Callback<void(bool success)>& on_next_write_callback);
gab 2016/08/08 04:37:44 Add test in important_file_writer_unittest.cc
proberge 2016/08/31 17:30:15 Done.
102 108
103 TimeDelta commit_interval() const { 109 TimeDelta commit_interval() const {
104 return commit_interval_; 110 return commit_interval_;
105 } 111 }
106 112
107 private: 113 private:
108 // Helper method for WriteNow(). 114 // Helper method for WriteNow().
109 bool PostWriteTask(const Callback<bool()>& task); 115 bool PostWriteTask(const Callback<bool()>& task);
110 116
111 // If |result| is true and |on_next_successful_write_| is set, invokes 117 // If |result| is true and |on_next_successful_write_| is set, invokes
112 // |on_successful_write_| and then resets it; no-ops otherwise. 118 // |on_successful_write_| and then resets it; no-ops otherwise.
113 void ForwardSuccessfulWrite(bool result); 119 void ForwardSuccessfulWrite(bool result);
114 120
115 // Invoked once and then reset on the next successful write event. 121 // Invoked once and then reset on the next successful write event.
116 Closure on_next_successful_write_; 122 Closure on_next_successful_write_reply_;
123
124 // Invoked synchronously on the next write event.
125 Callback<void(bool success)> on_next_write_callback_;
117 126
118 // Path being written to. 127 // Path being written to.
119 const FilePath path_; 128 const FilePath path_;
120 129
121 // TaskRunner for the thread on which file I/O can be done. 130 // TaskRunner for the thread on which file I/O can be done.
122 const scoped_refptr<SequencedTaskRunner> task_runner_; 131 const scoped_refptr<SequencedTaskRunner> task_runner_;
123 132
124 // Timer used to schedule commit after ScheduleWrite. 133 // Timer used to schedule commit after ScheduleWrite.
125 OneShotTimer timer_; 134 OneShotTimer timer_;
126 135
127 // Serializer which will provide the data to be saved. 136 // Serializer which will provide the data to be saved.
128 DataSerializer* serializer_; 137 DataSerializer* serializer_;
129 138
130 // Time delta after which scheduled data will be written to disk. 139 // Time delta after which scheduled data will be written to disk.
131 const TimeDelta commit_interval_; 140 const TimeDelta commit_interval_;
132 141
133 WeakPtrFactory<ImportantFileWriter> weak_factory_; 142 WeakPtrFactory<ImportantFileWriter> weak_factory_;
134 143
135 DISALLOW_COPY_AND_ASSIGN(ImportantFileWriter); 144 DISALLOW_COPY_AND_ASSIGN(ImportantFileWriter);
136 }; 145 };
137 146
138 } // namespace base 147 } // namespace base
139 148
140 #endif // BASE_FILES_IMPORTANT_FILE_WRITER_H_ 149 #endif // BASE_FILES_IMPORTANT_FILE_WRITER_H_
OLDNEW
« no previous file with comments | « no previous file | base/files/important_file_writer.cc » ('j') | chrome/browser/prefs/profile_pref_store_manager.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698