OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CURSOR_IMPL_H_ |
| 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CURSOR_IMPL_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/basictypes.h" |
| 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "content/browser/indexed_db/indexed_db_backing_store.h" |
| 14 #include "content/browser/indexed_db/indexed_db_cursor.h" |
| 15 #include "content/browser/indexed_db/indexed_db_database.h" |
| 16 #include "content/common/indexed_db/indexed_db_key_range.h" |
| 17 |
| 18 namespace content { |
| 19 |
| 20 class IndexedDBDatabaseImpl; |
| 21 class IndexedDBTransaction; |
| 22 |
| 23 class IndexedDBCursorImpl : public IndexedDBCursor { |
| 24 public: |
| 25 static scoped_refptr<IndexedDBCursorImpl> Create( |
| 26 scoped_ptr<IndexedDBBackingStore::Cursor> cursor, |
| 27 indexed_db::CursorType cursor_type, |
| 28 IndexedDBTransaction* transaction, |
| 29 int64 object_store_id) { |
| 30 return make_scoped_refptr( |
| 31 new IndexedDBCursorImpl(cursor.Pass(), |
| 32 cursor_type, |
| 33 IndexedDBDatabase::NORMAL_TASK, |
| 34 transaction, |
| 35 object_store_id)); |
| 36 } |
| 37 static scoped_refptr<IndexedDBCursorImpl> Create( |
| 38 scoped_ptr<IndexedDBBackingStore::Cursor> cursor, |
| 39 indexed_db::CursorType cursor_type, |
| 40 IndexedDBDatabase::TaskType task_type, |
| 41 IndexedDBTransaction* transaction, |
| 42 int64 object_store_id) { |
| 43 return make_scoped_refptr(new IndexedDBCursorImpl( |
| 44 cursor.Pass(), cursor_type, task_type, transaction, object_store_id)); |
| 45 } |
| 46 |
| 47 // IndexedDBCursor |
| 48 virtual void Advance(unsigned long, |
| 49 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) |
| 50 OVERRIDE; |
| 51 virtual void ContinueFunction( |
| 52 scoped_ptr<IndexedDBKey> key, |
| 53 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) OVERRIDE; |
| 54 virtual void DeleteFunction( |
| 55 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) OVERRIDE; |
| 56 virtual void PrefetchContinue( |
| 57 int number_to_fetch, |
| 58 scoped_refptr<IndexedDBCallbacksWrapper> callbacks) OVERRIDE; |
| 59 virtual void PrefetchReset(int used_prefetches, int unused_prefetches) |
| 60 OVERRIDE; |
| 61 virtual void PostSuccessHandlerCallback() OVERRIDE {} |
| 62 |
| 63 const IndexedDBKey& key() const { return cursor_->key(); } |
| 64 const IndexedDBKey& primary_key() const { return cursor_->primary_key(); } |
| 65 std::vector<char>* Value() const { |
| 66 return (cursor_type_ == indexed_db::CURSOR_KEY_ONLY) ? NULL |
| 67 : cursor_->Value(); |
| 68 } |
| 69 void Close(); |
| 70 |
| 71 private: |
| 72 IndexedDBCursorImpl(scoped_ptr<IndexedDBBackingStore::Cursor> cursor, |
| 73 indexed_db::CursorType cursor_type, |
| 74 IndexedDBDatabase::TaskType task_type, |
| 75 IndexedDBTransaction* transaction, |
| 76 int64 object_store_id); |
| 77 virtual ~IndexedDBCursorImpl(); |
| 78 |
| 79 class CursorIterationOperation; |
| 80 class CursorAdvanceOperation; |
| 81 class CursorPrefetchIterationOperation; |
| 82 |
| 83 IndexedDBDatabase::TaskType task_type_; |
| 84 indexed_db::CursorType cursor_type_; |
| 85 const scoped_refptr<IndexedDBTransaction> transaction_; |
| 86 const int64 object_store_id_; |
| 87 |
| 88 // Must be destroyed before transaction_. |
| 89 scoped_ptr<IndexedDBBackingStore::Cursor> cursor_; |
| 90 // Must be destroyed before transaction_. |
| 91 scoped_ptr<IndexedDBBackingStore::Cursor> saved_cursor_; |
| 92 |
| 93 bool closed_; |
| 94 }; |
| 95 |
| 96 } // namespace content |
| 97 |
| 98 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CURSOR_IMPL_H_ |
OLD | NEW |