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

Side by Side Diff: content/child/indexed_db/indexed_db_dispatcher_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/single_thread_task_runner.h" 6 #include "base/single_thread_task_runner.h"
7 #include "base/thread_task_runner_handle.h" 7 #include "base/thread_task_runner_handle.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "content/child/indexed_db/indexed_db_dispatcher.h" 9 #include "content/child/indexed_db/indexed_db_dispatcher.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 "content/common/indexed_db/indexed_db_key_range.h" 13 #include "content/common/indexed_db/indexed_db_key_range.h"
14 #include "content/common/indexed_db/indexed_db_messages.h" 14 #include "content/common/indexed_db/indexed_db_messages.h"
15 #include "ipc/ipc_sync_message_filter.h" 15 #include "content/test/test_thread_safe_sender.h"
16 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
17 #include "third_party/WebKit/public/platform/WebBlobInfo.h" 17 #include "third_party/WebKit/public/platform/WebBlobInfo.h"
18 #include "third_party/WebKit/public/platform/WebData.h" 18 #include "third_party/WebKit/public/platform/WebData.h"
19 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBCallbacks.h " 19 #include "third_party/WebKit/public/platform/modules/indexeddb/WebIDBCallbacks.h "
20 #include "third_party/WebKit/public/web/WebHeap.h" 20 #include "third_party/WebKit/public/web/WebHeap.h"
21 21
22 using blink::WebBlobInfo; 22 using blink::WebBlobInfo;
23 using blink::WebData; 23 using blink::WebData;
24 using blink::WebIDBCallbacks; 24 using blink::WebIDBCallbacks;
25 using blink::WebIDBCursor; 25 using blink::WebIDBCursor;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 58
59 private: 59 private:
60 DISALLOW_COPY_AND_ASSIGN(MockDispatcher); 60 DISALLOW_COPY_AND_ASSIGN(MockDispatcher);
61 }; 61 };
62 62
63 } // namespace 63 } // namespace
64 64
65 class IndexedDBDispatcherTest : public testing::Test { 65 class IndexedDBDispatcherTest : public testing::Test {
66 public: 66 public:
67 IndexedDBDispatcherTest() 67 IndexedDBDispatcherTest()
68 : task_runner_(base::ThreadTaskRunnerHandle::Get()), 68 : thread_safe_sender_(TestThreadSafeSender::Create(
69 sync_message_filter_(new IPC::SyncMessageFilter(NULL)), 69 base::ThreadTaskRunnerHandle::Get())) {}
70 thread_safe_sender_(new ThreadSafeSender(task_runner_.get(),
71 sync_message_filter_.get())) {}
72 70
73 void TearDown() override { blink::WebHeap::collectAllGarbageForTesting(); } 71 void TearDown() override { blink::WebHeap::collectAllGarbageForTesting(); }
74 72
75 protected: 73 protected:
76 base::MessageLoop message_loop_; 74 base::MessageLoop message_loop_;
77 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
78 scoped_refptr<IPC::SyncMessageFilter> sync_message_filter_;
79 scoped_refptr<ThreadSafeSender> thread_safe_sender_; 75 scoped_refptr<ThreadSafeSender> thread_safe_sender_;
80 76
81 private: 77 private:
82 DISALLOW_COPY_AND_ASSIGN(IndexedDBDispatcherTest); 78 DISALLOW_COPY_AND_ASSIGN(IndexedDBDispatcherTest);
83 }; 79 };
84 80
85 TEST_F(IndexedDBDispatcherTest, ValueSizeTest) { 81 TEST_F(IndexedDBDispatcherTest, ValueSizeTest) {
86 const std::vector<char> data(kMaxIDBValueSizeInBytes + 1); 82 const std::vector<char> data(kMaxIDBValueSizeInBytes + 1);
87 const WebData value(&data.front(), data.size()); 83 const WebData value(&data.front(), data.size());
88 const WebVector<WebBlobInfo> web_blob_info; 84 const WebVector<WebBlobInfo> web_blob_info;
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 cursor1_transaction_id); 338 cursor1_transaction_id);
343 339
344 EXPECT_EQ(2, cursor1->reset_count()); 340 EXPECT_EQ(2, cursor1->reset_count());
345 EXPECT_EQ(0, cursor2->reset_count()); 341 EXPECT_EQ(0, cursor2->reset_count());
346 342
347 cursor1.reset(); 343 cursor1.reset();
348 cursor2.reset(); 344 cursor2.reset();
349 } 345 }
350 346
351 } // namespace content 347 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698