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

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: Fixed buffer overflow (woops) in original test Created 6 years, 8 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/strings/string_piece.h" 15 #include "base/strings/string_piece.h"
16 #include "base/timer/timer.h" 16 #include "base/timer/timer.h"
17 #include "content/browser/indexed_db/indexed_db.h" 17 #include "content/browser/indexed_db/indexed_db.h"
18 #include "content/browser/indexed_db/indexed_db_metadata.h" 18 #include "content/browser/indexed_db/indexed_db_metadata.h"
19 #include "content/browser/indexed_db/leveldb/leveldb_iterator.h" 19 #include "content/browser/indexed_db/leveldb/leveldb_iterator.h"
20 #include "content/browser/indexed_db/leveldb/leveldb_transaction.h" 20 #include "content/browser/indexed_db/leveldb/leveldb_transaction.h"
21 #include "content/common/content_export.h" 21 #include "content/common/content_export.h"
22 #include "content/common/indexed_db/indexed_db_key.h" 22 #include "content/common/indexed_db/indexed_db_key.h"
23 #include "content/common/indexed_db/indexed_db_key_path.h" 23 #include "content/common/indexed_db/indexed_db_key_path.h"
24 #include "content/common/indexed_db/indexed_db_key_range.h" 24 #include "content/common/indexed_db/indexed_db_key_range.h"
25 #include "third_party/leveldatabase/src/include/leveldb/status.h" 25 #include "third_party/leveldatabase/src/include/leveldb/status.h"
26 #include "url/gurl.h" 26 #include "url/gurl.h"
27 27
28 namespace content { 28 namespace content {
29 29
30 class IndexedDBDatabaseError;
30 class LevelDBComparator; 31 class LevelDBComparator;
31 class LevelDBDatabase; 32 class LevelDBDatabase;
32 struct IndexedDBValue; 33 struct IndexedDBValue;
33 34
34 class LevelDBFactory { 35 class LevelDBFactory {
35 public: 36 public:
36 virtual ~LevelDBFactory() {} 37 virtual ~LevelDBFactory() {}
37 virtual leveldb::Status OpenLevelDB(const base::FilePath& file_name, 38 virtual leveldb::Status OpenLevelDB(const base::FilePath& file_name,
38 const LevelDBComparator* comparator, 39 const LevelDBComparator* comparator,
39 scoped_ptr<LevelDBDatabase>* db, 40 scoped_ptr<LevelDBDatabase>* db,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 blink::WebIDBDataLoss* data_loss, 72 blink::WebIDBDataLoss* data_loss,
72 std::string* data_loss_message, 73 std::string* data_loss_message,
73 bool* disk_full, 74 bool* disk_full,
74 LevelDBFactory* factory); 75 LevelDBFactory* factory);
75 static scoped_refptr<IndexedDBBackingStore> OpenInMemory( 76 static scoped_refptr<IndexedDBBackingStore> OpenInMemory(
76 const GURL& origin_url); 77 const GURL& origin_url);
77 static scoped_refptr<IndexedDBBackingStore> OpenInMemory( 78 static scoped_refptr<IndexedDBBackingStore> OpenInMemory(
78 const GURL& origin_url, 79 const GURL& origin_url,
79 LevelDBFactory* factory); 80 LevelDBFactory* factory);
80 81
82 virtual void Compact();
81 virtual std::vector<base::string16> GetDatabaseNames(); 83 virtual std::vector<base::string16> GetDatabaseNames();
82 virtual leveldb::Status GetIDBDatabaseMetaData( 84 virtual leveldb::Status GetIDBDatabaseMetaData(
83 const base::string16& name, 85 const base::string16& name,
84 IndexedDBDatabaseMetadata* metadata, 86 IndexedDBDatabaseMetadata* metadata,
85 bool* success) WARN_UNUSED_RESULT; 87 bool* success) WARN_UNUSED_RESULT;
86 virtual leveldb::Status CreateIDBDatabaseMetaData( 88 virtual leveldb::Status CreateIDBDatabaseMetaData(
87 const base::string16& name, 89 const base::string16& name,
88 const base::string16& version, 90 const base::string16& version,
89 int64 int_version, 91 int64 int_version,
90 int64* row_id); 92 int64* row_id);
91 virtual bool UpdateIDBDatabaseIntVersion( 93 virtual bool UpdateIDBDatabaseIntVersion(
92 IndexedDBBackingStore::Transaction* transaction, 94 IndexedDBBackingStore::Transaction* transaction,
93 int64 row_id, 95 int64 row_id,
94 int64 int_version); 96 int64 int_version);
95 virtual leveldb::Status DeleteDatabase(const base::string16& name); 97 virtual leveldb::Status DeleteDatabase(const base::string16& name);
96 98
99 // Assumes caller has already closed the backing store.
100 static leveldb::Status DestroyBackingStore(const base::FilePath& path_base,
101 const GURL& origin_url);
102 static bool RecordCorruptionInfo(const base::FilePath& path_base,
103 const GURL& origin_url,
104 const std::string& message);
97 leveldb::Status GetObjectStores( 105 leveldb::Status GetObjectStores(
98 int64 database_id, 106 int64 database_id,
99 IndexedDBDatabaseMetadata::ObjectStoreMap* map) WARN_UNUSED_RESULT; 107 IndexedDBDatabaseMetadata::ObjectStoreMap* map) WARN_UNUSED_RESULT;
100 virtual leveldb::Status CreateObjectStore( 108 virtual leveldb::Status CreateObjectStore(
101 IndexedDBBackingStore::Transaction* transaction, 109 IndexedDBBackingStore::Transaction* transaction,
102 int64 database_id, 110 int64 database_id,
103 int64 object_store_id, 111 int64 object_store_id,
104 const base::string16& name, 112 const base::string16& name,
105 const IndexedDBKeyPath& key_path, 113 const IndexedDBKeyPath& key_path,
106 bool auto_increment); 114 bool auto_increment);
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 scoped_ptr<LevelDBDatabase> db, 326 scoped_ptr<LevelDBDatabase> db,
319 scoped_ptr<LevelDBComparator> comparator); 327 scoped_ptr<LevelDBComparator> comparator);
320 virtual ~IndexedDBBackingStore(); 328 virtual ~IndexedDBBackingStore();
321 friend class base::RefCounted<IndexedDBBackingStore>; 329 friend class base::RefCounted<IndexedDBBackingStore>;
322 330
323 private: 331 private:
324 static scoped_refptr<IndexedDBBackingStore> Create( 332 static scoped_refptr<IndexedDBBackingStore> Create(
325 const GURL& origin_url, 333 const GURL& origin_url,
326 scoped_ptr<LevelDBDatabase> db, 334 scoped_ptr<LevelDBDatabase> db,
327 scoped_ptr<LevelDBComparator> comparator); 335 scoped_ptr<LevelDBComparator> comparator);
336 static bool ReadCorruptionInfo(const base::FilePath& path_base,
337 const GURL& origin_url,
338 std::string& message);
328 339
329 leveldb::Status FindKeyInIndex( 340 leveldb::Status FindKeyInIndex(
330 IndexedDBBackingStore::Transaction* transaction, 341 IndexedDBBackingStore::Transaction* transaction,
331 int64 database_id, 342 int64 database_id,
332 int64 object_store_id, 343 int64 object_store_id,
333 int64 index_id, 344 int64 index_id,
334 const IndexedDBKey& key, 345 const IndexedDBKey& key,
335 std::string* found_encoded_primary_key, 346 std::string* found_encoded_primary_key,
336 bool* found); 347 bool* found);
337 leveldb::Status GetIndexes(int64 database_id, 348 leveldb::Status GetIndexes(int64 database_id,
(...skipping 12 matching lines...) Expand all
350 const std::string origin_identifier_; 361 const std::string origin_identifier_;
351 362
352 scoped_ptr<LevelDBDatabase> db_; 363 scoped_ptr<LevelDBDatabase> db_;
353 scoped_ptr<LevelDBComparator> comparator_; 364 scoped_ptr<LevelDBComparator> comparator_;
354 base::OneShotTimer<IndexedDBBackingStore> close_timer_; 365 base::OneShotTimer<IndexedDBBackingStore> close_timer_;
355 }; 366 };
356 367
357 } // namespace content 368 } // namespace content
358 369
359 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ 370 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698