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

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_store_file.h

Issue 1420053005: Move code in components/safe_browsing_db and chrome/browser/s_b/ under the safe_browsing namespace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@02_components_move
Patch Set: Remove '// namespace safe_browsing' for a small fwd decl block. Created 5 years, 1 month 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 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/sequenced_task_runner.h" 16 #include "base/sequenced_task_runner.h"
17 17
18 namespace safe_browsing {
19
18 // Implement SafeBrowsingStore in terms of a flat file. The file 20 // Implement SafeBrowsingStore in terms of a flat file. The file
19 // format is pretty literal: 21 // format is pretty literal:
20 // 22 //
21 // int32 magic; // magic number "validating" file 23 // int32 magic; // magic number "validating" file
22 // int32 version; // format version 24 // int32 version; // format version
23 // 25 //
24 // // Counts for the various data which follows the header. 26 // // Counts for the various data which follows the header.
25 // uint32 add_chunk_count; // Chunks seen, including empties. 27 // uint32 add_chunk_count; // Chunks seen, including empties.
26 // uint32 sub_chunk_count; // Ditto. 28 // uint32 sub_chunk_count; // Ditto.
27 // uint32 shard_stride; // SBPrefix space covered per shard. 29 // uint32 shard_stride; // SBPrefix space covered per shard.
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 bool WriteSubPrefix(int32 chunk_id, 149 bool WriteSubPrefix(int32 chunk_id,
148 int32 add_chunk_id, 150 int32 add_chunk_id,
149 SBPrefix prefix) override; 151 SBPrefix prefix) override;
150 bool WriteSubHash(int32 chunk_id, 152 bool WriteSubHash(int32 chunk_id,
151 int32 add_chunk_id, 153 int32 add_chunk_id,
152 const SBFullHash& full_hash) override; 154 const SBFullHash& full_hash) override;
153 bool FinishChunk() override; 155 bool FinishChunk() override;
154 156
155 bool BeginUpdate() override; 157 bool BeginUpdate() override;
156 bool FinishUpdate( 158 bool FinishUpdate(
157 safe_browsing::PrefixSetBuilder* builder, 159 PrefixSetBuilder* builder,
158 std::vector<SBAddFullHash>* add_full_hashes_result) override; 160 std::vector<SBAddFullHash>* add_full_hashes_result) override;
159 bool CancelUpdate() override; 161 bool CancelUpdate() override;
160 162
161 void SetAddChunk(int32 chunk_id) override; 163 void SetAddChunk(int32 chunk_id) override;
162 bool CheckAddChunk(int32 chunk_id) override; 164 bool CheckAddChunk(int32 chunk_id) override;
163 void GetAddChunks(std::vector<int32>* out) override; 165 void GetAddChunks(std::vector<int32>* out) override;
164 void SetSubChunk(int32 chunk_id) override; 166 void SetSubChunk(int32 chunk_id) override;
165 bool CheckSubChunk(int32 chunk_id) override; 167 bool CheckSubChunk(int32 chunk_id) override;
166 void GetSubChunks(std::vector<int32>* out) override; 168 void GetSubChunks(std::vector<int32>* out) override;
167 169
(...skipping 14 matching lines...) Expand all
182 // Delete any on-disk files, including the permanent storage. 184 // Delete any on-disk files, including the permanent storage.
183 static bool DeleteStore(const base::FilePath& basename); 185 static bool DeleteStore(const base::FilePath& basename);
184 186
185 private: 187 private:
186 // Checks whether the current thread is part of the sequenced task runner 188 // Checks whether the current thread is part of the sequenced task runner
187 // this object was initialized with. 189 // this object was initialized with.
188 bool CalledOnValidThread(); 190 bool CalledOnValidThread();
189 191
190 // Does the actual update for FinishUpdate(), so that FinishUpdate() can clean 192 // Does the actual update for FinishUpdate(), so that FinishUpdate() can clean
191 // up correctly in case of error. 193 // up correctly in case of error.
192 virtual bool DoUpdate(safe_browsing::PrefixSetBuilder* builder, 194 virtual bool DoUpdate(PrefixSetBuilder* builder,
193 std::vector<SBAddFullHash>* add_full_hashes_result); 195 std::vector<SBAddFullHash>* add_full_hashes_result);
194 196
195 // Some very lucky users have an original-format file still in their 197 // Some very lucky users have an original-format file still in their
196 // profile. Check for it and delete, recording a histogram for the 198 // profile. Check for it and delete, recording a histogram for the
197 // result (no histogram for not-found). Logically this 199 // result (no histogram for not-found). Logically this
198 // would make more sense at the SafeBrowsingDatabase level, but 200 // would make more sense at the SafeBrowsingDatabase level, but
199 // practically speaking that code doesn't touch files directly. 201 // practically speaking that code doesn't touch files directly.
200 static void CheckForOriginalAndDelete(const base::FilePath& filename); 202 static void CheckForOriginalAndDelete(const base::FilePath& filename);
201 203
202 // Close all files and clear all buffers. 204 // Close all files and clear all buffers.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
272 base::Closure corruption_callback_; 274 base::Closure corruption_callback_;
273 275
274 // Tracks whether corruption has already been seen in the current 276 // Tracks whether corruption has already been seen in the current
275 // update, so that only one instance is recorded in the stats. 277 // update, so that only one instance is recorded in the stats.
276 // TODO(shess): Remove with format-migration support. 278 // TODO(shess): Remove with format-migration support.
277 bool corruption_seen_; 279 bool corruption_seen_;
278 280
279 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingStoreFile); 281 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingStoreFile);
280 }; 282 };
281 283
284 } // namespace safe_browsing
285
282 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_FILE_H_ 286 #endif // CHROME_BROWSER_SAFE_BROWSING_SAFE_BROWSING_STORE_FILE_H_
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/safe_browsing_store.cc ('k') | chrome/browser/safe_browsing/safe_browsing_store_file.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698