Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: content/child/indexed_db/webidbcursor_impl_unittest.cc

Issue 2480293004: Mandate unique_ptr for base::IDMap in IDMapOwnPointer mode. (Closed)
Patch Set: Rebase on some ScreenOrientation changes, update that stuff to use unique_ptr (the change I was sca… Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "content/child/indexed_db/webidbcursor_impl.h" 5 #include "content/child/indexed_db/webidbcursor_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <memory> 10 #include <memory>
11 #include <utility>
11 12
12 #include "base/macros.h" 13 #include "base/macros.h"
13 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
14 #include "base/threading/thread_task_runner_handle.h" 15 #include "base/threading/thread_task_runner_handle.h"
15 #include "base/values.h" 16 #include "base/values.h"
16 #include "content/child/indexed_db/indexed_db_dispatcher.h" 17 #include "content/child/indexed_db/indexed_db_dispatcher.h"
17 #include "content/child/indexed_db/indexed_db_key_builders.h" 18 #include "content/child/indexed_db/indexed_db_key_builders.h"
18 #include "content/child/indexed_db/mock_webidbcallbacks.h" 19 #include "content/child/indexed_db/mock_webidbcallbacks.h"
19 #include "content/child/thread_safe_sender.h" 20 #include "content/child/thread_safe_sender.h"
20 #include "content/common/indexed_db/indexed_db_key.h" 21 #include "content/common/indexed_db/indexed_db_key.h"
(...skipping 20 matching lines...) Expand all
41 : IndexedDBDispatcher(thread_safe_sender), 42 : IndexedDBDispatcher(thread_safe_sender),
42 prefetch_calls_(0), 43 prefetch_calls_(0),
43 last_prefetch_count_(0), 44 last_prefetch_count_(0),
44 reset_calls_(0), 45 reset_calls_(0),
45 last_used_count_(0), 46 last_used_count_(0),
46 advance_calls_(0), 47 advance_calls_(0),
47 continue_calls_(0), 48 continue_calls_(0),
48 destroyed_cursor_id_(0) {} 49 destroyed_cursor_id_(0) {}
49 50
50 void RequestIDBCursorPrefetch(int n, 51 void RequestIDBCursorPrefetch(int n,
51 WebIDBCallbacks* callbacks, 52 std::unique_ptr<WebIDBCallbacks> callbacks,
52 int32_t ipc_cursor_id) override { 53 int32_t ipc_cursor_id) override {
53 ++prefetch_calls_; 54 ++prefetch_calls_;
54 last_prefetch_count_ = n; 55 last_prefetch_count_ = n;
55 callbacks_.reset(callbacks); 56 callbacks_ = std::move(callbacks);
56 } 57 }
57 58
58 void RequestIDBCursorPrefetchReset(int used_prefetches, 59 void RequestIDBCursorPrefetchReset(int used_prefetches,
59 int unused_prefetches, 60 int unused_prefetches,
60 int32_t ipc_cursor_id) override { 61 int32_t ipc_cursor_id) override {
61 ++reset_calls_; 62 ++reset_calls_;
62 last_used_count_ = used_prefetches; 63 last_used_count_ = used_prefetches;
63 } 64 }
64 65
65 void RequestIDBCursorAdvance(unsigned long count, 66 void RequestIDBCursorAdvance(unsigned long count,
66 WebIDBCallbacks* callbacks, 67 std::unique_ptr<WebIDBCallbacks> callbacks,
67 int32_t ipc_cursor_id, 68 int32_t ipc_cursor_id,
68 int64_t transaction_id) override { 69 int64_t transaction_id) override {
69 ++advance_calls_; 70 ++advance_calls_;
70 callbacks_.reset(callbacks); 71 callbacks_ = std::move(callbacks);
71 } 72 }
72 73
73 void RequestIDBCursorContinue(const IndexedDBKey& key, 74 void RequestIDBCursorContinue(const IndexedDBKey& key,
74 const IndexedDBKey& primary_key, 75 const IndexedDBKey& primary_key,
75 WebIDBCallbacks* callbacks, 76 std::unique_ptr<WebIDBCallbacks> callbacks,
76 int32_t ipc_cursor_id, 77 int32_t ipc_cursor_id,
77 int64_t transaction_id) override { 78 int64_t transaction_id) override {
78 ++continue_calls_; 79 ++continue_calls_;
79 callbacks_.reset(callbacks); 80 callbacks_ = std::move(callbacks);
80 } 81 }
81 82
82 void CursorDestroyed(int32_t ipc_cursor_id) override { 83 void CursorDestroyed(int32_t ipc_cursor_id) override {
83 destroyed_cursor_id_ = ipc_cursor_id; 84 destroyed_cursor_id_ = ipc_cursor_id;
84 } 85 }
85 86
86 int prefetch_calls() { return prefetch_calls_; } 87 int prefetch_calls() { return prefetch_calls_; }
87 int last_prefetch_count() { return last_prefetch_count_; } 88 int last_prefetch_count() { return last_prefetch_count_; }
88 int reset_calls() { return reset_calls_; } 89 int reset_calls() { return reset_calls_; }
89 int last_used_count() { return last_used_count_; } 90 int last_used_count() { return last_used_count_; }
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 // The real dispatcher would call cursor->CachedContinue(), so do that: 331 // The real dispatcher would call cursor->CachedContinue(), so do that:
331 MockContinueCallbacks callbacks; 332 MockContinueCallbacks callbacks;
332 cursor.CachedContinue(&callbacks); 333 cursor.CachedContinue(&callbacks);
333 334
334 // Now the cursor should have reset the rest of the cache. 335 // Now the cursor should have reset the rest of the cache.
335 EXPECT_EQ(1, dispatcher_->reset_calls()); 336 EXPECT_EQ(1, dispatcher_->reset_calls());
336 EXPECT_EQ(1, dispatcher_->last_used_count()); 337 EXPECT_EQ(1, dispatcher_->last_used_count());
337 } 338 }
338 339
339 } // namespace content 340 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698