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 |
11 #include "chrome/browser/safe_browsing/safe_browsing_store.h" | 11 #include "chrome/browser/safe_browsing/safe_browsing_store.h" |
12 | 12 |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
15 #include "base/files/scoped_file.h" | 15 #include "base/files/scoped_file.h" |
| 16 #include "base/threading/non_thread_safe.h" |
16 | 17 |
17 // Implement SafeBrowsingStore in terms of a flat file. The file | 18 // Implement SafeBrowsingStore in terms of a flat file. The file |
18 // format is pretty literal: | 19 // format is pretty literal: |
19 // | 20 // |
20 // int32 magic; // magic number "validating" file | 21 // int32 magic; // magic number "validating" file |
21 // int32 version; // format version | 22 // int32 version; // format version |
22 // | 23 // |
23 // // Counts for the various data which follows the header. | 24 // // Counts for the various data which follows the header. |
24 // uint32 add_chunk_count; // Chunks seen, including empties. | 25 // uint32 add_chunk_count; // Chunks seen, including empties. |
25 // uint32 sub_chunk_count; // Ditto. | 26 // uint32 sub_chunk_count; // Ditto. |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 // - When the transaction is finished: | 116 // - When the transaction is finished: |
116 // - Read the update data from the temp file into memory. | 117 // - Read the update data from the temp file into memory. |
117 // - Overwrite the temp file with new header data. | 118 // - Overwrite the temp file with new header data. |
118 // - Until done: | 119 // - Until done: |
119 // - Read shards of the original file's data into memory. | 120 // - Read shards of the original file's data into memory. |
120 // - Merge from the update data. | 121 // - Merge from the update data. |
121 // - Write shards to the temp file. | 122 // - Write shards to the temp file. |
122 // - Delete original file. | 123 // - Delete original file. |
123 // - Rename temp file to original filename. | 124 // - Rename temp file to original filename. |
124 | 125 |
125 class SafeBrowsingStoreFile : public SafeBrowsingStore { | 126 class SafeBrowsingStoreFile : public SafeBrowsingStore, |
| 127 public base::NonThreadSafe { |
126 public: | 128 public: |
127 SafeBrowsingStoreFile(); | 129 SafeBrowsingStoreFile(); |
128 ~SafeBrowsingStoreFile() override; | 130 ~SafeBrowsingStoreFile() override; |
129 | 131 |
130 void Init(const base::FilePath& filename, | 132 void Init(const base::FilePath& filename, |
131 const base::Closure& corruption_callback) override; | 133 const base::Closure& corruption_callback) override; |
132 | 134 |
133 // Delete any on-disk files, including the permanent storage. | 135 // Delete any on-disk files, including the permanent storage. |
134 bool Delete() override; | 136 bool Delete() override; |
135 | 137 |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 | 265 |
264 // Tracks whether corruption has already been seen in the current | 266 // Tracks whether corruption has already been seen in the current |
265 // update, so that only one instance is recorded in the stats. | 267 // update, so that only one instance is recorded in the stats. |
266 // TODO(shess): Remove with format-migration support. | 268 // TODO(shess): Remove with format-migration support. |
267 bool corruption_seen_; | 269 bool corruption_seen_; |
268 | 270 |
269 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingStoreFile); | 271 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingStoreFile); |
270 }; | 272 }; |
271 | 273 |
272 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_FILE_H_ | 274 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_FILE_H_ |
OLD | NEW |