| 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 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_DIRECTORY_DATABASE_H_ | 5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_DIRECTORY_DATABASE_H_ |
| 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_DIRECTORY_DATABASE_H_ | 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_DIRECTORY_DATABASE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 FileId parent_id; | 50 FileId parent_id; |
| 51 FilePath data_path; | 51 FilePath data_path; |
| 52 FilePath::StringType name; | 52 FilePath::StringType name; |
| 53 // This modification time is valid only for directories, not files, as | 53 // This modification time is valid only for directories, not files, as |
| 54 // FileWriter will get the files out of sync. | 54 // FileWriter will get the files out of sync. |
| 55 // For files, look at the modification time of the underlying data_path. | 55 // For files, look at the modification time of the underlying data_path. |
| 56 base::Time modification_time; | 56 base::Time modification_time; |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 explicit FileSystemDirectoryDatabase(const FilePath& path); | 59 explicit FileSystemDirectoryDatabase( |
| 60 const FilePath& filesystem_data_directory); |
| 60 ~FileSystemDirectoryDatabase(); | 61 ~FileSystemDirectoryDatabase(); |
| 61 | 62 |
| 62 bool GetChildWithName( | 63 bool GetChildWithName( |
| 63 FileId parent_id, const FilePath::StringType& name, FileId* child_id); | 64 FileId parent_id, const FilePath::StringType& name, FileId* child_id); |
| 64 bool GetFileWithPath(const FilePath& path, FileId* file_id); | 65 bool GetFileWithPath(const FilePath& path, FileId* file_id); |
| 65 // ListChildren will succeed, returning 0 children, if parent_id doesn't | 66 // ListChildren will succeed, returning 0 children, if parent_id doesn't |
| 66 // exist. | 67 // exist. |
| 67 bool ListChildren(FileId parent_id, std::vector<FileId>* children); | 68 bool ListChildren(FileId parent_id, std::vector<FileId>* children); |
| 68 bool GetFileInfo(FileId file_id, FileInfo* info); | 69 bool GetFileInfo(FileId file_id, FileInfo* info); |
| 69 bool AddFileInfo(const FileInfo& info, FileId* file_id); | 70 bool AddFileInfo(const FileInfo& info, FileId* file_id); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 81 bool OverwritingMoveFile(FileId src_file_id, FileId dest_file_id); | 82 bool OverwritingMoveFile(FileId src_file_id, FileId dest_file_id); |
| 82 | 83 |
| 83 // This produces the series 0, 1, 2..., starting at 0 when the underlying | 84 // This produces the series 0, 1, 2..., starting at 0 when the underlying |
| 84 // filesystem is first created, and maintaining state across | 85 // filesystem is first created, and maintaining state across |
| 85 // creation/destruction of FileSystemDirectoryDatabase objects. | 86 // creation/destruction of FileSystemDirectoryDatabase objects. |
| 86 bool GetNextInteger(int64* next); | 87 bool GetNextInteger(int64* next); |
| 87 | 88 |
| 88 static bool DestroyDatabase(const FilePath& path); | 89 static bool DestroyDatabase(const FilePath& path); |
| 89 | 90 |
| 90 private: | 91 private: |
| 91 bool Init(); | 92 enum RecoveryOption { |
| 93 DELETE_ON_CORRUPTION, |
| 94 FAIL_ON_CORRUPTION, |
| 95 }; |
| 96 |
| 97 bool Init(RecoveryOption recovery_option); |
| 92 void ReportInitStatus(const leveldb::Status& status); | 98 void ReportInitStatus(const leveldb::Status& status); |
| 93 bool StoreDefaultValues(); | 99 bool StoreDefaultValues(); |
| 94 bool GetLastFileId(FileId* file_id); | 100 bool GetLastFileId(FileId* file_id); |
| 95 bool VerifyIsDirectory(FileId file_id); | 101 bool VerifyIsDirectory(FileId file_id); |
| 96 bool AddFileInfoHelper( | 102 bool AddFileInfoHelper( |
| 97 const FileInfo& info, FileId file_id, leveldb::WriteBatch* batch); | 103 const FileInfo& info, FileId file_id, leveldb::WriteBatch* batch); |
| 98 bool RemoveFileInfoHelper(FileId file_id, leveldb::WriteBatch* batch); | 104 bool RemoveFileInfoHelper(FileId file_id, leveldb::WriteBatch* batch); |
| 99 void HandleError(const tracked_objects::Location& from_here, | 105 void HandleError(const tracked_objects::Location& from_here, |
| 100 const leveldb::Status& status); | 106 const leveldb::Status& status); |
| 101 | 107 |
| 102 std::string path_; | 108 FilePath filesystem_data_directory_; |
| 103 scoped_ptr<leveldb::DB> db_; | 109 scoped_ptr<leveldb::DB> db_; |
| 104 base::Time last_reported_time_; | 110 base::Time last_reported_time_; |
| 105 DISALLOW_COPY_AND_ASSIGN(FileSystemDirectoryDatabase); | 111 DISALLOW_COPY_AND_ASSIGN(FileSystemDirectoryDatabase); |
| 106 }; | 112 }; |
| 107 | 113 |
| 108 } // namespace fileapi | 114 } // namespace fileapi |
| 109 | 115 |
| 110 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_DIRECTORY_DATABASE_H_ | 116 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_DIRECTORY_DATABASE_H_ |
| OLD | NEW |