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

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

Issue 312093005: IndexedDB: Sprinkle DISALLOW_COPY_AND_ASSIGN where appropriate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Whitespace fixes Created 6 years, 6 months 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 | Annotate | Revision Log
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 "base/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "base/message_loop/message_loop_proxy.h" 6 #include "base/message_loop/message_loop_proxy.h"
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "content/child/indexed_db/indexed_db_dispatcher.h" 8 #include "content/child/indexed_db/indexed_db_dispatcher.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 21 matching lines...) Expand all
32 class MockCallbacks : public WebIDBCallbacks { 32 class MockCallbacks : public WebIDBCallbacks {
33 public: 33 public:
34 MockCallbacks() : error_seen_(false) {} 34 MockCallbacks() : error_seen_(false) {}
35 35
36 virtual void onError(const WebIDBDatabaseError&) { error_seen_ = true; } 36 virtual void onError(const WebIDBDatabaseError&) { error_seen_ = true; }
37 37
38 bool error_seen() const { return error_seen_; } 38 bool error_seen() const { return error_seen_; }
39 39
40 private: 40 private:
41 bool error_seen_; 41 bool error_seen_;
42
43 DISALLOW_COPY_AND_ASSIGN(MockCallbacks);
42 }; 44 };
43 45
44 class MockDispatcher : public IndexedDBDispatcher { 46 class MockDispatcher : public IndexedDBDispatcher {
45 public: 47 public:
46 MockDispatcher(ThreadSafeSender* sender) : IndexedDBDispatcher(sender) {} 48 MockDispatcher(ThreadSafeSender* sender) : IndexedDBDispatcher(sender) {}
47 49
48 virtual bool Send(IPC::Message* msg) OVERRIDE { 50 virtual bool Send(IPC::Message* msg) OVERRIDE {
49 delete msg; 51 delete msg;
50 return true; 52 return true;
51 } 53 }
54
55 DISALLOW_COPY_AND_ASSIGN(MockDispatcher);
cmumford 2014/06/06 22:10:42 Do you want a private before this?
jsbell 2014/06/06 22:18:13 Done.
52 }; 56 };
53 57
54 } // namespace 58 } // namespace
55 59
56 class IndexedDBDispatcherTest : public testing::Test { 60 class IndexedDBDispatcherTest : public testing::Test {
57 public: 61 public:
58 IndexedDBDispatcherTest() 62 IndexedDBDispatcherTest()
59 : message_loop_proxy_(base::MessageLoopProxy::current()), 63 : message_loop_proxy_(base::MessageLoopProxy::current()),
60 sync_message_filter_(new IPC::SyncMessageFilter(NULL)), 64 sync_message_filter_(new IPC::SyncMessageFilter(NULL)),
61 thread_safe_sender_(new ThreadSafeSender(message_loop_proxy_.get(), 65 thread_safe_sender_(new ThreadSafeSender(message_loop_proxy_.get(),
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 virtual void onSuccess(WebIDBCursor* cursor, 139 virtual void onSuccess(WebIDBCursor* cursor,
136 const WebIDBKey& key, 140 const WebIDBKey& key,
137 const WebIDBKey& primaryKey, 141 const WebIDBKey& primaryKey,
138 const WebData& value, 142 const WebData& value,
139 const WebVector<WebBlobInfo>&) OVERRIDE { 143 const WebVector<WebBlobInfo>&) OVERRIDE {
140 cursor_->reset(cursor); 144 cursor_->reset(cursor);
141 } 145 }
142 146
143 private: 147 private:
144 scoped_ptr<WebIDBCursor>* cursor_; 148 scoped_ptr<WebIDBCursor>* cursor_;
149
150 DISALLOW_COPY_AND_ASSIGN(CursorCallbacks);
145 }; 151 };
146 152
147 } // namespace 153 } // namespace
148 154
149 TEST_F(IndexedDBDispatcherTest, CursorTransactionId) { 155 TEST_F(IndexedDBDispatcherTest, CursorTransactionId) {
150 const int32 ipc_database_id = -1; 156 const int32 ipc_database_id = -1;
151 const int64 transaction_id = 1234; 157 const int64 transaction_id = 1234;
152 const int64 object_store_id = 2; 158 const int64 object_store_id = 2;
153 const int32 index_id = 3; 159 const int32 index_id = 3;
154 const WebIDBCursor::Direction direction = WebIDBCursor::Next; 160 const WebIDBCursor::Direction direction = WebIDBCursor::Next;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 : WebIDBCursorImpl(ipc_cursor_id, transaction_id, thread_safe_sender), 247 : WebIDBCursorImpl(ipc_cursor_id, transaction_id, thread_safe_sender),
242 reset_count_(0) {} 248 reset_count_(0) {}
243 249
244 // This method is virtual so it can be overridden in unit tests. 250 // This method is virtual so it can be overridden in unit tests.
245 virtual void ResetPrefetchCache() OVERRIDE { ++reset_count_; } 251 virtual void ResetPrefetchCache() OVERRIDE { ++reset_count_; }
246 252
247 int reset_count() const { return reset_count_; } 253 int reset_count() const { return reset_count_; }
248 254
249 private: 255 private:
250 int reset_count_; 256 int reset_count_;
257
258 DISALLOW_COPY_AND_ASSIGN(MockCursor);
251 }; 259 };
252 260
253 } // namespace 261 } // namespace
254 262
255 TEST_F(IndexedDBDispatcherTest, CursorReset) { 263 TEST_F(IndexedDBDispatcherTest, CursorReset) {
256 scoped_ptr<WebIDBCursor> cursor; 264 scoped_ptr<WebIDBCursor> cursor;
257 MockDispatcher dispatcher(thread_safe_sender_.get()); 265 MockDispatcher dispatcher(thread_safe_sender_.get());
258 266
259 const int32 ipc_database_id = 0; 267 const int32 ipc_database_id = 0;
260 const int32 object_store_id = 0; 268 const int32 object_store_id = 0;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 cursor1_transaction_id); 333 cursor1_transaction_id);
326 334
327 EXPECT_EQ(2, cursor1->reset_count()); 335 EXPECT_EQ(2, cursor1->reset_count());
328 EXPECT_EQ(0, cursor2->reset_count()); 336 EXPECT_EQ(0, cursor2->reset_count());
329 337
330 cursor1.reset(); 338 cursor1.reset();
331 cursor2.reset(); 339 cursor2.reset();
332 } 340 }
333 341
334 } // namespace content 342 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/indexed_db/leveldb/leveldb_transaction.h ('k') | content/child/indexed_db/indexed_db_key_builders.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698