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

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

Issue 9663021: Add database recovery for FileSystemOriginDatabase (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: add tests 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_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
11 #include "base/file_path.h" 11 #include "base/file_path.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/time.h" 13 #include "base/time.h"
14 #include "third_party/leveldatabase/src/include/leveldb/db.h" 14 #include "third_party/leveldatabase/src/include/leveldb/db.h"
15 15
16 namespace tracked_objects { 16 namespace tracked_objects {
17 class Location; 17 class Location;
18 } 18 }
19 19
20 namespace leveldb { 20 namespace leveldb {
21 class Status;
21 class WriteBatch; 22 class WriteBatch;
22 } 23 }
23 24
24 namespace fileapi { 25 namespace fileapi {
25 26
26 // This class WILL NOT protect you against producing directory loops, giving an 27 // This class WILL NOT protect you against producing directory loops, giving an
27 // empty directory a backing data file, giving two files the same backing file, 28 // empty directory a backing data file, giving two files the same backing file,
28 // or pointing to a nonexistent backing file. It does no file IO other than 29 // or pointing to a nonexistent backing file. It does no file IO other than
29 // that involved with talking to its underlying database. It does not create or 30 // that involved with talking to its underlying database. It does not create or
30 // in any way touch real files; it only creates path entries in its database. 31 // in any way touch real files; it only creates path entries in its database.
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 bool OverwritingMoveFile(FileId src_file_id, FileId dest_file_id); 81 bool OverwritingMoveFile(FileId src_file_id, FileId dest_file_id);
81 82
82 // This produces the series 0, 1, 2..., starting at 0 when the underlying 83 // This produces the series 0, 1, 2..., starting at 0 when the underlying
83 // filesystem is first created, and maintaining state across 84 // filesystem is first created, and maintaining state across
84 // creation/destruction of FileSystemDirectoryDatabase objects. 85 // creation/destruction of FileSystemDirectoryDatabase objects.
85 bool GetNextInteger(int64* next); 86 bool GetNextInteger(int64* next);
86 87
87 static bool DestroyDatabase(const FilePath& path); 88 static bool DestroyDatabase(const FilePath& path);
88 89
89 private: 90 private:
90 bool Init(); 91 bool Init(bool cleanup_if_corrupted);
92 bool CheckIfDatabaseCorrupted(const leveldb::Status& status) const;
91 bool StoreDefaultValues(); 93 bool StoreDefaultValues();
92 bool GetLastFileId(FileId* file_id); 94 bool GetLastFileId(FileId* file_id);
93 bool VerifyIsDirectory(FileId file_id); 95 bool VerifyIsDirectory(FileId file_id);
94 bool AddFileInfoHelper( 96 bool AddFileInfoHelper(
95 const FileInfo& info, FileId file_id, leveldb::WriteBatch* batch); 97 const FileInfo& info, FileId file_id, leveldb::WriteBatch* batch);
96 bool RemoveFileInfoHelper(FileId file_id, leveldb::WriteBatch* batch); 98 bool RemoveFileInfoHelper(FileId file_id, leveldb::WriteBatch* batch);
97 void HandleError(const tracked_objects::Location& from_here, 99 void HandleError(const tracked_objects::Location& from_here,
98 leveldb::Status status); 100 leveldb::Status status);
99 101
100 std::string path_; 102 std::string path_;
101 scoped_ptr<leveldb::DB> db_; 103 scoped_ptr<leveldb::DB> db_;
102 }; 104 };
103 105
104 } // namespace fileapi 106 } // namespace fileapi
105 107
106 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_DIRECTORY_DATABASE_H_ 108 #endif // WEBKIT_FILEAPI_FILE_SYSTEM_DIRECTORY_DATABASE_H_
OLDNEW
« no previous file with comments | « no previous file | webkit/fileapi/file_system_directory_database.cc » ('j') | webkit/fileapi/file_system_directory_database.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698