OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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_RENDERER_RENDERER_WEBIDBCURSOR_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_RENDERER_WEBIDBCURSOR_IMPL_H_ |
6 #define CONTENT_RENDERER_RENDERER_WEBIDBCURSOR_IMPL_H_ | 6 #define CONTENT_RENDERER_RENDERER_WEBIDBCURSOR_IMPL_H_ |
7 | 7 |
| 8 #include <deque> |
| 9 |
8 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
9 #include "content/common/indexed_db_key.h" | 11 #include "content/common/indexed_db_key.h" |
10 #include "content/public/common/serialized_script_value.h" | 12 #include "content/public/common/serialized_script_value.h" |
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCallbacks.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCallbacks.h" |
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCursor.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCursor.h" |
13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKey.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKey.h" |
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSerializedScriptVa
lue.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebSerializedScriptVa
lue.h" |
15 | 17 |
16 class RendererWebIDBCursorImpl : public WebKit::WebIDBCursor { | 18 class RendererWebIDBCursorImpl : public WebKit::WebIDBCursor { |
17 public: | 19 public: |
18 RendererWebIDBCursorImpl(int32 idb_cursor_id); | 20 RendererWebIDBCursorImpl(int32 idb_cursor_id); |
19 virtual ~RendererWebIDBCursorImpl(); | 21 virtual ~RendererWebIDBCursorImpl(); |
20 | 22 |
21 virtual unsigned short direction() const; | 23 virtual unsigned short direction() const; |
22 virtual WebKit::WebIDBKey key() const; | 24 virtual WebKit::WebIDBKey key() const; |
23 virtual WebKit::WebIDBKey primaryKey() const; | 25 virtual WebKit::WebIDBKey primaryKey() const; |
24 virtual WebKit::WebSerializedScriptValue value() const; | 26 virtual WebKit::WebSerializedScriptValue value() const; |
25 virtual void update(const WebKit::WebSerializedScriptValue& value, | 27 virtual void update(const WebKit::WebSerializedScriptValue& value, |
26 WebKit::WebIDBCallbacks* callback, | 28 WebKit::WebIDBCallbacks* callback, |
27 WebKit::WebExceptionCode& ec); | 29 WebKit::WebExceptionCode& ec); |
28 virtual void continueFunction(const WebKit::WebIDBKey& key, | 30 virtual void continueFunction(const WebKit::WebIDBKey& key, |
29 WebKit::WebIDBCallbacks* callback, | 31 WebKit::WebIDBCallbacks* callback, |
30 WebKit::WebExceptionCode& ec); | 32 WebKit::WebExceptionCode& ec); |
31 virtual void deleteFunction(WebKit::WebIDBCallbacks* callback, | 33 virtual void deleteFunction(WebKit::WebIDBCallbacks* callback, |
32 WebKit::WebExceptionCode& ec); | 34 WebKit::WebExceptionCode& ec); |
| 35 virtual void postSuccessHandlerCallback(); |
33 | 36 |
34 void SetKeyAndValue(const IndexedDBKey& key, const IndexedDBKey& primary_key, | 37 void SetKeyAndValue(const IndexedDBKey& key, const IndexedDBKey& primary_key, |
35 const content::SerializedScriptValue& value); | 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(); |
36 | 46 |
37 private: | 47 private: |
38 int32 idb_cursor_id_; | 48 int32 idb_cursor_id_; |
39 IndexedDBKey key_; | 49 IndexedDBKey key_; |
40 IndexedDBKey primary_key_; | 50 IndexedDBKey primary_key_; |
41 content::SerializedScriptValue value_; | 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 }; |
42 }; | 73 }; |
43 | 74 |
44 #endif // CONTENT_RENDERER_RENDERER_WEBIDBCURSOR_IMPL_H_ | 75 #endif // CONTENT_RENDERER_RENDERER_WEBIDBCURSOR_IMPL_H_ |
OLD | NEW |