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

Side by Side Diff: chrome/common/important_file_writer.h

Issue 10383262: RefCounted types should not have public destructors, delegate cleanup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make win bot happy Created 8 years, 5 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 | Annotate | Revision Log
OLDNEW
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 #ifndef CHROME_COMMON_IMPORTANT_FILE_WRITER_H_ 5 #ifndef CHROME_COMMON_IMPORTANT_FILE_WRITER_H_
6 #define CHROME_COMMON_IMPORTANT_FILE_WRITER_H_ 6 #define CHROME_COMMON_IMPORTANT_FILE_WRITER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 24 matching lines...) Expand all
35 // temporary file to target filename. 35 // temporary file to target filename.
36 // 36 //
37 // If you want to know more about this approach and ext3/ext4 fsync issues, see 37 // If you want to know more about this approach and ext3/ext4 fsync issues, see
38 // http://valhenson.livejournal.com/37921.html 38 // http://valhenson.livejournal.com/37921.html
39 class ImportantFileWriter : public base::NonThreadSafe { 39 class ImportantFileWriter : public base::NonThreadSafe {
40 public: 40 public:
41 // Used by ScheduleSave to lazily provide the data to be saved. Allows us 41 // Used by ScheduleSave to lazily provide the data to be saved. Allows us
42 // to also batch data serializations. 42 // to also batch data serializations.
43 class DataSerializer { 43 class DataSerializer {
44 public: 44 public:
45 virtual ~DataSerializer() {}
46
47 // Should put serialized string in |data| and return true on successful 45 // Should put serialized string in |data| and return true on successful
48 // serialization. Will be called on the same thread on which 46 // serialization. Will be called on the same thread on which
49 // ImportantFileWriter has been created. 47 // ImportantFileWriter has been created.
50 virtual bool SerializeData(std::string* data) = 0; 48 virtual bool SerializeData(std::string* data) = 0;
49
50 protected:
51 virtual ~DataSerializer() {}
51 }; 52 };
52 53
53 // Initialize the writer. 54 // Initialize the writer.
54 // |path| is the name of file to write. 55 // |path| is the name of file to write.
55 // |file_message_loop_proxy| is the MessageLoopProxy for a thread on which 56 // |file_message_loop_proxy| is the MessageLoopProxy for a thread on which
56 // file I/O can be done. 57 // file I/O can be done.
57 // All non-const methods, ctor and dtor must be called on the same thread. 58 // All non-const methods, ctor and dtor must be called on the same thread.
58 ImportantFileWriter(const FilePath& path, 59 ImportantFileWriter(const FilePath& path,
59 base::MessageLoopProxy* file_message_loop_proxy); 60 base::MessageLoopProxy* file_message_loop_proxy);
60 61
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 // Serializer which will provide the data to be saved. 105 // Serializer which will provide the data to be saved.
105 DataSerializer* serializer_; 106 DataSerializer* serializer_;
106 107
107 // Time delta after which scheduled data will be written to disk. 108 // Time delta after which scheduled data will be written to disk.
108 base::TimeDelta commit_interval_; 109 base::TimeDelta commit_interval_;
109 110
110 DISALLOW_COPY_AND_ASSIGN(ImportantFileWriter); 111 DISALLOW_COPY_AND_ASSIGN(ImportantFileWriter);
111 }; 112 };
112 113
113 #endif // CHROME_COMMON_IMPORTANT_FILE_WRITER_H_ 114 #endif // CHROME_COMMON_IMPORTANT_FILE_WRITER_H_
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_service.h ('k') | chrome/common/net/gaia/gaia_oauth_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698