Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Side by Side Diff: webkit/fileapi/file_system_origin_database.h

Issue 9663021: Add database recovery for FileSystemOriginDatabase (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: build fix Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 16 matching lines...) Expand all
27 std::string origin; 27 std::string origin;
28 FilePath path; 28 FilePath path;
29 29
30 OriginRecord(); 30 OriginRecord();
31 OriginRecord(const std::string& origin, const FilePath& path); 31 OriginRecord(const std::string& origin, const FilePath& path);
32 ~OriginRecord(); 32 ~OriginRecord();
33 }; 33 };
34 34
35 // Only one instance of FileSystemOriginDatabase should exist for a given path 35 // Only one instance of FileSystemOriginDatabase should exist for a given path
36 // at a given time. 36 // at a given time.
37 explicit FileSystemOriginDatabase(const FilePath& path); 37 explicit FileSystemOriginDatabase(const FilePath& file_system_directory);
38 ~FileSystemOriginDatabase(); 38 ~FileSystemOriginDatabase();
39 39
40 bool HasOriginPath(const std::string& origin); 40 bool HasOriginPath(const std::string& origin);
41 41
42 // This will produce a unique path and add it to its database, if it's not 42 // This will produce a unique path and add it to its database, if it's not
43 // already present. 43 // already present.
44 bool GetPathForOrigin(const std::string& origin, FilePath* directory); 44 bool GetPathForOrigin(const std::string& origin, FilePath* directory);
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 enum RecoveryOption {
56 REPAIR_ON_CORRUPTION,
57 DELETE_ON_CORRUPTION,
58 FAIL_ON_CORRUPTION,
59 };
60
61 bool Init(RecoveryOption recovery_option);
62 bool RepairDB(const std::string& db_path);
kinuko 2012/03/23 04:01:33 LevelDB's method name is RepairDB but in this clas
tzik 2012/03/23 07:09:00 Done.
56 void HandleError(const tracked_objects::Location& from_here, 63 void HandleError(const tracked_objects::Location& from_here,
57 leveldb::Status status); 64 leveldb::Status status);
58 bool GetLastPathNumber(int* number); 65 bool GetLastPathNumber(int* number);
59 66
60 std::string path_; 67 FilePath file_system_directory_;
61 scoped_ptr<leveldb::DB> db_; 68 scoped_ptr<leveldb::DB> db_;
62 DISALLOW_COPY_AND_ASSIGN(FileSystemOriginDatabase); 69 DISALLOW_COPY_AND_ASSIGN(FileSystemOriginDatabase);
63 }; 70 };
64 71
65 } // namespace fileapi 72 } // namespace fileapi
66 73
67 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_ORIGIN_DATABASE_H_ 74 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_ORIGIN_DATABASE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698