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