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