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

Side by Side Diff: content/browser/indexed_db/indexed_db_backing_store.h

Issue 197333009: Handling LevelDB errors encountered after open. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Commented that DestroyBackingStore leaves non LevelDB files alone Created 6 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ 5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/timer/timer.h" 15 #include "base/timer/timer.h"
16 #include "content/browser/indexed_db/indexed_db.h" 16 #include "content/browser/indexed_db/indexed_db.h"
17 #include "content/browser/indexed_db/indexed_db_metadata.h" 17 #include "content/browser/indexed_db/indexed_db_metadata.h"
18 #include "content/browser/indexed_db/leveldb/leveldb_iterator.h" 18 #include "content/browser/indexed_db/leveldb/leveldb_iterator.h"
19 #include "content/browser/indexed_db/leveldb/leveldb_transaction.h" 19 #include "content/browser/indexed_db/leveldb/leveldb_transaction.h"
20 #include "content/common/content_export.h" 20 #include "content/common/content_export.h"
21 #include "content/common/indexed_db/indexed_db_key.h" 21 #include "content/common/indexed_db/indexed_db_key.h"
22 #include "content/common/indexed_db/indexed_db_key_path.h" 22 #include "content/common/indexed_db/indexed_db_key_path.h"
23 #include "content/common/indexed_db/indexed_db_key_range.h" 23 #include "content/common/indexed_db/indexed_db_key_range.h"
24 #include "third_party/leveldatabase/src/include/leveldb/status.h" 24 #include "third_party/leveldatabase/src/include/leveldb/status.h"
25 #include "url/gurl.h" 25 #include "url/gurl.h"
26 26
27 namespace content { 27 namespace content {
28 28
29 class IndexedDBDatabaseError;
29 class LevelDBComparator; 30 class LevelDBComparator;
30 class LevelDBDatabase; 31 class LevelDBDatabase;
31 struct IndexedDBValue; 32 struct IndexedDBValue;
32 33
33 class LevelDBFactory { 34 class LevelDBFactory {
34 public: 35 public:
35 virtual ~LevelDBFactory() {} 36 virtual ~LevelDBFactory() {}
36 virtual leveldb::Status OpenLevelDB(const base::FilePath& file_name, 37 virtual leveldb::Status OpenLevelDB(const base::FilePath& file_name,
37 const LevelDBComparator* comparator, 38 const LevelDBComparator* comparator,
38 scoped_ptr<LevelDBDatabase>* db, 39 scoped_ptr<LevelDBDatabase>* db,
(...skipping 24 matching lines...) Expand all
63 blink::WebIDBDataLoss* data_loss, 64 blink::WebIDBDataLoss* data_loss,
64 std::string* data_loss_message, 65 std::string* data_loss_message,
65 bool* disk_full, 66 bool* disk_full,
66 LevelDBFactory* factory); 67 LevelDBFactory* factory);
67 static scoped_refptr<IndexedDBBackingStore> OpenInMemory( 68 static scoped_refptr<IndexedDBBackingStore> OpenInMemory(
68 const GURL& origin_url); 69 const GURL& origin_url);
69 static scoped_refptr<IndexedDBBackingStore> OpenInMemory( 70 static scoped_refptr<IndexedDBBackingStore> OpenInMemory(
70 const GURL& origin_url, 71 const GURL& origin_url,
71 LevelDBFactory* factory); 72 LevelDBFactory* factory);
72 73
74 virtual void Compact();
73 virtual std::vector<base::string16> GetDatabaseNames(); 75 virtual std::vector<base::string16> GetDatabaseNames();
74 virtual leveldb::Status GetIDBDatabaseMetaData( 76 virtual leveldb::Status GetIDBDatabaseMetaData(
75 const base::string16& name, 77 const base::string16& name,
76 IndexedDBDatabaseMetadata* metadata, 78 IndexedDBDatabaseMetadata* metadata,
77 bool* success) WARN_UNUSED_RESULT; 79 bool* success) WARN_UNUSED_RESULT;
78 virtual leveldb::Status CreateIDBDatabaseMetaData( 80 virtual leveldb::Status CreateIDBDatabaseMetaData(
79 const base::string16& name, 81 const base::string16& name,
80 const base::string16& version, 82 const base::string16& version,
81 int64 int_version, 83 int64 int_version,
82 int64* row_id); 84 int64* row_id);
83 virtual bool UpdateIDBDatabaseIntVersion( 85 virtual bool UpdateIDBDatabaseIntVersion(
84 IndexedDBBackingStore::Transaction* transaction, 86 IndexedDBBackingStore::Transaction* transaction,
85 int64 row_id, 87 int64 row_id,
86 int64 int_version); 88 int64 int_version);
87 virtual leveldb::Status DeleteDatabase(const base::string16& name); 89 virtual leveldb::Status DeleteDatabase(const base::string16& name);
88 90
91 // Assumes caller has already closed the backing store.
92 static leveldb::Status DestroyBackingStore(const base::FilePath& path_base,
93 const GURL& origin_url);
94 static bool RecordCorruptionInfo(const base::FilePath& path_base,
95 const GURL& origin_url,
96 const std::string& message);
89 leveldb::Status GetObjectStores( 97 leveldb::Status GetObjectStores(
90 int64 database_id, 98 int64 database_id,
91 IndexedDBDatabaseMetadata::ObjectStoreMap* map) WARN_UNUSED_RESULT; 99 IndexedDBDatabaseMetadata::ObjectStoreMap* map) WARN_UNUSED_RESULT;
92 virtual leveldb::Status CreateObjectStore( 100 virtual leveldb::Status CreateObjectStore(
93 IndexedDBBackingStore::Transaction* transaction, 101 IndexedDBBackingStore::Transaction* transaction,
94 int64 database_id, 102 int64 database_id,
95 int64 object_store_id, 103 int64 object_store_id,
96 const base::string16& name, 104 const base::string16& name,
97 const IndexedDBKeyPath& key_path, 105 const IndexedDBKeyPath& key_path,
98 bool auto_increment); 106 bool auto_increment);
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 scoped_ptr<LevelDBDatabase> db, 318 scoped_ptr<LevelDBDatabase> db,
311 scoped_ptr<LevelDBComparator> comparator); 319 scoped_ptr<LevelDBComparator> comparator);
312 virtual ~IndexedDBBackingStore(); 320 virtual ~IndexedDBBackingStore();
313 friend class base::RefCounted<IndexedDBBackingStore>; 321 friend class base::RefCounted<IndexedDBBackingStore>;
314 322
315 private: 323 private:
316 static scoped_refptr<IndexedDBBackingStore> Create( 324 static scoped_refptr<IndexedDBBackingStore> Create(
317 const GURL& origin_url, 325 const GURL& origin_url,
318 scoped_ptr<LevelDBDatabase> db, 326 scoped_ptr<LevelDBDatabase> db,
319 scoped_ptr<LevelDBComparator> comparator); 327 scoped_ptr<LevelDBComparator> comparator);
328 static bool ReadCorruptionInfo(const base::FilePath& path_base,
329 const GURL& origin_url,
330 std::string& message);
320 331
321 leveldb::Status FindKeyInIndex( 332 leveldb::Status FindKeyInIndex(
322 IndexedDBBackingStore::Transaction* transaction, 333 IndexedDBBackingStore::Transaction* transaction,
323 int64 database_id, 334 int64 database_id,
324 int64 object_store_id, 335 int64 object_store_id,
325 int64 index_id, 336 int64 index_id,
326 const IndexedDBKey& key, 337 const IndexedDBKey& key,
327 std::string* found_encoded_primary_key, 338 std::string* found_encoded_primary_key,
328 bool* found); 339 bool* found);
329 leveldb::Status GetIndexes(int64 database_id, 340 leveldb::Status GetIndexes(int64 database_id,
(...skipping 12 matching lines...) Expand all
342 const std::string origin_identifier_; 353 const std::string origin_identifier_;
343 354
344 scoped_ptr<LevelDBDatabase> db_; 355 scoped_ptr<LevelDBDatabase> db_;
345 scoped_ptr<LevelDBComparator> comparator_; 356 scoped_ptr<LevelDBComparator> comparator_;
346 base::OneShotTimer<IndexedDBBackingStore> close_timer_; 357 base::OneShotTimer<IndexedDBBackingStore> close_timer_;
347 }; 358 };
348 359
349 } // namespace content 360 } // namespace content
350 361
351 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ 362 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698