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 <stdint.h> |
| 9 |
8 #include <string> | 10 #include <string> |
9 | 11 |
10 #include "base/basictypes.h" | 12 #include "base/macros.h" |
11 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
12 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
13 #include "content/browser/indexed_db/indexed_db_backing_store.h" | 15 #include "content/browser/indexed_db/indexed_db_backing_store.h" |
14 #include "content/browser/indexed_db/indexed_db_database.h" | 16 #include "content/browser/indexed_db/indexed_db_database.h" |
15 #include "content/common/indexed_db/indexed_db_key_range.h" | 17 #include "content/common/indexed_db/indexed_db_key_range.h" |
16 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h" | 18 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBTypes.h" |
17 | 19 |
18 namespace content { | 20 namespace content { |
19 | 21 |
20 class IndexedDBTransaction; | 22 class IndexedDBTransaction; |
21 | 23 |
22 class CONTENT_EXPORT IndexedDBCursor | 24 class CONTENT_EXPORT IndexedDBCursor |
23 : NON_EXPORTED_BASE(public base::RefCounted<IndexedDBCursor>) { | 25 : NON_EXPORTED_BASE(public base::RefCounted<IndexedDBCursor>) { |
24 public: | 26 public: |
25 IndexedDBCursor(scoped_ptr<IndexedDBBackingStore::Cursor> cursor, | 27 IndexedDBCursor(scoped_ptr<IndexedDBBackingStore::Cursor> cursor, |
26 indexed_db::CursorType cursor_type, | 28 indexed_db::CursorType cursor_type, |
27 blink::WebIDBTaskType task_type, | 29 blink::WebIDBTaskType task_type, |
28 IndexedDBTransaction* transaction); | 30 IndexedDBTransaction* transaction); |
29 | 31 |
30 void Advance(uint32 count, scoped_refptr<IndexedDBCallbacks> callbacks); | 32 void Advance(uint32_t count, scoped_refptr<IndexedDBCallbacks> callbacks); |
31 void Continue(scoped_ptr<IndexedDBKey> key, | 33 void Continue(scoped_ptr<IndexedDBKey> key, |
32 scoped_ptr<IndexedDBKey> primary_key, | 34 scoped_ptr<IndexedDBKey> primary_key, |
33 scoped_refptr<IndexedDBCallbacks> callbacks); | 35 scoped_refptr<IndexedDBCallbacks> callbacks); |
34 void PrefetchContinue(int number_to_fetch, | 36 void PrefetchContinue(int number_to_fetch, |
35 scoped_refptr<IndexedDBCallbacks> callbacks); | 37 scoped_refptr<IndexedDBCallbacks> callbacks); |
36 leveldb::Status PrefetchReset(int used_prefetches, int unused_prefetches); | 38 leveldb::Status PrefetchReset(int used_prefetches, int unused_prefetches); |
37 | 39 |
38 const IndexedDBKey& key() const { return cursor_->key(); } | 40 const IndexedDBKey& key() const { return cursor_->key(); } |
39 const IndexedDBKey& primary_key() const { return cursor_->primary_key(); } | 41 const IndexedDBKey& primary_key() const { return cursor_->primary_key(); } |
40 IndexedDBValue* Value() const { | 42 IndexedDBValue* Value() const { |
41 return (cursor_type_ == indexed_db::CURSOR_KEY_ONLY) ? NULL | 43 return (cursor_type_ == indexed_db::CURSOR_KEY_ONLY) ? NULL |
42 : cursor_->value(); | 44 : cursor_->value(); |
43 } | 45 } |
44 void Close(); | 46 void Close(); |
45 | 47 |
46 void CursorIterationOperation(scoped_ptr<IndexedDBKey> key, | 48 void CursorIterationOperation(scoped_ptr<IndexedDBKey> key, |
47 scoped_ptr<IndexedDBKey> primary_key, | 49 scoped_ptr<IndexedDBKey> primary_key, |
48 scoped_refptr<IndexedDBCallbacks> callbacks, | 50 scoped_refptr<IndexedDBCallbacks> callbacks, |
49 IndexedDBTransaction* transaction); | 51 IndexedDBTransaction* transaction); |
50 void CursorAdvanceOperation(uint32 count, | 52 void CursorAdvanceOperation(uint32_t count, |
51 scoped_refptr<IndexedDBCallbacks> callbacks, | 53 scoped_refptr<IndexedDBCallbacks> callbacks, |
52 IndexedDBTransaction* transaction); | 54 IndexedDBTransaction* transaction); |
53 void CursorPrefetchIterationOperation( | 55 void CursorPrefetchIterationOperation( |
54 int number_to_fetch, | 56 int number_to_fetch, |
55 scoped_refptr<IndexedDBCallbacks> callbacks, | 57 scoped_refptr<IndexedDBCallbacks> callbacks, |
56 IndexedDBTransaction* transaction); | 58 IndexedDBTransaction* transaction); |
57 | 59 |
58 private: | 60 private: |
59 friend class base::RefCounted<IndexedDBCursor>; | 61 friend class base::RefCounted<IndexedDBCursor>; |
60 | 62 |
61 ~IndexedDBCursor(); | 63 ~IndexedDBCursor(); |
62 | 64 |
63 blink::WebIDBTaskType task_type_; | 65 blink::WebIDBTaskType task_type_; |
64 indexed_db::CursorType cursor_type_; | 66 indexed_db::CursorType cursor_type_; |
65 const scoped_refptr<IndexedDBTransaction> transaction_; | 67 const scoped_refptr<IndexedDBTransaction> transaction_; |
66 | 68 |
67 // Must be destroyed before transaction_. | 69 // Must be destroyed before transaction_. |
68 scoped_ptr<IndexedDBBackingStore::Cursor> cursor_; | 70 scoped_ptr<IndexedDBBackingStore::Cursor> cursor_; |
69 // Must be destroyed before transaction_. | 71 // Must be destroyed before transaction_. |
70 scoped_ptr<IndexedDBBackingStore::Cursor> saved_cursor_; | 72 scoped_ptr<IndexedDBBackingStore::Cursor> saved_cursor_; |
71 | 73 |
72 bool closed_; | 74 bool closed_; |
73 | 75 |
74 DISALLOW_COPY_AND_ASSIGN(IndexedDBCursor); | 76 DISALLOW_COPY_AND_ASSIGN(IndexedDBCursor); |
75 }; | 77 }; |
76 | 78 |
77 } // namespace content | 79 } // namespace content |
78 | 80 |
79 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CURSOR_H_ | 81 #endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CURSOR_H_ |
OLD | NEW |