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_H_ | 5 #ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CURSOR_H_ |
6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CURSOR_H_ | 6 #define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CURSOR_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_database.h" | 14 #include "content/browser/indexed_db/indexed_db_database.h" |
15 #include "content/common/indexed_db/indexed_db_key_range.h" | 15 #include "content/common/indexed_db/indexed_db_key_range.h" |
16 | 16 |
17 namespace content { | 17 namespace content { |
18 | 18 |
19 class IndexedDBDatabase; | |
20 class IndexedDBTransaction; | 19 class IndexedDBTransaction; |
21 | 20 |
22 class CONTENT_EXPORT IndexedDBCursor | 21 class CONTENT_EXPORT IndexedDBCursor |
23 : NON_EXPORTED_BASE(public base::RefCounted<IndexedDBCursor>) { | 22 : NON_EXPORTED_BASE(public base::RefCounted<IndexedDBCursor>) { |
24 public: | 23 public: |
25 static scoped_refptr<IndexedDBCursor> Create( | 24 static scoped_refptr<IndexedDBCursor> Create( |
26 scoped_ptr<IndexedDBBackingStore::Cursor> cursor, | 25 scoped_ptr<IndexedDBBackingStore::Cursor> cursor, |
27 indexed_db::CursorType cursor_type, | 26 indexed_db::CursorType cursor_type, |
28 IndexedDBTransaction* transaction) { | 27 IndexedDBTransaction* transaction) { |
29 return make_scoped_refptr( | 28 return make_scoped_refptr( |
30 new IndexedDBCursor(cursor.Pass(), | 29 new IndexedDBCursor(cursor.Pass(), |
31 cursor_type, | 30 cursor_type, |
32 IndexedDBDatabase::NORMAL_TASK, | 31 IndexedDBDatabase::NORMAL_TASK, |
33 transaction)); | 32 transaction)); |
34 } | 33 } |
35 static scoped_refptr<IndexedDBCursor> Create( | 34 static scoped_refptr<IndexedDBCursor> Create( |
36 scoped_ptr<IndexedDBBackingStore::Cursor> cursor, | 35 scoped_ptr<IndexedDBBackingStore::Cursor> cursor, |
37 indexed_db::CursorType cursor_type, | 36 indexed_db::CursorType cursor_type, |
38 IndexedDBDatabase::TaskType task_type, | 37 IndexedDBDatabase::TaskType task_type, |
39 IndexedDBTransaction* transaction) { | 38 IndexedDBTransaction* transaction) { |
40 return make_scoped_refptr(new IndexedDBCursor( | 39 return make_scoped_refptr(new IndexedDBCursor( |
41 cursor.Pass(), cursor_type, task_type, transaction)); | 40 cursor.Pass(), cursor_type, task_type, transaction)); |
42 } | 41 } |
43 | 42 |
44 // IndexedDBCursor | 43 // IndexedDBCursor |
45 void Advance(uint32 count, | 44 void Advance(uint32 count, scoped_refptr<IndexedDBCallbacks> callbacks); |
46 scoped_refptr<IndexedDBCallbacksWrapper> callbacks); | |
47 void ContinueFunction(scoped_ptr<IndexedDBKey> key, | 45 void ContinueFunction(scoped_ptr<IndexedDBKey> key, |
48 scoped_refptr<IndexedDBCallbacksWrapper> callbacks); | 46 scoped_refptr<IndexedDBCallbacks> callbacks); |
49 void PrefetchContinue(int number_to_fetch, | 47 void PrefetchContinue(int number_to_fetch, |
50 scoped_refptr<IndexedDBCallbacksWrapper> callbacks); | 48 scoped_refptr<IndexedDBCallbacks> callbacks); |
51 void PrefetchReset(int used_prefetches, int unused_prefetches); | 49 void PrefetchReset(int used_prefetches, int unused_prefetches); |
52 | 50 |
53 const IndexedDBKey& key() const { return cursor_->key(); } | 51 const IndexedDBKey& key() const { return cursor_->key(); } |
54 const IndexedDBKey& primary_key() const { return cursor_->primary_key(); } | 52 const IndexedDBKey& primary_key() const { return cursor_->primary_key(); } |
55 std::vector<char>* Value() const { | 53 std::vector<char>* Value() const { |
56 return (cursor_type_ == indexed_db::CURSOR_KEY_ONLY) ? NULL | 54 return (cursor_type_ == indexed_db::CURSOR_KEY_ONLY) ? NULL |
57 : cursor_->Value(); | 55 : cursor_->Value(); |
58 } | 56 } |
59 void Close(); | 57 void Close(); |
60 | 58 |
(...skipping 18 matching lines...) Expand all Loading... |
79 scoped_ptr<IndexedDBBackingStore::Cursor> cursor_; | 77 scoped_ptr<IndexedDBBackingStore::Cursor> cursor_; |
80 // Must be destroyed before transaction_. | 78 // Must be destroyed before transaction_. |
81 scoped_ptr<IndexedDBBackingStore::Cursor> saved_cursor_; | 79 scoped_ptr<IndexedDBBackingStore::Cursor> saved_cursor_; |
82 | 80 |
83 bool closed_; | 81 bool closed_; |
84 }; | 82 }; |
85 | 83 |
86 } // namespace content | 84 } // namespace content |
87 | 85 |
88 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CURSOR_H_ | 86 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CURSOR_H_ |
OLD | NEW |