| OLD | NEW |
| 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 #include "content/browser/indexed_db/indexed_db_backing_store.h" | 5 #include "content/browser/indexed_db/indexed_db_backing_store.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| (...skipping 3763 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3774 object_store_id, | 3774 object_store_id, |
| 3775 range, | 3775 range, |
| 3776 direction, | 3776 direction, |
| 3777 &cursor_options)) | 3777 &cursor_options)) |
| 3778 return scoped_ptr<IndexedDBBackingStore::Cursor>(); | 3778 return scoped_ptr<IndexedDBBackingStore::Cursor>(); |
| 3779 scoped_ptr<ObjectStoreCursorImpl> cursor(new ObjectStoreCursorImpl( | 3779 scoped_ptr<ObjectStoreCursorImpl> cursor(new ObjectStoreCursorImpl( |
| 3780 this, transaction, database_id, cursor_options)); | 3780 this, transaction, database_id, cursor_options)); |
| 3781 if (!cursor->FirstSeek(s)) | 3781 if (!cursor->FirstSeek(s)) |
| 3782 return scoped_ptr<IndexedDBBackingStore::Cursor>(); | 3782 return scoped_ptr<IndexedDBBackingStore::Cursor>(); |
| 3783 | 3783 |
| 3784 return cursor.PassAs<IndexedDBBackingStore::Cursor>(); | 3784 return cursor.Pass(); |
| 3785 } | 3785 } |
| 3786 | 3786 |
| 3787 scoped_ptr<IndexedDBBackingStore::Cursor> | 3787 scoped_ptr<IndexedDBBackingStore::Cursor> |
| 3788 IndexedDBBackingStore::OpenObjectStoreKeyCursor( | 3788 IndexedDBBackingStore::OpenObjectStoreKeyCursor( |
| 3789 IndexedDBBackingStore::Transaction* transaction, | 3789 IndexedDBBackingStore::Transaction* transaction, |
| 3790 int64 database_id, | 3790 int64 database_id, |
| 3791 int64 object_store_id, | 3791 int64 object_store_id, |
| 3792 const IndexedDBKeyRange& range, | 3792 const IndexedDBKeyRange& range, |
| 3793 blink::WebIDBCursorDirection direction, | 3793 blink::WebIDBCursorDirection direction, |
| 3794 leveldb::Status* s) { | 3794 leveldb::Status* s) { |
| 3795 IDB_TRACE("IndexedDBBackingStore::OpenObjectStoreKeyCursor"); | 3795 IDB_TRACE("IndexedDBBackingStore::OpenObjectStoreKeyCursor"); |
| 3796 *s = leveldb::Status::OK(); | 3796 *s = leveldb::Status::OK(); |
| 3797 LevelDBTransaction* leveldb_transaction = transaction->transaction(); | 3797 LevelDBTransaction* leveldb_transaction = transaction->transaction(); |
| 3798 IndexedDBBackingStore::Cursor::CursorOptions cursor_options; | 3798 IndexedDBBackingStore::Cursor::CursorOptions cursor_options; |
| 3799 if (!ObjectStoreCursorOptions(leveldb_transaction, | 3799 if (!ObjectStoreCursorOptions(leveldb_transaction, |
| 3800 database_id, | 3800 database_id, |
| 3801 object_store_id, | 3801 object_store_id, |
| 3802 range, | 3802 range, |
| 3803 direction, | 3803 direction, |
| 3804 &cursor_options)) | 3804 &cursor_options)) |
| 3805 return scoped_ptr<IndexedDBBackingStore::Cursor>(); | 3805 return scoped_ptr<IndexedDBBackingStore::Cursor>(); |
| 3806 scoped_ptr<ObjectStoreKeyCursorImpl> cursor(new ObjectStoreKeyCursorImpl( | 3806 scoped_ptr<ObjectStoreKeyCursorImpl> cursor(new ObjectStoreKeyCursorImpl( |
| 3807 this, transaction, database_id, cursor_options)); | 3807 this, transaction, database_id, cursor_options)); |
| 3808 if (!cursor->FirstSeek(s)) | 3808 if (!cursor->FirstSeek(s)) |
| 3809 return scoped_ptr<IndexedDBBackingStore::Cursor>(); | 3809 return scoped_ptr<IndexedDBBackingStore::Cursor>(); |
| 3810 | 3810 |
| 3811 return cursor.PassAs<IndexedDBBackingStore::Cursor>(); | 3811 return cursor.Pass(); |
| 3812 } | 3812 } |
| 3813 | 3813 |
| 3814 scoped_ptr<IndexedDBBackingStore::Cursor> | 3814 scoped_ptr<IndexedDBBackingStore::Cursor> |
| 3815 IndexedDBBackingStore::OpenIndexKeyCursor( | 3815 IndexedDBBackingStore::OpenIndexKeyCursor( |
| 3816 IndexedDBBackingStore::Transaction* transaction, | 3816 IndexedDBBackingStore::Transaction* transaction, |
| 3817 int64 database_id, | 3817 int64 database_id, |
| 3818 int64 object_store_id, | 3818 int64 object_store_id, |
| 3819 int64 index_id, | 3819 int64 index_id, |
| 3820 const IndexedDBKeyRange& range, | 3820 const IndexedDBKeyRange& range, |
| 3821 blink::WebIDBCursorDirection direction, | 3821 blink::WebIDBCursorDirection direction, |
| 3822 leveldb::Status* s) { | 3822 leveldb::Status* s) { |
| 3823 IDB_TRACE("IndexedDBBackingStore::OpenIndexKeyCursor"); | 3823 IDB_TRACE("IndexedDBBackingStore::OpenIndexKeyCursor"); |
| 3824 *s = leveldb::Status::OK(); | 3824 *s = leveldb::Status::OK(); |
| 3825 LevelDBTransaction* leveldb_transaction = transaction->transaction(); | 3825 LevelDBTransaction* leveldb_transaction = transaction->transaction(); |
| 3826 IndexedDBBackingStore::Cursor::CursorOptions cursor_options; | 3826 IndexedDBBackingStore::Cursor::CursorOptions cursor_options; |
| 3827 if (!IndexCursorOptions(leveldb_transaction, | 3827 if (!IndexCursorOptions(leveldb_transaction, |
| 3828 database_id, | 3828 database_id, |
| 3829 object_store_id, | 3829 object_store_id, |
| 3830 index_id, | 3830 index_id, |
| 3831 range, | 3831 range, |
| 3832 direction, | 3832 direction, |
| 3833 &cursor_options)) | 3833 &cursor_options)) |
| 3834 return scoped_ptr<IndexedDBBackingStore::Cursor>(); | 3834 return scoped_ptr<IndexedDBBackingStore::Cursor>(); |
| 3835 scoped_ptr<IndexKeyCursorImpl> cursor( | 3835 scoped_ptr<IndexKeyCursorImpl> cursor( |
| 3836 new IndexKeyCursorImpl(this, transaction, database_id, cursor_options)); | 3836 new IndexKeyCursorImpl(this, transaction, database_id, cursor_options)); |
| 3837 if (!cursor->FirstSeek(s)) | 3837 if (!cursor->FirstSeek(s)) |
| 3838 return scoped_ptr<IndexedDBBackingStore::Cursor>(); | 3838 return scoped_ptr<IndexedDBBackingStore::Cursor>(); |
| 3839 | 3839 |
| 3840 return cursor.PassAs<IndexedDBBackingStore::Cursor>(); | 3840 return cursor.Pass(); |
| 3841 } | 3841 } |
| 3842 | 3842 |
| 3843 scoped_ptr<IndexedDBBackingStore::Cursor> | 3843 scoped_ptr<IndexedDBBackingStore::Cursor> |
| 3844 IndexedDBBackingStore::OpenIndexCursor( | 3844 IndexedDBBackingStore::OpenIndexCursor( |
| 3845 IndexedDBBackingStore::Transaction* transaction, | 3845 IndexedDBBackingStore::Transaction* transaction, |
| 3846 int64 database_id, | 3846 int64 database_id, |
| 3847 int64 object_store_id, | 3847 int64 object_store_id, |
| 3848 int64 index_id, | 3848 int64 index_id, |
| 3849 const IndexedDBKeyRange& range, | 3849 const IndexedDBKeyRange& range, |
| 3850 blink::WebIDBCursorDirection direction, | 3850 blink::WebIDBCursorDirection direction, |
| 3851 leveldb::Status* s) { | 3851 leveldb::Status* s) { |
| 3852 IDB_TRACE("IndexedDBBackingStore::OpenIndexCursor"); | 3852 IDB_TRACE("IndexedDBBackingStore::OpenIndexCursor"); |
| 3853 LevelDBTransaction* leveldb_transaction = transaction->transaction(); | 3853 LevelDBTransaction* leveldb_transaction = transaction->transaction(); |
| 3854 IndexedDBBackingStore::Cursor::CursorOptions cursor_options; | 3854 IndexedDBBackingStore::Cursor::CursorOptions cursor_options; |
| 3855 if (!IndexCursorOptions(leveldb_transaction, | 3855 if (!IndexCursorOptions(leveldb_transaction, |
| 3856 database_id, | 3856 database_id, |
| 3857 object_store_id, | 3857 object_store_id, |
| 3858 index_id, | 3858 index_id, |
| 3859 range, | 3859 range, |
| 3860 direction, | 3860 direction, |
| 3861 &cursor_options)) | 3861 &cursor_options)) |
| 3862 return scoped_ptr<IndexedDBBackingStore::Cursor>(); | 3862 return scoped_ptr<IndexedDBBackingStore::Cursor>(); |
| 3863 scoped_ptr<IndexCursorImpl> cursor( | 3863 scoped_ptr<IndexCursorImpl> cursor( |
| 3864 new IndexCursorImpl(this, transaction, database_id, cursor_options)); | 3864 new IndexCursorImpl(this, transaction, database_id, cursor_options)); |
| 3865 if (!cursor->FirstSeek(s)) | 3865 if (!cursor->FirstSeek(s)) |
| 3866 return scoped_ptr<IndexedDBBackingStore::Cursor>(); | 3866 return scoped_ptr<IndexedDBBackingStore::Cursor>(); |
| 3867 | 3867 |
| 3868 return cursor.PassAs<IndexedDBBackingStore::Cursor>(); | 3868 return cursor.Pass(); |
| 3869 } | 3869 } |
| 3870 | 3870 |
| 3871 IndexedDBBackingStore::Transaction::Transaction( | 3871 IndexedDBBackingStore::Transaction::Transaction( |
| 3872 IndexedDBBackingStore* backing_store) | 3872 IndexedDBBackingStore* backing_store) |
| 3873 : backing_store_(backing_store), database_id_(-1) { | 3873 : backing_store_(backing_store), database_id_(-1) { |
| 3874 } | 3874 } |
| 3875 | 3875 |
| 3876 IndexedDBBackingStore::Transaction::~Transaction() { | 3876 IndexedDBBackingStore::Transaction::~Transaction() { |
| 3877 STLDeleteContainerPairSecondPointers( | 3877 STLDeleteContainerPairSecondPointers( |
| 3878 blob_change_map_.begin(), blob_change_map_.end()); | 3878 blob_change_map_.begin(), blob_change_map_.end()); |
| (...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4265 int64_t size, | 4265 int64_t size, |
| 4266 base::Time last_modified) | 4266 base::Time last_modified) |
| 4267 : is_file_(true), | 4267 : is_file_(true), |
| 4268 file_path_(file_path), | 4268 file_path_(file_path), |
| 4269 key_(key), | 4269 key_(key), |
| 4270 size_(size), | 4270 size_(size), |
| 4271 last_modified_(last_modified) { | 4271 last_modified_(last_modified) { |
| 4272 } | 4272 } |
| 4273 | 4273 |
| 4274 } // namespace content | 4274 } // namespace content |
| OLD | NEW |