#ifndef CONTENT_CHILD_INDEXED_DB_PROXY_WEBIDBCURSOR_IMPL_H_
#define CONTENT_CHILD_INDEXED_DB_PROXY_WEBIDBCURSOR_IMPL_H_
#include <deque>
#include <vector>
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/gtest_prod_util.h"
#include "base/memory/ref_counted.h"
#include "content/common/content_export.h"
#include "content/common/indexed_db/indexed_db_key.h"
#include "third_party/WebKit/public/platform/WebData.h"
#include "third_party/WebKit/public/platform/WebIDBCallbacks.h"
#include "third_party/WebKit/public/platform/WebIDBCursor.h"
#include "third_party/WebKit/public/platform/WebIDBKey.h"
namespace content {
class ThreadSafeSender;
class CONTENT_EXPORT WebIDBCursorImpl
: NON_EXPORTED_BASE(public blink::WebIDBCursor) {
public:
WebIDBCursorImpl(int32 ipc_cursor_id,
int64 transaction_id,
ThreadSafeSender* thread_safe_sender);
virtual ~WebIDBCursorImpl();
virtual void advance(unsigned long count, blink::WebIDBCallbacks* callback);
virtual void continueFunction(const blink::WebIDBKey& key,
blink::WebIDBCallbacks* callback);
virtual void continueFunction(const blink::WebIDBKey& key,
const blink::WebIDBKey& primary_key,
blink::WebIDBCallbacks* callback);
virtual void postSuccessHandlerCallback();
void SetPrefetchData(const std::vector<IndexedDBKey>& keys,
const std::vector<IndexedDBKey>& primary_keys,
const std::vector<blink::WebData>& values);
void CachedAdvance(unsigned long count, blink::WebIDBCallbacks* callbacks);
void CachedContinue(blink::WebIDBCallbacks* callbacks);
virtual void ResetPrefetchCache();
int64 transaction_id() const { return transaction_id_; }
private:
FRIEND_TEST_ALL_PREFIXES(IndexedDBDispatcherTest, CursorReset);
FRIEND_TEST_ALL_PREFIXES(IndexedDBDispatcherTest, CursorTransactionId);
FRIEND_TEST_ALL_PREFIXES(WebIDBCursorImplTest, AdvancePrefetchTest);
FRIEND_TEST_ALL_PREFIXES(WebIDBCursorImplTest, PrefetchReset);
FRIEND_TEST_ALL_PREFIXES(WebIDBCursorImplTest, PrefetchTest);
int32 ipc_cursor_id_;
int64 transaction_id_;
std::deque<IndexedDBKey> prefetch_keys_;
std::deque<IndexedDBKey> prefetch_primary_keys_;
std::deque<blink::WebData> prefetch_values_;
int continue_count_;
int used_prefetches_;
int pending_onsuccess_callbacks_;
int prefetch_amount_;
scoped_refptr<ThreadSafeSender> thread_safe_sender_;
enum { kInvalidCursorId = -1 };
enum { kPrefetchContinueThreshold = 2 };
enum { kMinPrefetchAmount = 5 };
enum { kMaxPrefetchAmount = 100 };
};
}
#endif