| 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/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" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 bool Send(IPC::Message* msg) override { | 54 bool Send(IPC::Message* msg) override { |
| 55 delete msg; | 55 delete msg; |
| 56 return true; | 56 return true; |
| 57 } | 57 } |
| 58 | 58 |
| 59 private: | 59 private: |
| 60 DISALLOW_COPY_AND_ASSIGN(MockDispatcher); | 60 DISALLOW_COPY_AND_ASSIGN(MockDispatcher); |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 class MockSyncMessageFilter : public IPC::SyncMessageFilter { |
| 64 public: |
| 65 MockSyncMessageFilter() |
| 66 : SyncMessageFilter(nullptr, false /* is_channel_send_thread_safe */) {} |
| 67 |
| 68 private: |
| 69 ~MockSyncMessageFilter() override {} |
| 70 }; |
| 71 |
| 63 } // namespace | 72 } // namespace |
| 64 | 73 |
| 65 class IndexedDBDispatcherTest : public testing::Test { | 74 class IndexedDBDispatcherTest : public testing::Test { |
| 66 public: | 75 public: |
| 67 IndexedDBDispatcherTest() | 76 IndexedDBDispatcherTest() |
| 68 : task_runner_(base::ThreadTaskRunnerHandle::Get()), | 77 : thread_safe_sender_(new ThreadSafeSender( |
| 69 sync_message_filter_(new IPC::SyncMessageFilter(NULL)), | 78 base::ThreadTaskRunnerHandle::Get(), new MockSyncMessageFilter)) {} |
| 70 thread_safe_sender_(new ThreadSafeSender(task_runner_.get(), | |
| 71 sync_message_filter_.get())) {} | |
| 72 | 79 |
| 73 void TearDown() override { blink::WebHeap::collectAllGarbageForTesting(); } | 80 void TearDown() override { blink::WebHeap::collectAllGarbageForTesting(); } |
| 74 | 81 |
| 75 protected: | 82 protected: |
| 76 base::MessageLoop message_loop_; | 83 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_; | 84 scoped_refptr<ThreadSafeSender> thread_safe_sender_; |
| 80 | 85 |
| 81 private: | 86 private: |
| 82 DISALLOW_COPY_AND_ASSIGN(IndexedDBDispatcherTest); | 87 DISALLOW_COPY_AND_ASSIGN(IndexedDBDispatcherTest); |
| 83 }; | 88 }; |
| 84 | 89 |
| 85 TEST_F(IndexedDBDispatcherTest, ValueSizeTest) { | 90 TEST_F(IndexedDBDispatcherTest, ValueSizeTest) { |
| 86 const std::vector<char> data(kMaxIDBValueSizeInBytes + 1); | 91 const std::vector<char> data(kMaxIDBValueSizeInBytes + 1); |
| 87 const WebData value(&data.front(), data.size()); | 92 const WebData value(&data.front(), data.size()); |
| 88 const WebVector<WebBlobInfo> web_blob_info; | 93 const WebVector<WebBlobInfo> web_blob_info; |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 cursor1_transaction_id); | 347 cursor1_transaction_id); |
| 343 | 348 |
| 344 EXPECT_EQ(2, cursor1->reset_count()); | 349 EXPECT_EQ(2, cursor1->reset_count()); |
| 345 EXPECT_EQ(0, cursor2->reset_count()); | 350 EXPECT_EQ(0, cursor2->reset_count()); |
| 346 | 351 |
| 347 cursor1.reset(); | 352 cursor1.reset(); |
| 348 cursor2.reset(); | 353 cursor2.reset(); |
| 349 } | 354 } |
| 350 | 355 |
| 351 } // namespace content | 356 } // namespace content |
| OLD | NEW |