| 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/files/file_util.h" | 7 #include "base/files/file_util.h" |
| 8 #include "base/files/scoped_file.h" | 8 #include "base/files/scoped_file.h" |
| 9 #include "base/md5.h" | 9 #include "base/md5.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 } | 611 } |
| 612 | 612 |
| 613 if (!ReadAndVerifyChecksum(file_.get(), &context)) { | 613 if (!ReadAndVerifyChecksum(file_.get(), &context)) { |
| 614 RecordFormatEvent(FORMAT_EVENT_VALIDITY_CHECKSUM_FAILURE); | 614 RecordFormatEvent(FORMAT_EVENT_VALIDITY_CHECKSUM_FAILURE); |
| 615 return OnCorruptDatabase(); | 615 return OnCorruptDatabase(); |
| 616 } | 616 } |
| 617 | 617 |
| 618 return true; | 618 return true; |
| 619 } | 619 } |
| 620 | 620 |
| 621 void SafeBrowsingStoreFile::Init( | 621 void SafeBrowsingStoreFile::Init(const base::FilePath& filename, |
| 622 const base::FilePath& filename, | 622 const base::Closure& corruption_callback) { |
| 623 const base::Closure& corruption_callback | |
| 624 ) { | |
| 625 filename_ = filename; | 623 filename_ = filename; |
| 626 corruption_callback_ = corruption_callback; | 624 corruption_callback_ = corruption_callback; |
| 627 } | 625 } |
| 628 | 626 |
| 629 bool SafeBrowsingStoreFile::BeginChunk() { | 627 bool SafeBrowsingStoreFile::BeginChunk() { |
| 630 return ClearChunkBuffers(); | 628 return ClearChunkBuffers(); |
| 631 } | 629 } |
| 632 | 630 |
| 633 bool SafeBrowsingStoreFile::WriteAddPrefix(int32 chunk_id, SBPrefix prefix) { | 631 bool SafeBrowsingStoreFile::WriteAddPrefix(int32 chunk_id, SBPrefix prefix) { |
| 634 add_prefixes_.push_back(SBAddPrefix(chunk_id, prefix)); | 632 add_prefixes_.push_back(SBAddPrefix(chunk_id, prefix)); |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1113 // With SQLite support gone, one way to get to this code is if the | 1111 // With SQLite support gone, one way to get to this code is if the |
| 1114 // existing file is a SQLite file. Make sure the journal file is | 1112 // existing file is a SQLite file. Make sure the journal file is |
| 1115 // also removed. | 1113 // also removed. |
| 1116 const base::FilePath journal_filename( | 1114 const base::FilePath journal_filename( |
| 1117 basename.value() + FILE_PATH_LITERAL("-journal")); | 1115 basename.value() + FILE_PATH_LITERAL("-journal")); |
| 1118 if (base::PathExists(journal_filename)) | 1116 if (base::PathExists(journal_filename)) |
| 1119 base::DeleteFile(journal_filename, false); | 1117 base::DeleteFile(journal_filename, false); |
| 1120 | 1118 |
| 1121 return true; | 1119 return true; |
| 1122 } | 1120 } |
| OLD | NEW |