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

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

Issue 1262253004: Let IPC::SyncMessageFilter take advantage of thread-safe Send. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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
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/thread_task_runner_handle.h" 6 #include "base/thread_task_runner_handle.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/indexed_db_key_builders.h" 9 #include "content/child/indexed_db/indexed_db_key_builders.h"
10 #include "content/child/indexed_db/webidbcursor_impl.h" 10 #include "content/child/indexed_db/webidbcursor_impl.h"
11 #include "content/child/thread_safe_sender.h" 11 #include "content/child/thread_safe_sender.h"
12 #include "content/common/indexed_db/indexed_db_key.h" 12 #include "content/common/indexed_db/indexed_db_key.h"
13 #include "ipc/ipc_sync_message_filter.h" 13 #include "content/test/test_thread_safe_sender.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 #include "third_party/WebKit/public/platform/WebData.h" 15 #include "third_party/WebKit/public/platform/WebData.h"
16 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBCallbacks.h " 16 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBCallbacks.h "
17 17
18 using blink::WebBlobInfo; 18 using blink::WebBlobInfo;
19 using blink::WebData; 19 using blink::WebData;
20 using blink::WebIDBCallbacks; 20 using blink::WebIDBCallbacks;
21 using blink::WebIDBDatabase; 21 using blink::WebIDBDatabase;
22 using blink::WebIDBKey; 22 using blink::WebIDBKey;
23 using blink::WebIDBKeyTypeNumber; 23 using blink::WebIDBKeyTypeNumber;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 IndexedDBKey* key_; 114 IndexedDBKey* key_;
115 WebVector<WebBlobInfo>* web_blob_info_; 115 WebVector<WebBlobInfo>* web_blob_info_;
116 }; 116 };
117 117
118 } // namespace 118 } // namespace
119 119
120 class WebIDBCursorImplTest : public testing::Test { 120 class WebIDBCursorImplTest : public testing::Test {
121 public: 121 public:
122 WebIDBCursorImplTest() { 122 WebIDBCursorImplTest() {
123 null_key_.assignNull(); 123 null_key_.assignNull();
124 sync_message_filter_ = new IPC::SyncMessageFilter(NULL); 124 thread_safe_sender_ =
125 thread_safe_sender_ = new ThreadSafeSender( 125 TestThreadSafeSender::Create(base::ThreadTaskRunnerHandle::Get());
126 base::ThreadTaskRunnerHandle::Get(), sync_message_filter_.get());
127 dispatcher_ = 126 dispatcher_ =
128 make_scoped_ptr(new MockDispatcher(thread_safe_sender_.get())); 127 make_scoped_ptr(new MockDispatcher(thread_safe_sender_.get()));
129 } 128 }
130 129
131 protected: 130 protected:
132 base::MessageLoop message_loop_; 131 base::MessageLoop message_loop_;
133 WebIDBKey null_key_; 132 WebIDBKey null_key_;
134 scoped_refptr<ThreadSafeSender> thread_safe_sender_; 133 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
135 scoped_ptr<MockDispatcher> dispatcher_; 134 scoped_ptr<MockDispatcher> dispatcher_;
136 135
137 private: 136 private:
138 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter_;
139
140 DISALLOW_COPY_AND_ASSIGN(WebIDBCursorImplTest); 137 DISALLOW_COPY_AND_ASSIGN(WebIDBCursorImplTest);
141 }; 138 };
142 139
143 TEST_F(WebIDBCursorImplTest, PrefetchTest) { 140 TEST_F(WebIDBCursorImplTest, PrefetchTest) {
144 const int64 transaction_id = 1; 141 const int64 transaction_id = 1;
145 { 142 {
146 WebIDBCursorImpl cursor(WebIDBCursorImpl::kInvalidCursorId, 143 WebIDBCursorImpl cursor(WebIDBCursorImpl::kInvalidCursorId,
147 transaction_id, 144 transaction_id,
148 thread_safe_sender_.get()); 145 thread_safe_sender_.get());
149 146
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 // The real dispatcher would call cursor->CachedContinue(), so do that: 319 // The real dispatcher would call cursor->CachedContinue(), so do that:
323 scoped_ptr<WebIDBCallbacks> callbacks(new MockContinueCallbacks()); 320 scoped_ptr<WebIDBCallbacks> callbacks(new MockContinueCallbacks());
324 cursor.CachedContinue(callbacks.get()); 321 cursor.CachedContinue(callbacks.get());
325 322
326 // Now the cursor should have reset the rest of the cache. 323 // Now the cursor should have reset the rest of the cache.
327 EXPECT_EQ(1, dispatcher_->reset_calls()); 324 EXPECT_EQ(1, dispatcher_->reset_calls());
328 EXPECT_EQ(1, dispatcher_->last_used_count()); 325 EXPECT_EQ(1, dispatcher_->last_used_count());
329 } 326 }
330 327
331 } // namespace content 328 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698