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

Side by Side Diff: components/safe_browsing_db/v4_store.h

Issue 2383063003: Add UMA metrics for the time it takes to read store from disk and apply update (Closed)
Patch Set: Reduce the max value and increase the number of buckets in histogram. Created 4 years, 2 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 COMPONENTS_SAFE_BROWSING_DB_V4_STORE_H_ 5 #ifndef COMPONENTS_SAFE_BROWSING_DB_V4_STORE_H_
6 #define COMPONENTS_SAFE_BROWSING_DB_V4_STORE_H_ 6 #define COMPONENTS_SAFE_BROWSING_DB_V4_STORE_H_
7 7
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/sequenced_task_runner.h" 10 #include "base/sequenced_task_runner.h"
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 IteratorMap* iterator_map); 283 IteratorMap* iterator_map);
284 284
285 // Reserve the appropriate string size so that the string size of the merged 285 // Reserve the appropriate string size so that the string size of the merged
286 // list is exact. This ignores the space that would otherwise be released by 286 // list is exact. This ignores the space that would otherwise be released by
287 // deletions specified in the update because it is non-trivial to calculate 287 // deletions specified in the update because it is non-trivial to calculate
288 // those deletions upfront. This isn't so bad since deletions are supposed to 288 // those deletions upfront. This isn't so bad since deletions are supposed to
289 // be small and infrequent. 289 // be small and infrequent.
290 static void ReserveSpaceInPrefixMap(const HashPrefixMap& other_prefixes_map, 290 static void ReserveSpaceInPrefixMap(const HashPrefixMap& other_prefixes_map,
291 HashPrefixMap* prefix_map_to_update); 291 HashPrefixMap* prefix_map_to_update);
292 292
293 // Updates the |additions_map| with the additions received in the partial
294 // update from the server.
295 static ApplyUpdateResult UpdateHashPrefixMapFromAdditions(
296 const ::google::protobuf::RepeatedPtrField<ThreatEntrySet>& additions,
297 HashPrefixMap* additions_map);
298
299 // Merges the prefix map from the old store (|old_hash_prefix_map|) and the 293 // Merges the prefix map from the old store (|old_hash_prefix_map|) and the
300 // update (additions_map) to populate the prefix map for the current store. 294 // update (additions_map) to populate the prefix map for the current store.
301 // The indices in the |raw_removals| list, which may be NULL, are not merged. 295 // The indices in the |raw_removals| list, which may be NULL, are not merged.
302 // The SHA256 checksum of the final list of hash prefixes, in lexographically 296 // The SHA256 checksum of the final list of hash prefixes, in lexographically
303 // sorted order, must match |expected_checksum| (if it's not empty). 297 // sorted order, must match |expected_checksum| (if it's not empty).
304 ApplyUpdateResult MergeUpdate(const HashPrefixMap& old_hash_prefix_map, 298 ApplyUpdateResult MergeUpdate(const HashPrefixMap& old_hash_prefix_map,
305 const HashPrefixMap& additions_map, 299 const HashPrefixMap& additions_map,
306 const ::google::protobuf::RepeatedField< 300 const ::google::protobuf::RepeatedField<
307 ::google::protobuf::int32>* raw_removals, 301 ::google::protobuf::int32>* raw_removals,
308 const std::string& expected_checksum); 302 const std::string& expected_checksum);
(...skipping 25 matching lines...) Expand all
334 // updates the |hash_prefix_map_| and |state_| in the V4Store. If processing 328 // updates the |hash_prefix_map_| and |state_| in the V4Store. If processing
335 // succeeds, it returns APPLY_UPDATE_SUCCESS. 329 // succeeds, it returns APPLY_UPDATE_SUCCESS.
336 ApplyUpdateResult ProcessUpdate( 330 ApplyUpdateResult ProcessUpdate(
337 const HashPrefixMap& hash_prefix_map_old, 331 const HashPrefixMap& hash_prefix_map_old,
338 const std::unique_ptr<ListUpdateResponse>& response); 332 const std::unique_ptr<ListUpdateResponse>& response);
339 333
340 // Reads the state of the store from the file on disk and returns the reason 334 // Reads the state of the store from the file on disk and returns the reason
341 // for the failure or reports success. 335 // for the failure or reports success.
342 StoreReadResult ReadFromDisk(); 336 StoreReadResult ReadFromDisk();
343 337
338 // Updates the |additions_map| with the additions received in the partial
339 // update from the server.
340 ApplyUpdateResult UpdateHashPrefixMapFromAdditions(
341 const ::google::protobuf::RepeatedPtrField<ThreatEntrySet>& additions,
342 HashPrefixMap* additions_map);
343
344 // Writes the FULL_UPDATE |response| to disk as a V4StoreFileFormat proto. 344 // Writes the FULL_UPDATE |response| to disk as a V4StoreFileFormat proto.
345 StoreWriteResult WriteToDisk( 345 StoreWriteResult WriteToDisk(
346 std::unique_ptr<ListUpdateResponse> response) const; 346 std::unique_ptr<ListUpdateResponse> response) const;
347 347
348 // The state of the store as returned by the PVer4 server in the last applied 348 // The state of the store as returned by the PVer4 server in the last applied
349 // update response. 349 // update response.
350 std::string state_; 350 std::string state_;
351 const base::FilePath store_path_; 351 const base::FilePath store_path_;
352 HashPrefixMap hash_prefix_map_; 352 HashPrefixMap hash_prefix_map_;
353 const scoped_refptr<base::SequencedTaskRunner> task_runner_; 353 const scoped_refptr<base::SequencedTaskRunner> task_runner_;
354 }; 354 };
355 355
356 std::ostream& operator<<(std::ostream& os, const V4Store& store); 356 std::ostream& operator<<(std::ostream& os, const V4Store& store);
357 357
358 } // namespace safe_browsing 358 } // namespace safe_browsing
359 359
360 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_STORE_H_ 360 #endif // COMPONENTS_SAFE_BROWSING_DB_V4_STORE_H_
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/local_database_manager.cc ('k') | components/safe_browsing_db/v4_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698