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_ORIGIN_DATABASE_H_ | 5 #ifndef WEBKIT_FILEAPI_FILE_SYSTEM_ORIGIN_DATABASE_H_ |
6 #define WEBKIT_FILEAPI_FILE_SYSTEM_ORIGIN_DATABASE_H_ | 6 #define WEBKIT_FILEAPI_FILE_SYSTEM_ORIGIN_DATABASE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 // Also returns success if the origin is not found. | 46 // Also returns success if the origin is not found. |
47 bool RemovePathForOrigin(const std::string& origin); | 47 bool RemovePathForOrigin(const std::string& origin); |
48 | 48 |
49 bool ListAllOrigins(std::vector<OriginRecord>* origins); | 49 bool ListAllOrigins(std::vector<OriginRecord>* origins); |
50 | 50 |
51 // This will release all database resources in use; call it to save memory. | 51 // This will release all database resources in use; call it to save memory. |
52 void DropDatabase(); | 52 void DropDatabase(); |
53 | 53 |
54 private: | 54 private: |
55 bool Init(); | 55 bool Init(bool cleanup_if_corrupted); |
| 56 bool CheckIfDatabaseCorrupted(const leveldb::Status& status) const; |
56 void HandleError(const tracked_objects::Location& from_here, | 57 void HandleError(const tracked_objects::Location& from_here, |
57 leveldb::Status status); | 58 leveldb::Status status); |
58 bool GetLastPathNumber(int* number); | 59 bool GetLastPathNumber(int* number); |
59 | 60 |
60 std::string path_; | 61 std::string path_; |
61 scoped_ptr<leveldb::DB> db_; | 62 scoped_ptr<leveldb::DB> db_; |
62 DISALLOW_COPY_AND_ASSIGN(FileSystemOriginDatabase); | 63 DISALLOW_COPY_AND_ASSIGN(FileSystemOriginDatabase); |
63 }; | 64 }; |
64 | 65 |
65 } // namespace fileapi | 66 } // namespace fileapi |
66 | 67 |
67 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_ORIGIN_DATABASE_H_ | 68 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_ORIGIN_DATABASE_H_ |
OLD | NEW |