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 22 matching lines...) Expand all Loading... |
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 virtual 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 virtual 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 virtual 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 virtual 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 virtual 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 11 matching lines...) Expand all Loading... |
95 | 95 |
96 class MockContinueCallbacks : public WebIDBCallbacks { | 96 class MockContinueCallbacks : public WebIDBCallbacks { |
97 public: | 97 public: |
98 MockContinueCallbacks(IndexedDBKey* key = 0, | 98 MockContinueCallbacks(IndexedDBKey* key = 0, |
99 WebVector<WebBlobInfo>* webBlobInfo = 0) | 99 WebVector<WebBlobInfo>* webBlobInfo = 0) |
100 : key_(key), webBlobInfo_(webBlobInfo) {} | 100 : key_(key), webBlobInfo_(webBlobInfo) {} |
101 | 101 |
102 virtual void onSuccess(const WebIDBKey& key, | 102 virtual void onSuccess(const WebIDBKey& key, |
103 const WebIDBKey& primaryKey, | 103 const WebIDBKey& primaryKey, |
104 const WebData& value, | 104 const WebData& value, |
105 const WebVector<WebBlobInfo>& webBlobInfo) OVERRIDE { | 105 const WebVector<WebBlobInfo>& webBlobInfo) override { |
106 if (key_) | 106 if (key_) |
107 *key_ = IndexedDBKeyBuilder::Build(key); | 107 *key_ = IndexedDBKeyBuilder::Build(key); |
108 if (webBlobInfo_) | 108 if (webBlobInfo_) |
109 *webBlobInfo_ = webBlobInfo; | 109 *webBlobInfo_ = webBlobInfo; |
110 } | 110 } |
111 | 111 |
112 private: | 112 private: |
113 IndexedDBKey* key_; | 113 IndexedDBKey* key_; |
114 WebVector<WebBlobInfo>* webBlobInfo_; | 114 WebVector<WebBlobInfo>* webBlobInfo_; |
115 }; | 115 }; |
(...skipping 204 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 |