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