OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CONTENT_COMMON_CHILD_INDEXED_DB_PROXY_WEBIDBCURSOR_IMPL_H_ | |
6 #define CONTENT_COMMON_CHILD_INDEXED_DB_PROXY_WEBIDBCURSOR_IMPL_H_ | |
7 | |
8 #include <deque> | |
9 #include <vector> | |
10 | |
11 #include "base/basictypes.h" | |
12 #include "base/compiler_specific.h" | |
13 #include "base/gtest_prod_util.h" | |
14 #include "content/common/content_export.h" | |
15 #include "content/common/indexed_db/indexed_db_key.h" | |
16 #include "third_party/WebKit/public/platform/WebData.h" | |
17 #include "third_party/WebKit/public/platform/WebIDBCallbacks.h" | |
18 #include "third_party/WebKit/public/platform/WebIDBCursor.h" | |
19 #include "third_party/WebKit/public/platform/WebIDBKey.h" | |
20 | |
21 namespace content { | |
22 | |
23 class CONTENT_EXPORT RendererWebIDBCursorImpl | |
24 : NON_EXPORTED_BASE(public WebKit::WebIDBCursor) { | |
25 public: | |
26 explicit RendererWebIDBCursorImpl(int32 ipc_cursor_id); | |
27 virtual ~RendererWebIDBCursorImpl(); | |
28 | |
29 virtual void advance(unsigned long count, WebKit::WebIDBCallbacks* callback); | |
30 virtual void continueFunction(const WebKit::WebIDBKey& key, | |
31 WebKit::WebIDBCallbacks* callback); | |
32 virtual void postSuccessHandlerCallback(); | |
33 | |
34 void SetPrefetchData(const std::vector<IndexedDBKey>& keys, | |
35 const std::vector<IndexedDBKey>& primary_keys, | |
36 const std::vector<WebKit::WebData>& values); | |
37 | |
38 void CachedContinue(WebKit::WebIDBCallbacks* callbacks); | |
39 void ResetPrefetchCache(); | |
40 | |
41 private: | |
42 FRIEND_TEST_ALL_PREFIXES(RendererWebIDBCursorImplTest, PrefetchTest); | |
43 | |
44 int32 ipc_cursor_id_; | |
45 | |
46 // Prefetch cache. | |
47 std::deque<IndexedDBKey> prefetch_keys_; | |
48 std::deque<IndexedDBKey> prefetch_primary_keys_; | |
49 std::deque<WebKit::WebData> prefetch_values_; | |
50 | |
51 // Number of continue calls that would qualify for a pre-fetch. | |
52 int continue_count_; | |
53 | |
54 // Number of items used from the last prefetch. | |
55 int used_prefetches_; | |
56 | |
57 // Number of onsuccess handlers we are waiting for. | |
58 int pending_onsuccess_callbacks_; | |
59 | |
60 // Number of items to request in next prefetch. | |
61 int prefetch_amount_; | |
62 | |
63 enum { kInvalidCursorId = -1 }; | |
64 enum { kPrefetchContinueThreshold = 2 }; | |
65 enum { kMinPrefetchAmount = 5 }; | |
66 enum { kMaxPrefetchAmount = 100 }; | |
67 }; | |
68 | |
69 } // namespace content | |
70 | |
71 #endif // CONTENT_COMMON_CHILD_INDEXED_DB_PROXY_WEBIDBCURSOR_IMPL_H_ | |
OLD | NEW |