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 CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_FILE_H_ | 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_FILE_H_ |
6 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_FILE_H_ | 6 #define CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_FILE_H_ |
7 | 7 |
8 #include <set> | 8 #include <set> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 // - Write shards to the temp file. | 121 // - Write shards to the temp file. |
122 // - Delete original file. | 122 // - Delete original file. |
123 // - Rename temp file to original filename. | 123 // - Rename temp file to original filename. |
124 | 124 |
125 class SafeBrowsingStoreFile : public SafeBrowsingStore { | 125 class SafeBrowsingStoreFile : public SafeBrowsingStore { |
126 public: | 126 public: |
127 SafeBrowsingStoreFile(); | 127 SafeBrowsingStoreFile(); |
128 virtual ~SafeBrowsingStoreFile(); | 128 virtual ~SafeBrowsingStoreFile(); |
129 | 129 |
130 virtual void Init(const base::FilePath& filename, | 130 virtual void Init(const base::FilePath& filename, |
131 const base::Closure& corruption_callback) OVERRIDE; | 131 const base::Closure& corruption_callback) override; |
132 | 132 |
133 // Delete any on-disk files, including the permanent storage. | 133 // Delete any on-disk files, including the permanent storage. |
134 virtual bool Delete() OVERRIDE; | 134 virtual bool Delete() override; |
135 | 135 |
136 // Get all add hash prefixes and full-length hashes, respectively, from | 136 // Get all add hash prefixes and full-length hashes, respectively, from |
137 // the store. | 137 // the store. |
138 virtual bool GetAddPrefixes(SBAddPrefixes* add_prefixes) OVERRIDE; | 138 virtual bool GetAddPrefixes(SBAddPrefixes* add_prefixes) override; |
139 virtual bool GetAddFullHashes( | 139 virtual bool GetAddFullHashes( |
140 std::vector<SBAddFullHash>* add_full_hashes) OVERRIDE; | 140 std::vector<SBAddFullHash>* add_full_hashes) override; |
141 | 141 |
142 virtual bool BeginChunk() OVERRIDE; | 142 virtual bool BeginChunk() override; |
143 | 143 |
144 virtual bool WriteAddPrefix(int32 chunk_id, SBPrefix prefix) OVERRIDE; | 144 virtual bool WriteAddPrefix(int32 chunk_id, SBPrefix prefix) override; |
145 virtual bool WriteAddHash(int32 chunk_id, | 145 virtual bool WriteAddHash(int32 chunk_id, |
146 const SBFullHash& full_hash) OVERRIDE; | 146 const SBFullHash& full_hash) override; |
147 virtual bool WriteSubPrefix(int32 chunk_id, | 147 virtual bool WriteSubPrefix(int32 chunk_id, |
148 int32 add_chunk_id, SBPrefix prefix) OVERRIDE; | 148 int32 add_chunk_id, SBPrefix prefix) override; |
149 virtual bool WriteSubHash(int32 chunk_id, int32 add_chunk_id, | 149 virtual bool WriteSubHash(int32 chunk_id, int32 add_chunk_id, |
150 const SBFullHash& full_hash) OVERRIDE; | 150 const SBFullHash& full_hash) override; |
151 virtual bool FinishChunk() OVERRIDE; | 151 virtual bool FinishChunk() override; |
152 | 152 |
153 virtual bool BeginUpdate() OVERRIDE; | 153 virtual bool BeginUpdate() override; |
154 virtual bool FinishUpdate( | 154 virtual bool FinishUpdate( |
155 safe_browsing::PrefixSetBuilder* builder, | 155 safe_browsing::PrefixSetBuilder* builder, |
156 std::vector<SBAddFullHash>* add_full_hashes_result) OVERRIDE; | 156 std::vector<SBAddFullHash>* add_full_hashes_result) override; |
157 virtual bool CancelUpdate() OVERRIDE; | 157 virtual bool CancelUpdate() override; |
158 | 158 |
159 virtual void SetAddChunk(int32 chunk_id) OVERRIDE; | 159 virtual void SetAddChunk(int32 chunk_id) override; |
160 virtual bool CheckAddChunk(int32 chunk_id) OVERRIDE; | 160 virtual bool CheckAddChunk(int32 chunk_id) override; |
161 virtual void GetAddChunks(std::vector<int32>* out) OVERRIDE; | 161 virtual void GetAddChunks(std::vector<int32>* out) override; |
162 virtual void SetSubChunk(int32 chunk_id) OVERRIDE; | 162 virtual void SetSubChunk(int32 chunk_id) override; |
163 virtual bool CheckSubChunk(int32 chunk_id) OVERRIDE; | 163 virtual bool CheckSubChunk(int32 chunk_id) override; |
164 virtual void GetSubChunks(std::vector<int32>* out) OVERRIDE; | 164 virtual void GetSubChunks(std::vector<int32>* out) override; |
165 | 165 |
166 virtual void DeleteAddChunk(int32 chunk_id) OVERRIDE; | 166 virtual void DeleteAddChunk(int32 chunk_id) override; |
167 virtual void DeleteSubChunk(int32 chunk_id) OVERRIDE; | 167 virtual void DeleteSubChunk(int32 chunk_id) override; |
168 | 168 |
169 // Verify |file_|'s checksum, calling the corruption callback if it | 169 // Verify |file_|'s checksum, calling the corruption callback if it |
170 // does not check out. Empty input is considered valid. | 170 // does not check out. Empty input is considered valid. |
171 virtual bool CheckValidity() OVERRIDE; | 171 virtual bool CheckValidity() override; |
172 | 172 |
173 // Returns the name of the temporary file used to buffer data for | 173 // Returns the name of the temporary file used to buffer data for |
174 // |filename|. Exported for unit tests. | 174 // |filename|. Exported for unit tests. |
175 static const base::FilePath TemporaryFileForFilename( | 175 static const base::FilePath TemporaryFileForFilename( |
176 const base::FilePath& filename) { | 176 const base::FilePath& filename) { |
177 return base::FilePath(filename.value() + FILE_PATH_LITERAL("_new")); | 177 return base::FilePath(filename.value() + FILE_PATH_LITERAL("_new")); |
178 } | 178 } |
179 | 179 |
180 // Delete any on-disk files, including the permanent storage. | 180 // Delete any on-disk files, including the permanent storage. |
181 static bool DeleteStore(const base::FilePath& basename); | 181 static bool DeleteStore(const base::FilePath& basename); |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 | 263 |
264 // Tracks whether corruption has already been seen in the current | 264 // Tracks whether corruption has already been seen in the current |
265 // update, so that only one instance is recorded in the stats. | 265 // update, so that only one instance is recorded in the stats. |
266 // TODO(shess): Remove with format-migration support. | 266 // TODO(shess): Remove with format-migration support. |
267 bool corruption_seen_; | 267 bool corruption_seen_; |
268 | 268 |
269 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingStoreFile); | 269 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingStoreFile); |
270 }; | 270 }; |
271 | 271 |
272 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_FILE_H_ | 272 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_FILE_H_ |
OLD | NEW |