| 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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 | 194 |
| 195 // Just best-effort on the journal file, don't want to get lost in | 195 // Just best-effort on the journal file, don't want to get lost in |
| 196 // the weeds. | 196 // the weeds. |
| 197 const base::FilePath journal_filename( | 197 const base::FilePath journal_filename( |
| 198 current_filename.DirName().AppendASCII("Safe Browsing-journal")); | 198 current_filename.DirName().AppendASCII("Safe Browsing-journal")); |
| 199 file_util::Delete(journal_filename, false); | 199 file_util::Delete(journal_filename, false); |
| 200 } | 200 } |
| 201 } | 201 } |
| 202 | 202 |
| 203 SafeBrowsingStoreFile::SafeBrowsingStoreFile() | 203 SafeBrowsingStoreFile::SafeBrowsingStoreFile() |
| 204 : chunks_written_(0), | 204 : chunks_written_(0), empty_(false), corruption_seen_(false) {} |
| 205 file_(NULL), | |
| 206 empty_(false), | |
| 207 corruption_seen_(false) { | |
| 208 } | |
| 209 | 205 |
| 210 SafeBrowsingStoreFile::~SafeBrowsingStoreFile() { | 206 SafeBrowsingStoreFile::~SafeBrowsingStoreFile() { |
| 211 Close(); | 207 Close(); |
| 212 } | 208 } |
| 213 | 209 |
| 214 bool SafeBrowsingStoreFile::Delete() { | 210 bool SafeBrowsingStoreFile::Delete() { |
| 215 // The database should not be open at this point. But, just in | 211 // The database should not be open at this point. But, just in |
| 216 // case, close everything before deleting. | 212 // case, close everything before deleting. |
| 217 if (!Close()) { | 213 if (!Close()) { |
| 218 NOTREACHED(); | 214 NOTREACHED(); |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 // 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 |
| 756 // 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 |
| 757 // also removed. | 753 // also removed. |
| 758 const base::FilePath journal_filename( | 754 const base::FilePath journal_filename( |
| 759 basename.value() + FILE_PATH_LITERAL("-journal")); | 755 basename.value() + FILE_PATH_LITERAL("-journal")); |
| 760 if (file_util::PathExists(journal_filename)) | 756 if (file_util::PathExists(journal_filename)) |
| 761 file_util::Delete(journal_filename, false); | 757 file_util::Delete(journal_filename, false); |
| 762 | 758 |
| 763 return true; | 759 return true; |
| 764 } | 760 } |
| OLD | NEW |