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

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

Issue 18023022: Blob support for IDB [Chromium] (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use ScopedVector and stl_utils for BlobDataHandles. Created 7 years 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) 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 <set>
8 #include <string> 9 #include <string>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/basictypes.h" 12 #include "base/basictypes.h"
12 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
13 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
15 #include "base/timer/timer.h" 16 #include "base/timer/timer.h"
16 #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_active_blob_registry.h"
19 #include "content/browser/indexed_db/indexed_db_blob_info.h"
20 #include "content/browser/indexed_db/indexed_db_leveldb_coding.h"
17 #include "content/browser/indexed_db/indexed_db_metadata.h" 21 #include "content/browser/indexed_db/indexed_db_metadata.h"
18 #include "content/browser/indexed_db/leveldb/leveldb_iterator.h" 22 #include "content/browser/indexed_db/leveldb/leveldb_iterator.h"
19 #include "content/browser/indexed_db/leveldb/leveldb_transaction.h" 23 #include "content/browser/indexed_db/leveldb/leveldb_transaction.h"
20 #include "content/common/content_export.h" 24 #include "content/common/content_export.h"
21 #include "content/common/indexed_db/indexed_db_key.h" 25 #include "content/common/indexed_db/indexed_db_key.h"
22 #include "content/common/indexed_db/indexed_db_key_path.h" 26 #include "content/common/indexed_db/indexed_db_key_path.h"
23 #include "content/common/indexed_db/indexed_db_key_range.h" 27 #include "content/common/indexed_db/indexed_db_key_range.h"
24 #include "third_party/leveldatabase/src/include/leveldb/status.h" 28 #include "third_party/leveldatabase/src/include/leveldb/status.h"
25 #include "url/gurl.h" 29 #include "url/gurl.h"
30 #include "webkit/browser/blob/blob_data_handle.h"
31
32 class GURL;
33
34 namespace base {
35 class TaskRunner;
36 }
37
38 namespace fileapi {
39 class FileWriterDelegate;
40 }
41
42 namespace net {
43 class URLRequestContext;
44 }
26 45
27 namespace content { 46 namespace content {
28 47
48 class IndexedDBFactory;
29 class LevelDBComparator; 49 class LevelDBComparator;
30 class LevelDBDatabase; 50 class LevelDBDatabase;
51 struct IndexedDBValue;
31 52
32 class LevelDBFactory { 53 class LevelDBFactory {
33 public: 54 public:
34 virtual ~LevelDBFactory() {} 55 virtual ~LevelDBFactory() {}
35 virtual leveldb::Status OpenLevelDB(const base::FilePath& file_name, 56 virtual leveldb::Status OpenLevelDB(const base::FilePath& file_name,
36 const LevelDBComparator* comparator, 57 const LevelDBComparator* comparator,
37 scoped_ptr<LevelDBDatabase>* db, 58 scoped_ptr<LevelDBDatabase>* db,
38 bool* is_disk_full) = 0; 59 bool* is_disk_full) = 0;
39 virtual bool DestroyLevelDB(const base::FilePath& file_name) = 0; 60 virtual bool DestroyLevelDB(const base::FilePath& file_name) = 0;
40 }; 61 };
41 62
42 class CONTENT_EXPORT IndexedDBBackingStore 63 class CONTENT_EXPORT IndexedDBBackingStore
43 : public base::RefCounted<IndexedDBBackingStore> { 64 : public base::RefCounted<IndexedDBBackingStore> {
44 public: 65 public:
45 class CONTENT_EXPORT Transaction; 66 class CONTENT_EXPORT Transaction;
46 67
47 const GURL& origin_url() const { return origin_url_; } 68 const GURL& origin_url() const { return origin_url_; }
48 base::OneShotTimer<IndexedDBBackingStore>* close_timer() { 69 base::OneShotTimer<IndexedDBBackingStore>* close_timer() {
49 return &close_timer_; 70 return &close_timer_;
50 } 71 }
72 IndexedDBFactory* factory() const { return indexed_db_factory_; }
51 73
52 static scoped_refptr<IndexedDBBackingStore> Open( 74 static scoped_refptr<IndexedDBBackingStore> Open(
75 IndexedDBFactory* indexed_db_factory,
53 const GURL& origin_url, 76 const GURL& origin_url,
54 const base::FilePath& path_base, 77 const base::FilePath& path_base,
55 blink::WebIDBDataLoss* data_loss, 78 net::URLRequestContext* request_context,
56 std::string* data_loss_message,
57 bool* disk_full);
58
59 static scoped_refptr<IndexedDBBackingStore> Open(
60 const GURL& origin_url,
61 const base::FilePath& path_base,
62 blink::WebIDBDataLoss* data_loss, 79 blink::WebIDBDataLoss* data_loss,
63 std::string* data_loss_message, 80 std::string* data_loss_message,
64 bool* disk_full, 81 bool* disk_full,
65 LevelDBFactory* factory); 82 base::TaskRunner* task_runner,
83 bool clean_journal);
84
85 static scoped_refptr<IndexedDBBackingStore> Open(
86 IndexedDBFactory* indexed_db_factory,
87 const GURL& origin_url,
88 const base::FilePath& path_base,
89 net::URLRequestContext* request_context,
90 blink::WebIDBDataLoss* data_loss,
91 std::string* data_loss_message,
92 bool* disk_full,
93 LevelDBFactory* factory,
94 base::TaskRunner* task_runner,
95 bool clean_journal);
66 static scoped_refptr<IndexedDBBackingStore> OpenInMemory( 96 static scoped_refptr<IndexedDBBackingStore> OpenInMemory(
67 const GURL& origin_url); 97 const GURL& origin_url, base::TaskRunner* task_runner);
68 static scoped_refptr<IndexedDBBackingStore> OpenInMemory( 98 static scoped_refptr<IndexedDBBackingStore> OpenInMemory(
69 const GURL& origin_url, 99 const GURL& origin_url,
70 LevelDBFactory* factory); 100 LevelDBFactory* factory,
101 base::TaskRunner* task_runner);
102
103 void GrantChildProcessPermissions(int child_process_id);
71 104
72 virtual std::vector<string16> GetDatabaseNames(); 105 virtual std::vector<string16> GetDatabaseNames();
73 virtual bool GetIDBDatabaseMetaData(const string16& name, 106 virtual bool GetIDBDatabaseMetaData(const string16& name,
74 IndexedDBDatabaseMetadata* metadata, 107 IndexedDBDatabaseMetadata* metadata,
75 bool* success) WARN_UNUSED_RESULT; 108 bool* success) WARN_UNUSED_RESULT;
76 virtual bool CreateIDBDatabaseMetaData(const string16& name, 109 virtual bool CreateIDBDatabaseMetaData(const string16& name,
77 const string16& version, 110 const string16& version,
78 int64 int_version, 111 int64 int_version,
79 int64* row_id); 112 int64* row_id);
80 virtual bool UpdateIDBDatabaseIntVersion( 113 virtual bool UpdateIDBDatabaseIntVersion(
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 } 145 }
113 146
114 private: 147 private:
115 // TODO(jsbell): Make it more clear that this is the *encoded* version of 148 // TODO(jsbell): Make it more clear that this is the *encoded* version of
116 // the key. 149 // the key.
117 std::string primary_key_; 150 std::string primary_key_;
118 int64 version_; 151 int64 version_;
119 DISALLOW_COPY_AND_ASSIGN(RecordIdentifier); 152 DISALLOW_COPY_AND_ASSIGN(RecordIdentifier);
120 }; 153 };
121 154
155 class BlobWriteCallback : public RefCounted<BlobWriteCallback> {
156 public:
157 virtual ~BlobWriteCallback() { }
158 virtual void didSucceed() = 0;
159 virtual void didFail() = 0;
160 };
161
122 virtual bool GetRecord(IndexedDBBackingStore::Transaction* transaction, 162 virtual bool GetRecord(IndexedDBBackingStore::Transaction* transaction,
123 int64 database_id, 163 int64 database_id,
124 int64 object_store_id, 164 int64 object_store_id,
125 const IndexedDBKey& key, 165 const IndexedDBKey& key,
126 std::string* record) WARN_UNUSED_RESULT; 166 IndexedDBValue* record) WARN_UNUSED_RESULT;
127 virtual bool PutRecord(IndexedDBBackingStore::Transaction* transaction, 167 virtual bool PutRecord(IndexedDBBackingStore::Transaction* transaction,
128 int64 database_id, 168 int64 database_id,
129 int64 object_store_id, 169 int64 object_store_id,
130 const IndexedDBKey& key, 170 const IndexedDBKey& key,
131 const std::string& value, 171 IndexedDBValue& value,
172 ScopedVector<webkit_blob::BlobDataHandle>* handles,
132 RecordIdentifier* record) WARN_UNUSED_RESULT; 173 RecordIdentifier* record) WARN_UNUSED_RESULT;
133 virtual bool ClearObjectStore(IndexedDBBackingStore::Transaction* transaction, 174 virtual bool ClearObjectStore(IndexedDBBackingStore::Transaction* transaction,
134 int64 database_id, 175 int64 database_id,
135 int64 object_store_id) WARN_UNUSED_RESULT; 176 int64 object_store_id) WARN_UNUSED_RESULT;
136 virtual bool DeleteRecord(IndexedDBBackingStore::Transaction* transaction, 177 virtual bool DeleteRecord(IndexedDBBackingStore::Transaction* transaction,
137 int64 database_id, 178 int64 database_id,
138 int64 object_store_id, 179 int64 object_store_id,
139 const RecordIdentifier& record) WARN_UNUSED_RESULT; 180 const RecordIdentifier& record) WARN_UNUSED_RESULT;
181 virtual bool DeleteRange(IndexedDBBackingStore::Transaction* transaction,
182 int64 database_id,
183 int64 object_store_id,
184 const IndexedDBKeyRange&) WARN_UNUSED_RESULT;
140 virtual bool GetKeyGeneratorCurrentNumber( 185 virtual bool GetKeyGeneratorCurrentNumber(
141 IndexedDBBackingStore::Transaction* transaction, 186 IndexedDBBackingStore::Transaction* transaction,
142 int64 database_id, 187 int64 database_id,
143 int64 object_store_id, 188 int64 object_store_id,
144 int64* current_number) WARN_UNUSED_RESULT; 189 int64* current_number) WARN_UNUSED_RESULT;
145 virtual bool MaybeUpdateKeyGeneratorCurrentNumber( 190 virtual bool MaybeUpdateKeyGeneratorCurrentNumber(
146 IndexedDBBackingStore::Transaction* transaction, 191 IndexedDBBackingStore::Transaction* transaction,
147 int64 database_id, 192 int64 database_id,
148 int64 object_store_id, 193 int64 object_store_id,
149 int64 new_state, 194 int64 new_state,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 const IndexedDBKey& key, 228 const IndexedDBKey& key,
184 scoped_ptr<IndexedDBKey>* primary_key) WARN_UNUSED_RESULT; 229 scoped_ptr<IndexedDBKey>* primary_key) WARN_UNUSED_RESULT;
185 virtual bool KeyExistsInIndex(IndexedDBBackingStore::Transaction* transaction, 230 virtual bool KeyExistsInIndex(IndexedDBBackingStore::Transaction* transaction,
186 int64 database_id, 231 int64 database_id,
187 int64 object_store_id, 232 int64 object_store_id,
188 int64 index_id, 233 int64 index_id,
189 const IndexedDBKey& key, 234 const IndexedDBKey& key,
190 scoped_ptr<IndexedDBKey>* found_primary_key, 235 scoped_ptr<IndexedDBKey>* found_primary_key,
191 bool* exists) WARN_UNUSED_RESULT; 236 bool* exists) WARN_UNUSED_RESULT;
192 237
238 // Public for IndexedDBActiveBlobRegistry::ReleaseBlobRef.
239 void ReportBlobUnused(int64 database_id, int64 blob_key);
240
241 base::FilePath GetIDBBlobFileName(int64 database_id, int64 key);
242
193 class Cursor { 243 class Cursor {
194 public: 244 public:
195 virtual ~Cursor(); 245 virtual ~Cursor();
196 246
197 enum IteratorState { 247 enum IteratorState {
198 READY = 0, 248 READY = 0,
199 SEEK 249 SEEK
200 }; 250 };
201 251
202 struct CursorOptions { 252 struct CursorOptions {
(...skipping 16 matching lines...) Expand all
219 return Continue(key, NULL, state); 269 return Continue(key, NULL, state);
220 } 270 }
221 bool Continue(const IndexedDBKey* key, 271 bool Continue(const IndexedDBKey* key,
222 const IndexedDBKey* primary_key, 272 const IndexedDBKey* primary_key,
223 IteratorState state); 273 IteratorState state);
224 bool Advance(uint32 count); 274 bool Advance(uint32 count);
225 bool FirstSeek(); 275 bool FirstSeek();
226 276
227 virtual Cursor* Clone() = 0; 277 virtual Cursor* Clone() = 0;
228 virtual const IndexedDBKey& primary_key() const; 278 virtual const IndexedDBKey& primary_key() const;
229 virtual std::string* Value() = 0; 279 virtual IndexedDBValue* Value() = 0;
230 virtual const RecordIdentifier& record_identifier() const; 280 virtual const RecordIdentifier& record_identifier() const;
231 virtual bool LoadCurrentRow() = 0; 281 virtual bool LoadCurrentRow() = 0;
232 282
233 protected: 283 protected:
234 Cursor(LevelDBTransaction* transaction, 284 Cursor(scoped_refptr<IndexedDBBackingStore> backing_store,
285 LevelDBTransaction* transaction,
286 int64 database_id,
235 const CursorOptions& cursor_options); 287 const CursorOptions& cursor_options);
236 explicit Cursor(const IndexedDBBackingStore::Cursor* other); 288 explicit Cursor(const IndexedDBBackingStore::Cursor* other);
237 289
238 virtual std::string EncodeKey(const IndexedDBKey& key) = 0; 290 virtual std::string EncodeKey(const IndexedDBKey& key) = 0;
239 virtual std::string EncodeKey(const IndexedDBKey& key, 291 virtual std::string EncodeKey(const IndexedDBKey& key,
240 const IndexedDBKey& primary_key) = 0; 292 const IndexedDBKey& primary_key) = 0;
241 293
242 bool IsPastBounds() const; 294 bool IsPastBounds() const;
243 bool HaveEnteredRange() const; 295 bool HaveEnteredRange() const;
244 296
297 scoped_refptr<IndexedDBBackingStore> backing_store_;
245 LevelDBTransaction* transaction_; 298 LevelDBTransaction* transaction_;
299 int64 database_id_;
246 const CursorOptions cursor_options_; 300 const CursorOptions cursor_options_;
247 scoped_ptr<LevelDBIterator> iterator_; 301 scoped_ptr<LevelDBIterator> iterator_;
248 scoped_ptr<IndexedDBKey> current_key_; 302 scoped_ptr<IndexedDBKey> current_key_;
249 IndexedDBBackingStore::RecordIdentifier record_identifier_; 303 IndexedDBBackingStore::RecordIdentifier record_identifier_;
250 }; 304 };
251 305
252 virtual scoped_ptr<Cursor> OpenObjectStoreKeyCursor( 306 virtual scoped_ptr<Cursor> OpenObjectStoreKeyCursor(
253 IndexedDBBackingStore::Transaction* transaction, 307 IndexedDBBackingStore::Transaction* transaction,
254 int64 database_id, 308 int64 database_id,
255 int64 object_store_id, 309 int64 object_store_id,
(...skipping 18 matching lines...) Expand all
274 int64 object_store_id, 328 int64 object_store_id,
275 int64 index_id, 329 int64 index_id,
276 const IndexedDBKeyRange& key_range, 330 const IndexedDBKeyRange& key_range,
277 indexed_db::CursorDirection); 331 indexed_db::CursorDirection);
278 332
279 class Transaction { 333 class Transaction {
280 public: 334 public:
281 explicit Transaction(IndexedDBBackingStore* backing_store); 335 explicit Transaction(IndexedDBBackingStore* backing_store);
282 ~Transaction(); 336 ~Transaction();
283 void Begin(); 337 void Begin();
284 bool Commit(); 338 // The callback will be called eventually on success or failure, or
339 // immediately if phase one is complete due to lack of any blobs to write.
340 bool CommitPhaseOne(scoped_refptr<BlobWriteCallback>);
341 bool CommitPhaseTwo();
285 void Rollback(); 342 void Rollback();
286 void Reset() { 343 void Reset() {
287 backing_store_ = NULL; 344 backing_store_ = NULL;
288 transaction_ = NULL; 345 transaction_ = NULL;
289 } 346 }
347 void PutBlobInfo(int64 database_id, int64 object_store_id,
348 const std::string& key, std::vector<IndexedDBBlobInfo>*,
349 ScopedVector<webkit_blob::BlobDataHandle>* handles);
290 350
291 LevelDBTransaction* transaction() { return transaction_; } 351 LevelDBTransaction* transaction() { return transaction_; }
292 352
353 // DatabaseId, BlobKey
354 typedef std::pair<int64_t, int64_t> BlobJournalEntryType;
355 typedef std::vector<BlobJournalEntryType> BlobJournalType;
356 // This holds a BlobEntryKey and the encoded IndexedDBBlobInfo vector stored
357 // under that key.
358 typedef std::vector< std::pair<BlobEntryKey, std::string> >
359 BlobEntryKeyValuePairVec;
360
361 class WriteDescriptor {
362 public:
363 WriteDescriptor(const GURL& url, int64_t key);
364 WriteDescriptor(const base::FilePath& path, int64_t key);
365
366 bool is_file() const { return is_file_; }
367 const GURL& url() const {
368 DCHECK(!is_file_);
369 return url_;
370 }
371 const base::FilePath& file_path() const {
372 DCHECK(is_file_);
373 return file_path_;
374 }
375 int64_t key() const { return key_; }
376 private:
377 bool is_file_;
378 GURL url_;
379 base::FilePath file_path_;
380 int64_t key_;
381 };
382
383 class ChainedBlobWriter : public base::RefCounted<ChainedBlobWriter> {
384 public:
385
386 virtual void set_delegate(
387 scoped_ptr<fileapi::FileWriterDelegate> delegate) = 0;
388
389 virtual void ReportWriteCompletion(
390 bool succeeded, int64 bytes_written) = 0;
391
392 virtual void Abort() = 0;
393
394 protected:
395 virtual ~ChainedBlobWriter() {}
396 friend class base::RefCounted<ChainedBlobWriter>;
397 };
398 class ChainedBlobWriterImpl;
399
400 typedef std::vector<WriteDescriptor> WriteDescriptorVec;
401
293 private: 402 private:
403 class BlobChangeRecord {
404 public:
405 BlobChangeRecord() {}
406 void set_key(const std::string& key) {
407 key_ = key;
408 }
409 const std::string& key() const {
410 return key_;
411 }
412 void set_object_store_id(int64 object_store_id) {
413 object_store_id_ = object_store_id;
414 }
415 int64 object_store_id() const {
416 return object_store_id_;
417 }
418 void SetBlobInfo(std::vector<IndexedDBBlobInfo>* blob_info);
419 std::vector<IndexedDBBlobInfo>& mutable_blob_info() {
420 return blob_info_;
421 }
422 void SetHandles(ScopedVector<webkit_blob::BlobDataHandle>* handles);
423
424 private:
425 std::string key_;
426 int64 object_store_id_;
427 std::vector<IndexedDBBlobInfo> blob_info_;
428 ScopedVector<webkit_blob::BlobDataHandle> handles_;
429 };
430 class BlobWriteCallbackWrapper;
431 typedef std::map<std::string, BlobChangeRecord*> BlobChangeMap;
432
433 // These return true on success, false on failure.
434 bool HandleBlobPreTransaction(BlobEntryKeyValuePairVec* new_blob_entries,
435 WriteDescriptorVec* new_files_to_write);
436 bool CollectBlobFilesToRemove();
437 // The callback will be called eventually on success or failure.
438 void WriteNewBlobs(BlobEntryKeyValuePairVec& new_blob_entries,
439 WriteDescriptorVec& new_files_to_write,
440 scoped_refptr<BlobWriteCallback> callback);
441 bool SortBlobsToRemove();
442
294 IndexedDBBackingStore* backing_store_; 443 IndexedDBBackingStore* backing_store_;
295 scoped_refptr<LevelDBTransaction> transaction_; 444 scoped_refptr<LevelDBTransaction> transaction_;
445 BlobChangeMap blob_change_map_;
446 int64 database_id_;
447 BlobJournalType blobs_to_remove_;
448 scoped_refptr<ChainedBlobWriter> chained_blob_writer_;
296 }; 449 };
297 450
451 LevelDBComparator* comparator() { return comparator_.get(); }
452 IndexedDBActiveBlobRegistry* active_blob_registry() {
453 return &active_blob_registry_;
454 }
455
456 base::TaskRunner* task_runner() { return task_runner_; }
457
298 protected: 458 protected:
299 IndexedDBBackingStore(const GURL& origin_url, 459 IndexedDBBackingStore(IndexedDBFactory* indexed_db_factory,
460 const GURL& origin_url,
461 const base::FilePath& blob_path,
462 net::URLRequestContext* request_context,
300 scoped_ptr<LevelDBDatabase> db, 463 scoped_ptr<LevelDBDatabase> db,
301 scoped_ptr<LevelDBComparator> comparator); 464 scoped_ptr<LevelDBComparator> comparator,
465 base::TaskRunner* task_runner);
302 virtual ~IndexedDBBackingStore(); 466 virtual ~IndexedDBBackingStore();
303 friend class base::RefCounted<IndexedDBBackingStore>; 467 friend class base::RefCounted<IndexedDBBackingStore>;
304 468
469 bool SetUpMetadata();
470
471 virtual bool WriteBlobFile(
472 int64 database_id, const Transaction::WriteDescriptor& descriptor,
473 Transaction::ChainedBlobWriter* chained_blob_writer);
474 virtual bool RemoveBlobFile(int64 database_id, int64 key);
475 virtual void StartJournalCleaningTimer();
476 void CleanPrimaryJournalIgnoreReturn();
477
305 private: 478 private:
306 static scoped_refptr<IndexedDBBackingStore> Create( 479 static scoped_refptr<IndexedDBBackingStore> Create(
480 IndexedDBFactory* indexed_db_factory,
307 const GURL& origin_url, 481 const GURL& origin_url,
482 const base::FilePath& blob_path,
483 net::URLRequestContext* request_context,
308 scoped_ptr<LevelDBDatabase> db, 484 scoped_ptr<LevelDBDatabase> db,
309 scoped_ptr<LevelDBComparator> comparator); 485 scoped_ptr<LevelDBComparator> comparator,
486 base::TaskRunner* task_runner);
310 487
311 bool FindKeyInIndex(IndexedDBBackingStore::Transaction* transaction, 488 bool FindKeyInIndex(IndexedDBBackingStore::Transaction* transaction,
312 int64 database_id, 489 int64 database_id,
313 int64 object_store_id, 490 int64 object_store_id,
314 int64 index_id, 491 int64 index_id,
315 const IndexedDBKey& key, 492 const IndexedDBKey& key,
316 std::string* found_encoded_primary_key, 493 std::string* found_encoded_primary_key,
317 bool* found); 494 bool* found);
318 bool GetIndexes(int64 database_id, 495 bool GetIndexes(int64 database_id,
319 int64 object_store_id, 496 int64 object_store_id,
320 IndexedDBObjectStoreMetadata::IndexMap* map) 497 IndexedDBObjectStoreMetadata::IndexMap* map)
321 WARN_UNUSED_RESULT; 498 WARN_UNUSED_RESULT;
499 bool RemoveBlobDirectory(int64 database_id);
500 bool CleanUpBlobJournal(const std::string& level_db_key);
322 501
502 IndexedDBFactory* indexed_db_factory_;
323 const GURL origin_url_; 503 const GURL origin_url_;
324 504
325 // The origin identifier is a key prefix unique to the origin used in the 505 // The origin identifier is a key prefix unique to the origin used in the
326 // leveldb backing store to partition data by origin. It is a normalized 506 // leveldb backing store to partition data by origin. It is a normalized
327 // version of the origin URL with a versioning suffix appended, e.g. 507 // version of the origin URL with a versioning suffix appended, e.g.
328 // "http_localhost_81@1" Since only one origin is stored per backing store 508 // "http_localhost_81@1" Since only one origin is stored per backing store
329 // this is redundant but necessary for backwards compatibility; the suffix 509 // this is redundant but necessary for backwards compatibility; the suffix
330 // provides for future flexibility. 510 // provides for future flexibility.
331 const std::string origin_identifier_; 511 const std::string origin_identifier_;
332 512
513 base::FilePath blob_path_;
514 net::URLRequestContext* request_context_;
515 base::TaskRunner* task_runner_;
516 std::set<int> child_process_ids_granted_;
517 base::OneShotTimer<IndexedDBBackingStore> journal_cleaning_timer_;
518
333 scoped_ptr<LevelDBDatabase> db_; 519 scoped_ptr<LevelDBDatabase> db_;
334 scoped_ptr<LevelDBComparator> comparator_; 520 scoped_ptr<LevelDBComparator> comparator_;
521 // The active_blob_registry_ will hold a refcount to this backing store
522 // whenever any live blobs are registered with it.
523 IndexedDBActiveBlobRegistry active_blob_registry_;
335 base::OneShotTimer<IndexedDBBackingStore> close_timer_; 524 base::OneShotTimer<IndexedDBBackingStore> close_timer_;
336 }; 525 };
337 526
338 } // namespace content 527 } // namespace content
339 528
340 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_ 529 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_BACKING_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698