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/indexed_db_key_builders.h" | 8 #include "content/child/indexed_db/indexed_db_key_builders.h" |
9 #include "content/child/indexed_db/webidbcursor_impl.h" | 9 #include "content/child/indexed_db/webidbcursor_impl.h" |
10 #include "content/child/thread_safe_sender.h" | 10 #include "content/child/thread_safe_sender.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 explicit MockDispatcher(ThreadSafeSender* thread_safe_sender) | 31 explicit MockDispatcher(ThreadSafeSender* thread_safe_sender) |
32 : IndexedDBDispatcher(thread_safe_sender), | 32 : IndexedDBDispatcher(thread_safe_sender), |
33 prefetch_calls_(0), | 33 prefetch_calls_(0), |
34 last_prefetch_count_(0), | 34 last_prefetch_count_(0), |
35 reset_calls_(0), | 35 reset_calls_(0), |
36 last_used_count_(0), | 36 last_used_count_(0), |
37 advance_calls_(0), | 37 advance_calls_(0), |
38 continue_calls_(0), | 38 continue_calls_(0), |
39 destroyed_cursor_id_(0) {} | 39 destroyed_cursor_id_(0) {} |
40 | 40 |
41 virtual void RequestIDBCursorPrefetch(int n, | 41 void RequestIDBCursorPrefetch(int n, |
42 WebIDBCallbacks* callbacks, | 42 WebIDBCallbacks* callbacks, |
43 int32 ipc_cursor_id) override { | 43 int32 ipc_cursor_id) override { |
44 ++prefetch_calls_; | 44 ++prefetch_calls_; |
45 last_prefetch_count_ = n; | 45 last_prefetch_count_ = n; |
46 callbacks_.reset(callbacks); | 46 callbacks_.reset(callbacks); |
47 } | 47 } |
48 | 48 |
49 virtual void RequestIDBCursorPrefetchReset(int used_prefetches, | 49 void RequestIDBCursorPrefetchReset(int used_prefetches, |
50 int unused_prefetches, | 50 int unused_prefetches, |
51 int32 ipc_cursor_id) override { | 51 int32 ipc_cursor_id) override { |
52 ++reset_calls_; | 52 ++reset_calls_; |
53 last_used_count_ = used_prefetches; | 53 last_used_count_ = used_prefetches; |
54 } | 54 } |
55 | 55 |
56 virtual void RequestIDBCursorAdvance(unsigned long count, | 56 void RequestIDBCursorAdvance(unsigned long count, |
57 WebIDBCallbacks* callbacks, | 57 WebIDBCallbacks* callbacks, |
58 int32 ipc_cursor_id, | 58 int32 ipc_cursor_id, |
59 int64 transaction_id) override { | 59 int64 transaction_id) override { |
60 ++advance_calls_; | 60 ++advance_calls_; |
61 callbacks_.reset(callbacks); | 61 callbacks_.reset(callbacks); |
62 } | 62 } |
63 | 63 |
64 virtual void RequestIDBCursorContinue(const IndexedDBKey& key, | 64 void RequestIDBCursorContinue(const IndexedDBKey& key, |
65 const IndexedDBKey& primary_key, | 65 const IndexedDBKey& primary_key, |
66 WebIDBCallbacks* callbacks, | 66 WebIDBCallbacks* callbacks, |
67 int32 ipc_cursor_id, | 67 int32 ipc_cursor_id, |
68 int64 transaction_id) override { | 68 int64 transaction_id) override { |
69 ++continue_calls_; | 69 ++continue_calls_; |
70 callbacks_.reset(callbacks); | 70 callbacks_.reset(callbacks); |
71 } | 71 } |
72 | 72 |
73 virtual void CursorDestroyed(int32 ipc_cursor_id) override { | 73 void CursorDestroyed(int32 ipc_cursor_id) override { |
74 destroyed_cursor_id_ = ipc_cursor_id; | 74 destroyed_cursor_id_ = ipc_cursor_id; |
75 } | 75 } |
76 | 76 |
77 int prefetch_calls() { return prefetch_calls_; } | 77 int prefetch_calls() { return prefetch_calls_; } |
78 int last_prefetch_count() { return last_prefetch_count_; } | 78 int last_prefetch_count() { return last_prefetch_count_; } |
79 int reset_calls() { return reset_calls_; } | 79 int reset_calls() { return reset_calls_; } |
80 int last_used_count() { return last_used_count_; } | 80 int last_used_count() { return last_used_count_; } |
81 int advance_calls() { return advance_calls_; } | 81 int advance_calls() { return advance_calls_; } |
82 int continue_calls() { return continue_calls_; } | 82 int continue_calls() { return continue_calls_; } |
83 int32 destroyed_cursor_id() { return destroyed_cursor_id_; } | 83 int32 destroyed_cursor_id() { return destroyed_cursor_id_; } |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 // The real dispatcher would call cursor->CachedContinue(), so do that: | 320 // The real dispatcher would call cursor->CachedContinue(), so do that: |
321 scoped_ptr<WebIDBCallbacks> callbacks(new MockContinueCallbacks()); | 321 scoped_ptr<WebIDBCallbacks> callbacks(new MockContinueCallbacks()); |
322 cursor.CachedContinue(callbacks.get()); | 322 cursor.CachedContinue(callbacks.get()); |
323 | 323 |
324 // Now the cursor should have reset the rest of the cache. | 324 // Now the cursor should have reset the rest of the cache. |
325 EXPECT_EQ(1, dispatcher_->reset_calls()); | 325 EXPECT_EQ(1, dispatcher_->reset_calls()); |
326 EXPECT_EQ(1, dispatcher_->last_used_count()); | 326 EXPECT_EQ(1, dispatcher_->last_used_count()); |
327 } | 327 } |
328 | 328 |
329 } // namespace content | 329 } // namespace content |
OLD | NEW |