OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
48 | 48 |
49 FileId parent_id; | 49 FileId parent_id; |
50 FilePath data_path; | 50 FilePath data_path; |
51 FilePath::StringType name; | 51 FilePath::StringType name; |
52 // This modification time is valid only for directories, not files, as | 52 // This modification time is valid only for directories, not files, as |
53 // FileWriter will get the files out of sync. | 53 // FileWriter will get the files out of sync. |
54 // For files, look at the modification time of the underlying data_path. | 54 // For files, look at the modification time of the underlying data_path. |
55 base::Time modification_time; | 55 base::Time modification_time; |
56 }; | 56 }; |
57 | 57 |
58 explicit FileSystemDirectoryDatabase(const FilePath& path); | 58 explicit FileSystemDirectoryDatabase(const FilePath& path); |
kinuko
2012/03/26 05:25:09
path -> sandbox_directory (or whatever we actually
tzik
2012/03/26 08:04:56
Done.
| |
59 ~FileSystemDirectoryDatabase(); | 59 ~FileSystemDirectoryDatabase(); |
60 | 60 |
61 bool GetChildWithName( | 61 bool GetChildWithName( |
62 FileId parent_id, const FilePath::StringType& name, FileId* child_id); | 62 FileId parent_id, const FilePath::StringType& name, FileId* child_id); |
63 bool GetFileWithPath(const FilePath& path, FileId* file_id); | 63 bool GetFileWithPath(const FilePath& path, FileId* file_id); |
64 // ListChildren will succeed, returning 0 children, if parent_id doesn't | 64 // ListChildren will succeed, returning 0 children, if parent_id doesn't |
65 // exist. | 65 // exist. |
66 bool ListChildren(FileId parent_id, std::vector<FileId>* children); | 66 bool ListChildren(FileId parent_id, std::vector<FileId>* children); |
67 bool GetFileInfo(FileId file_id, FileInfo* info); | 67 bool GetFileInfo(FileId file_id, FileInfo* info); |
68 bool AddFileInfo(const FileInfo& info, FileId* file_id); | 68 bool AddFileInfo(const FileInfo& info, FileId* file_id); |
(...skipping 11 matching lines...) Expand all Loading... | |
80 bool OverwritingMoveFile(FileId src_file_id, FileId dest_file_id); | 80 bool OverwritingMoveFile(FileId src_file_id, FileId dest_file_id); |
81 | 81 |
82 // This produces the series 0, 1, 2..., starting at 0 when the underlying | 82 // This produces the series 0, 1, 2..., starting at 0 when the underlying |
83 // filesystem is first created, and maintaining state across | 83 // filesystem is first created, and maintaining state across |
84 // creation/destruction of FileSystemDirectoryDatabase objects. | 84 // creation/destruction of FileSystemDirectoryDatabase objects. |
85 bool GetNextInteger(int64* next); | 85 bool GetNextInteger(int64* next); |
86 | 86 |
87 static bool DestroyDatabase(const FilePath& path); | 87 static bool DestroyDatabase(const FilePath& path); |
88 | 88 |
89 private: | 89 private: |
90 bool Init(); | 90 enum RecoveryOption { |
91 DELETE_ON_CORRUPTION, | |
92 FAIL_ON_CORRUPTION, | |
93 }; | |
94 | |
95 bool Init(RecoveryOption recovery_option); | |
91 bool StoreDefaultValues(); | 96 bool StoreDefaultValues(); |
92 bool GetLastFileId(FileId* file_id); | 97 bool GetLastFileId(FileId* file_id); |
93 bool VerifyIsDirectory(FileId file_id); | 98 bool VerifyIsDirectory(FileId file_id); |
94 bool AddFileInfoHelper( | 99 bool AddFileInfoHelper( |
95 const FileInfo& info, FileId file_id, leveldb::WriteBatch* batch); | 100 const FileInfo& info, FileId file_id, leveldb::WriteBatch* batch); |
96 bool RemoveFileInfoHelper(FileId file_id, leveldb::WriteBatch* batch); | 101 bool RemoveFileInfoHelper(FileId file_id, leveldb::WriteBatch* batch); |
97 void HandleError(const tracked_objects::Location& from_here, | 102 void HandleError(const tracked_objects::Location& from_here, |
98 leveldb::Status status); | 103 leveldb::Status status); |
99 | 104 |
100 std::string path_; | 105 FilePath sandbox_directory_; |
kinuko
2012/03/26 05:25:09
This sounds slightly unclear to me. (What's 'sandb
tzik
2012/03/26 08:04:56
Done.
| |
101 scoped_ptr<leveldb::DB> db_; | 106 scoped_ptr<leveldb::DB> db_; |
102 }; | 107 }; |
103 | 108 |
104 } // namespace fileapi | 109 } // namespace fileapi |
105 | 110 |
106 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_DIRECTORY_DATABASE_H_ | 111 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_DIRECTORY_DATABASE_H_ |
OLD | NEW |