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. | |
25 virtual WebKit::WebIDBKey key() const; | |
26 virtual WebKit::WebIDBKey primaryKey() const; | |
27 virtual WebKit::WebSerializedScriptValue value() const; | |
28 virtual void advance(unsigned long count, | 24 virtual void advance(unsigned long count, |
29 WebKit::WebIDBCallbacks* callback, | 25 WebKit::WebIDBCallbacks* callback, |
30 WebKit::WebExceptionCode& ec); | 26 WebKit::WebExceptionCode& ec); |
31 virtual void continueFunction(const WebKit::WebIDBKey& key, | 27 virtual void continueFunction(const WebKit::WebIDBKey& key, |
32 WebKit::WebIDBCallbacks* callback, | 28 WebKit::WebIDBCallbacks* callback, |
33 WebKit::WebExceptionCode& ec); | 29 WebKit::WebExceptionCode& ec); |
34 virtual void deleteFunction(WebKit::WebIDBCallbacks* callback, | 30 virtual void deleteFunction(WebKit::WebIDBCallbacks* callback, |
35 WebKit::WebExceptionCode& ec); | 31 WebKit::WebExceptionCode& ec); |
36 virtual void postSuccessHandlerCallback(); | 32 virtual void postSuccessHandlerCallback(); |
37 | 33 |
38 // TODO(jsbell): Remove the following method after WK92278 rolls. | |
39 void SetKeyAndValue(const content::IndexedDBKey& key, | |
40 const content::IndexedDBKey& primary_key, | |
41 const content::SerializedScriptValue& value); | |
42 void SetPrefetchData( | 34 void SetPrefetchData( |
43 const std::vector<content::IndexedDBKey>& keys, | 35 const std::vector<content::IndexedDBKey>& keys, |
44 const std::vector<content::IndexedDBKey>& primary_keys, | 36 const std::vector<content::IndexedDBKey>& primary_keys, |
45 const std::vector<content::SerializedScriptValue>& values); | 37 const std::vector<content::SerializedScriptValue>& values); |
46 | 38 |
47 void CachedContinue(WebKit::WebIDBCallbacks* callbacks); | 39 void CachedContinue(WebKit::WebIDBCallbacks* callbacks); |
48 void ResetPrefetchCache(); | 40 void ResetPrefetchCache(); |
49 | 41 |
50 private: | 42 private: |
51 int32 idb_cursor_id_; | 43 int32 idb_cursor_id_; |
52 | 44 |
53 // TODO(jsbell): Remove the following three members after WK92278 rolls. | |
54 content::IndexedDBKey key_; | |
55 content::IndexedDBKey primary_key_; | |
56 content::SerializedScriptValue value_; | |
57 | |
58 // Prefetch cache. | 45 // Prefetch cache. |
59 std::deque<content::IndexedDBKey> prefetch_keys_; | 46 std::deque<content::IndexedDBKey> prefetch_keys_; |
60 std::deque<content::IndexedDBKey> prefetch_primary_keys_; | 47 std::deque<content::IndexedDBKey> prefetch_primary_keys_; |
61 std::deque<content::SerializedScriptValue> prefetch_values_; | 48 std::deque<content::SerializedScriptValue> prefetch_values_; |
62 | 49 |
63 // Number of continue calls that would qualify for a pre-fetch. | 50 // Number of continue calls that would qualify for a pre-fetch. |
64 int continue_count_; | 51 int continue_count_; |
65 | 52 |
66 // Number of items used from the last prefetch. | 53 // Number of items used from the last prefetch. |
67 int used_prefetches_; | 54 int used_prefetches_; |
68 | 55 |
69 // Number of onsuccess handlers we are waiting for. | 56 // Number of onsuccess handlers we are waiting for. |
70 int pending_onsuccess_callbacks_; | 57 int pending_onsuccess_callbacks_; |
71 | 58 |
72 // Number of items to request in next prefetch. | 59 // Number of items to request in next prefetch. |
73 int prefetch_amount_; | 60 int prefetch_amount_; |
74 | 61 |
75 enum { kPrefetchContinueThreshold = 2 }; | 62 enum { kPrefetchContinueThreshold = 2 }; |
76 enum { kMinPrefetchAmount = 5 }; | 63 enum { kMinPrefetchAmount = 5 }; |
77 enum { kMaxPrefetchAmount = 100 }; | 64 enum { kMaxPrefetchAmount = 100 }; |
78 }; | 65 }; |
79 | 66 |
80 #endif // CONTENT_COMMON_INDEXED_DB_PROXY_WEBIDBCURSOR_IMPL_H_ | 67 #endif // CONTENT_COMMON_INDEXED_DB_PROXY_WEBIDBCURSOR_IMPL_H_ |
OLD | NEW |