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 #include "base/memory/scoped_ptr.h" | 5 #include "base/memory/scoped_ptr.h" |
6 #include "base/values.h" | 6 #include "base/values.h" |
7 #include "content/child/indexed_db/indexed_db_dispatcher.h" | 7 #include "content/child/indexed_db/indexed_db_dispatcher.h" |
8 #include "content/child/indexed_db/proxy_webidbcursor_impl.h" | 8 #include "content/child/indexed_db/proxy_webidbcursor_impl.h" |
9 #include "content/child/thread_safe_sender.h" | 9 #include "content/child/thread_safe_sender.h" |
10 #include "content/common/indexed_db/indexed_db_key.h" | 10 #include "content/common/indexed_db/indexed_db_key.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 TEST(RendererWebIDBCursorImplTest, PrefetchTest) { | 84 TEST(RendererWebIDBCursorImplTest, PrefetchTest) { |
85 | 85 |
86 WebIDBKey null_key; | 86 WebIDBKey null_key; |
87 null_key.assignNull(); | 87 null_key.assignNull(); |
88 | 88 |
89 scoped_refptr<base::MessageLoopProxy> message_loop_proxy( | 89 scoped_refptr<base::MessageLoopProxy> message_loop_proxy( |
90 base::MessageLoopProxy::current()); | 90 base::MessageLoopProxy::current()); |
91 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter( | 91 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter( |
92 new IPC::SyncMessageFilter(NULL)); | 92 new IPC::SyncMessageFilter(NULL)); |
93 scoped_refptr<ThreadSafeSender> thread_safe_sender(new ThreadSafeSender( | 93 scoped_refptr<ThreadSafeSender> thread_safe_sender(new ThreadSafeSender( |
94 message_loop_proxy, sync_message_filter)); | 94 message_loop_proxy.get(), sync_message_filter.get())); |
95 | 95 |
96 MockDispatcher dispatcher(thread_safe_sender); | 96 MockDispatcher dispatcher(thread_safe_sender.get()); |
97 | 97 |
98 { | 98 { |
99 RendererWebIDBCursorImpl cursor( | 99 RendererWebIDBCursorImpl cursor(RendererWebIDBCursorImpl::kInvalidCursorId, |
100 RendererWebIDBCursorImpl::kInvalidCursorId, thread_safe_sender); | 100 thread_safe_sender.get()); |
101 | 101 |
102 // Call continue() until prefetching should kick in. | 102 // Call continue() until prefetching should kick in. |
103 int continue_calls = 0; | 103 int continue_calls = 0; |
104 EXPECT_EQ(dispatcher.continue_calls(), 0); | 104 EXPECT_EQ(dispatcher.continue_calls(), 0); |
105 for (int i = 0; i < RendererWebIDBCursorImpl::kPrefetchContinueThreshold; | 105 for (int i = 0; i < RendererWebIDBCursorImpl::kPrefetchContinueThreshold; |
106 ++i) { | 106 ++i) { |
107 cursor.continueFunction(null_key, new MockContinueCallbacks()); | 107 cursor.continueFunction(null_key, new MockContinueCallbacks()); |
108 EXPECT_EQ(++continue_calls, dispatcher.continue_calls()); | 108 EXPECT_EQ(++continue_calls, dispatcher.continue_calls()); |
109 EXPECT_EQ(0, dispatcher.prefetch_calls()); | 109 EXPECT_EQ(0, dispatcher.prefetch_calls()); |
110 } | 110 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 EXPECT_EQ(expected_key++, key.number()); | 152 EXPECT_EQ(expected_key++, key.number()); |
153 } | 153 } |
154 } | 154 } |
155 } | 155 } |
156 | 156 |
157 EXPECT_EQ(dispatcher.destroyed_cursor_id(), | 157 EXPECT_EQ(dispatcher.destroyed_cursor_id(), |
158 RendererWebIDBCursorImpl::kInvalidCursorId); | 158 RendererWebIDBCursorImpl::kInvalidCursorId); |
159 } | 159 } |
160 | 160 |
161 } // namespace content | 161 } // namespace content |
OLD | NEW |