| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_RENDERER_INDEXED_DB_RENDERER_WEBIDBCURSOR_IMPL_H_ | |
| 6 #define CONTENT_RENDERER_INDEXED_DB_RENDERER_WEBIDBCURSOR_IMPL_H_ | |
| 7 | |
| 8 #include <deque> | |
| 9 | |
| 10 #include "base/basictypes.h" | |
| 11 #include "content/common/indexed_db/indexed_db_key.h" | |
| 12 #include "content/public/common/serialized_script_value.h" | |
| 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCallbacks.h" | |
| 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCursor.h" | |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKey.h" | |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebSerialize
dScriptValue.h" | |
| 17 | |
| 18 class RendererWebIDBCursorImpl : public WebKit::WebIDBCursor { | |
| 19 public: | |
| 20 RendererWebIDBCursorImpl(int32 idb_cursor_id); | |
| 21 virtual ~RendererWebIDBCursorImpl(); | |
| 22 | |
| 23 virtual unsigned short direction() const; | |
| 24 virtual WebKit::WebIDBKey key() const; | |
| 25 virtual WebKit::WebIDBKey primaryKey() const; | |
| 26 virtual WebKit::WebSerializedScriptValue value() const; | |
| 27 virtual void update(const WebKit::WebSerializedScriptValue& value, | |
| 28 WebKit::WebIDBCallbacks* callback, | |
| 29 WebKit::WebExceptionCode& ec); | |
| 30 virtual void continueFunction(const WebKit::WebIDBKey& key, | |
| 31 WebKit::WebIDBCallbacks* callback, | |
| 32 WebKit::WebExceptionCode& ec); | |
| 33 virtual void deleteFunction(WebKit::WebIDBCallbacks* callback, | |
| 34 WebKit::WebExceptionCode& ec); | |
| 35 virtual void postSuccessHandlerCallback(); | |
| 36 | |
| 37 void SetKeyAndValue(const IndexedDBKey& key, const IndexedDBKey& primary_key, | |
| 38 const content::SerializedScriptValue& value); | |
| 39 void SetPrefetchData( | |
| 40 const std::vector<IndexedDBKey>& keys, | |
| 41 const std::vector<IndexedDBKey>& primary_keys, | |
| 42 const std::vector<content::SerializedScriptValue>& values); | |
| 43 | |
| 44 void CachedContinue(WebKit::WebIDBCallbacks* callbacks); | |
| 45 void ResetPrefetchCache(); | |
| 46 | |
| 47 private: | |
| 48 int32 idb_cursor_id_; | |
| 49 IndexedDBKey key_; | |
| 50 IndexedDBKey primary_key_; | |
| 51 content::SerializedScriptValue value_; | |
| 52 | |
| 53 // Prefetch cache. | |
| 54 std::deque<IndexedDBKey> prefetch_keys_; | |
| 55 std::deque<IndexedDBKey> prefetch_primary_keys_; | |
| 56 std::deque<content::SerializedScriptValue> prefetch_values_; | |
| 57 | |
| 58 // Number of continue calls that would qualify for a pre-fetch. | |
| 59 int continue_count_; | |
| 60 | |
| 61 // Number of items used from the last prefetch. | |
| 62 int used_prefetches_; | |
| 63 | |
| 64 // Number of onsuccess handlers we are waiting for. | |
| 65 int pending_onsuccess_callbacks_; | |
| 66 | |
| 67 // Number of items to request in next prefetch. | |
| 68 int prefetch_amount_; | |
| 69 | |
| 70 enum { kPrefetchContinueThreshold = 2 }; | |
| 71 enum { kMinPrefetchAmount = 5 }; | |
| 72 enum { kMaxPrefetchAmount = 100 }; | |
| 73 }; | |
| 74 | |
| 75 #endif // CONTENT_RENDERER_INDEXED_DB_RENDERER_WEBIDBCURSOR_IMPL_H_ | |
| OLD | NEW |