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 #include "chrome/browser/safe_browsing/safe_browsing_store_file.h" | 5 #include "chrome/browser/safe_browsing/safe_browsing_store_file.h" |
6 | 6 |
7 #include "base/md5.h" | 7 #include "base/md5.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 | 9 |
10 namespace { | 10 namespace { |
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
652 if (!file_util::TruncateFile(new_file_.get())) | 652 if (!file_util::TruncateFile(new_file_.get())) |
653 return false; | 653 return false; |
654 | 654 |
655 // Close the file handle and swizzle the file into place. | 655 // Close the file handle and swizzle the file into place. |
656 new_file_.reset(); | 656 new_file_.reset(); |
657 if (!base::Delete(filename_, false) && | 657 if (!base::Delete(filename_, false) && |
658 file_util::PathExists(filename_)) | 658 file_util::PathExists(filename_)) |
659 return false; | 659 return false; |
660 | 660 |
661 const base::FilePath new_filename = TemporaryFileForFilename(filename_); | 661 const base::FilePath new_filename = TemporaryFileForFilename(filename_); |
662 if (!file_util::Move(new_filename, filename_)) | 662 if (!base::Move(new_filename, filename_)) |
663 return false; | 663 return false; |
664 | 664 |
665 // Record counts before swapping to caller. | 665 // Record counts before swapping to caller. |
666 UMA_HISTOGRAM_COUNTS("SB2.AddPrefixes", add_prefixes.size()); | 666 UMA_HISTOGRAM_COUNTS("SB2.AddPrefixes", add_prefixes.size()); |
667 UMA_HISTOGRAM_COUNTS("SB2.SubPrefixes", sub_prefixes.size()); | 667 UMA_HISTOGRAM_COUNTS("SB2.SubPrefixes", sub_prefixes.size()); |
668 | 668 |
669 // Pass the resulting data off to the caller. | 669 // Pass the resulting data off to the caller. |
670 add_prefixes_result->swap(add_prefixes); | 670 add_prefixes_result->swap(add_prefixes); |
671 add_full_hashes_result->swap(add_full_hashes); | 671 add_full_hashes_result->swap(add_full_hashes); |
672 | 672 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
751 // With SQLite support gone, one way to get to this code is if the | 751 // With SQLite support gone, one way to get to this code is if the |
752 // existing file is a SQLite file. Make sure the journal file is | 752 // existing file is a SQLite file. Make sure the journal file is |
753 // also removed. | 753 // also removed. |
754 const base::FilePath journal_filename( | 754 const base::FilePath journal_filename( |
755 basename.value() + FILE_PATH_LITERAL("-journal")); | 755 basename.value() + FILE_PATH_LITERAL("-journal")); |
756 if (file_util::PathExists(journal_filename)) | 756 if (file_util::PathExists(journal_filename)) |
757 base::Delete(journal_filename, false); | 757 base::Delete(journal_filename, false); |
758 | 758 |
759 return true; | 759 return true; |
760 } | 760 } |
OLD | NEW |