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