1868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Copyright (c) 2013 The Chromium Authors. All rights reserved. 2868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be 3868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// found in the LICENSE file. 4868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 5868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#ifndef CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CURSOR_H_ 6868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#define CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CURSOR_H_ 7868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 87dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch#include <string> 9868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 10868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/basictypes.h" 11868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/memory/ref_counted.h" 12868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/memory/scoped_ptr.h" 13868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "content/browser/indexed_db/indexed_db_backing_store.h" 14868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "content/browser/indexed_db/indexed_db_database.h" 15868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "content/common/indexed_db/indexed_db_key_range.h" 16868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 17868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)namespace content { 18868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 19868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)class IndexedDBTransaction; 20868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 21868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)class CONTENT_EXPORT IndexedDBCursor 22868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) : NON_EXPORTED_BASE(public base::RefCounted<IndexedDBCursor>) { 23868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) public: 247dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch IndexedDBCursor(scoped_ptr<IndexedDBBackingStore::Cursor> cursor, 257dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch indexed_db::CursorType cursor_type, 267dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch IndexedDBDatabase::TaskType task_type, 277dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch IndexedDBTransaction* transaction); 28868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 29eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch void Advance(uint32 count, scoped_refptr<IndexedDBCallbacks> callbacks); 307dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch void Continue(scoped_ptr<IndexedDBKey> key, 31f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) scoped_ptr<IndexedDBKey> primary_key, 327dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch scoped_refptr<IndexedDBCallbacks> callbacks); 33868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) void PrefetchContinue(int number_to_fetch, 34eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch scoped_refptr<IndexedDBCallbacks> callbacks); 35868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) void PrefetchReset(int used_prefetches, int unused_prefetches); 36868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 37868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const IndexedDBKey& key() const { return cursor_->key(); } 38868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const IndexedDBKey& primary_key() const { return cursor_->primary_key(); } 397dbb3d5cf0c15f500944d211057644d6a2f37371Ben Murdoch std::string* Value() const { 40868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) return (cursor_type_ == indexed_db::CURSOR_KEY_ONLY) ? NULL 41a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles) : cursor_->value(); 42868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) } 43868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) void Close(); 44868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 453551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) void CursorIterationOperation(scoped_ptr<IndexedDBKey> key, 46f2477e01787aa58f445919b809d89e252beef54fTorne (Richard Coles) scoped_ptr<IndexedDBKey> primary_key, 473551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) scoped_refptr<IndexedDBCallbacks> callbacks, 483551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) IndexedDBTransaction* transaction); 493551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) void CursorAdvanceOperation(uint32 count, 503551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) scoped_refptr<IndexedDBCallbacks> callbacks, 513551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) IndexedDBTransaction* transaction); 523551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) void CursorPrefetchIterationOperation( 533551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) int number_to_fetch, 543551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) scoped_refptr<IndexedDBCallbacks> callbacks, 553551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) IndexedDBTransaction* transaction); 563551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) 57868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) private: 58868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) friend class base::RefCounted<IndexedDBCursor>; 59868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 60868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) ~IndexedDBCursor(); 61868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 62868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) IndexedDBDatabase::TaskType task_type_; 63868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) indexed_db::CursorType cursor_type_; 64868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) const scoped_refptr<IndexedDBTransaction> transaction_; 65868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 66868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Must be destroyed before transaction_. 67868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) scoped_ptr<IndexedDBBackingStore::Cursor> cursor_; 68868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) // Must be destroyed before transaction_. 69868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) scoped_ptr<IndexedDBBackingStore::Cursor> saved_cursor_; 70868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 71868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) bool closed_; 72868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}; 73868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 74868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)} // namespace content 75868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) 76868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#endif // CONTENT_BROWSER_INDEXED_DB_INDEXED_DB_CURSOR_H_ 77