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/Platform/chromium/public/WebData.h" |
14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCallbacks.h" | 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCallbacks.h" |
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCursor.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBCursor.h" |
16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKey.h" | 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIDBKey.h" |
17 | 18 |
18 namespace content { | 19 namespace content { |
19 | 20 |
20 class RendererWebIDBCursorImpl : public WebKit::WebIDBCursor { | 21 class RendererWebIDBCursorImpl : public WebKit::WebIDBCursor { |
21 public: | 22 public: |
22 explicit RendererWebIDBCursorImpl(int32 ipc_cursor_id); | 23 explicit RendererWebIDBCursorImpl(int32 ipc_cursor_id); |
23 virtual ~RendererWebIDBCursorImpl(); | 24 virtual ~RendererWebIDBCursorImpl(); |
24 | 25 |
25 virtual void advance(unsigned long count, | 26 virtual void advance(unsigned long count, |
26 WebKit::WebIDBCallbacks* callback, | 27 WebKit::WebIDBCallbacks* callback, |
27 WebKit::WebExceptionCode& ec); | 28 WebKit::WebExceptionCode& ec); |
28 virtual void continueFunction(const WebKit::WebIDBKey& key, | 29 virtual void continueFunction(const WebKit::WebIDBKey& key, |
29 WebKit::WebIDBCallbacks* callback, | 30 WebKit::WebIDBCallbacks* callback, |
30 WebKit::WebExceptionCode& ec); | 31 WebKit::WebExceptionCode& ec); |
31 virtual void deleteFunction(WebKit::WebIDBCallbacks* callback, | 32 virtual void deleteFunction(WebKit::WebIDBCallbacks* callback, |
32 WebKit::WebExceptionCode& ec); | 33 WebKit::WebExceptionCode& ec); |
33 virtual void postSuccessHandlerCallback(); | 34 virtual void postSuccessHandlerCallback(); |
34 | 35 |
| 36 void SetPrefetchDataOld( |
| 37 const std::vector<IndexedDBKey>& keys, |
| 38 const std::vector<IndexedDBKey>& primary_keys, |
| 39 const std::vector<SerializedScriptValue>& values); |
35 void SetPrefetchData( | 40 void SetPrefetchData( |
36 const std::vector<IndexedDBKey>& keys, | 41 const std::vector<IndexedDBKey>& keys, |
37 const std::vector<IndexedDBKey>& primary_keys, | 42 const std::vector<IndexedDBKey>& primary_keys, |
38 const std::vector<SerializedScriptValue>& values); | 43 const std::vector<WebKit::WebData>& values); |
39 | 44 |
40 void CachedContinue(WebKit::WebIDBCallbacks* callbacks); | 45 void CachedContinue(WebKit::WebIDBCallbacks* callbacks); |
| 46 void CachedContinueOld(WebKit::WebIDBCallbacks* callbacks); |
41 void ResetPrefetchCache(); | 47 void ResetPrefetchCache(); |
42 | 48 |
43 private: | 49 private: |
44 int32 ipc_cursor_id_; | 50 int32 ipc_cursor_id_; |
45 | 51 |
46 // Prefetch cache. | 52 // Prefetch cache. |
47 std::deque<IndexedDBKey> prefetch_keys_; | 53 std::deque<IndexedDBKey> prefetch_keys_; |
48 std::deque<IndexedDBKey> prefetch_primary_keys_; | 54 std::deque<IndexedDBKey> prefetch_primary_keys_; |
49 std::deque<SerializedScriptValue> prefetch_values_; | 55 std::deque<WebKit::WebData> prefetch_values_; |
50 | 56 |
51 // Number of continue calls that would qualify for a pre-fetch. | 57 // Number of continue calls that would qualify for a pre-fetch. |
52 int continue_count_; | 58 int continue_count_; |
53 | 59 |
54 // Number of items used from the last prefetch. | 60 // Number of items used from the last prefetch. |
55 int used_prefetches_; | 61 int used_prefetches_; |
56 | 62 |
57 // Number of onsuccess handlers we are waiting for. | 63 // Number of onsuccess handlers we are waiting for. |
58 int pending_onsuccess_callbacks_; | 64 int pending_onsuccess_callbacks_; |
59 | 65 |
60 // Number of items to request in next prefetch. | 66 // Number of items to request in next prefetch. |
61 int prefetch_amount_; | 67 int prefetch_amount_; |
62 | 68 |
63 enum { kPrefetchContinueThreshold = 2 }; | 69 enum { kPrefetchContinueThreshold = 2 }; |
64 enum { kMinPrefetchAmount = 5 }; | 70 enum { kMinPrefetchAmount = 5 }; |
65 enum { kMaxPrefetchAmount = 100 }; | 71 enum { kMaxPrefetchAmount = 100 }; |
66 }; | 72 }; |
67 | 73 |
68 } // namespace content | 74 } // namespace content |
69 | 75 |
70 #endif // CONTENT_COMMON_INDEXED_DB_PROXY_WEBIDBCURSOR_IMPL_H_ | 76 #endif // CONTENT_COMMON_INDEXED_DB_PROXY_WEBIDBCURSOR_IMPL_H_ |
OLD | NEW |