| 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 "webkit/browser/fileapi/sandbox_directory_database.h" | 5 #include "webkit/browser/fileapi/sandbox_directory_database.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <stack> | 10 #include <stack> |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 fileapi::SandboxDirectoryDatabase* dir_db, | 173 fileapi::SandboxDirectoryDatabase* dir_db, |
| 174 leveldb::DB* db, | 174 leveldb::DB* db, |
| 175 const base::FilePath& path) | 175 const base::FilePath& path) |
| 176 : dir_db_(dir_db), db_(db), path_(path), | 176 : dir_db_(dir_db), db_(db), path_(path), |
| 177 num_directories_in_db_(0), | 177 num_directories_in_db_(0), |
| 178 num_files_in_db_(0), | 178 num_files_in_db_(0), |
| 179 num_hierarchy_links_in_db_(0), | 179 num_hierarchy_links_in_db_(0), |
| 180 last_file_id_(-1), last_integer_(-1) { | 180 last_file_id_(-1), last_integer_(-1) { |
| 181 DCHECK(dir_db_); | 181 DCHECK(dir_db_); |
| 182 DCHECK(db_); | 182 DCHECK(db_); |
| 183 DCHECK(!path_.empty() && file_util::DirectoryExists(path_)); | 183 DCHECK(!path_.empty() && base::DirectoryExists(path_)); |
| 184 } | 184 } |
| 185 | 185 |
| 186 bool DatabaseCheckHelper::IsDatabaseEmpty() { | 186 bool DatabaseCheckHelper::IsDatabaseEmpty() { |
| 187 scoped_ptr<leveldb::Iterator> itr(db_->NewIterator(leveldb::ReadOptions())); | 187 scoped_ptr<leveldb::Iterator> itr(db_->NewIterator(leveldb::ReadOptions())); |
| 188 itr->SeekToFirst(); | 188 itr->SeekToFirst(); |
| 189 return !itr->Valid(); | 189 return !itr->Valid(); |
| 190 } | 190 } |
| 191 | 191 |
| 192 bool DatabaseCheckHelper::ScanDatabase() { | 192 bool DatabaseCheckHelper::ScanDatabase() { |
| 193 // Scans all database entries sequentially to verify each of them has unique | 193 // Scans all database entries sequentially to verify each of them has unique |
| (...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 916 | 916 |
| 917 void SandboxDirectoryDatabase::HandleError( | 917 void SandboxDirectoryDatabase::HandleError( |
| 918 const tracked_objects::Location& from_here, | 918 const tracked_objects::Location& from_here, |
| 919 const leveldb::Status& status) { | 919 const leveldb::Status& status) { |
| 920 LOG(ERROR) << "SandboxDirectoryDatabase failed at: " | 920 LOG(ERROR) << "SandboxDirectoryDatabase failed at: " |
| 921 << from_here.ToString() << " with error: " << status.ToString(); | 921 << from_here.ToString() << " with error: " << status.ToString(); |
| 922 db_.reset(); | 922 db_.reset(); |
| 923 } | 923 } |
| 924 | 924 |
| 925 } // namespace fileapi | 925 } // namespace fileapi |
| OLD | NEW |