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