OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/test/test_thread_safe_sender.h" |
| 6 |
| 7 #include "base/synchronization/waitable_event.h" |
| 8 #include "base/threading/thread.h" |
| 9 #include "ipc/ipc_sync_channel.h" |
| 10 |
| 11 namespace content { |
| 12 |
| 13 namespace { |
| 14 |
| 15 class FakeIPCListener : public IPC::Listener { |
| 16 public: |
| 17 FakeIPCListener() {} |
| 18 ~FakeIPCListener() override {} |
| 19 bool OnMessageReceived(const IPC::Message& message) override { return false; } |
| 20 }; |
| 21 |
| 22 } // namespace |
| 23 |
| 24 // static |
| 25 scoped_refptr<ThreadSafeSender> TestThreadSafeSender::Create( |
| 26 const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner) { |
| 27 scoped_ptr<base::Thread> io_thread( |
| 28 new base::Thread("TestThreadSafeSender IO")); |
| 29 io_thread->Start(); |
| 30 |
| 31 scoped_ptr<base::WaitableEvent> shutdown_event( |
| 32 new base::WaitableEvent(true /* manual_reset */, |
| 33 false /* initially_signaled */)); |
| 34 scoped_ptr<IPC::SyncChannel> sync_channel = IPC::SyncChannel::Create( |
| 35 nullptr, io_thread->task_runner(), shutdown_event.get()); |
| 36 return new TestThreadSafeSender(main_task_runner, io_thread.Pass(), |
| 37 shutdown_event.Pass(), sync_channel.Pass()); |
| 38 } |
| 39 |
| 40 TestThreadSafeSender::TestThreadSafeSender( |
| 41 const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner, |
| 42 scoped_ptr<base::Thread> io_thread, |
| 43 scoped_ptr<base::WaitableEvent> shutdown_event, |
| 44 scoped_ptr<IPC::SyncChannel> sync_channel) |
| 45 : ThreadSafeSender(main_task_runner, |
| 46 sync_channel->AddNewSyncMessageFilter()), |
| 47 io_thread_(io_thread.Pass()), |
| 48 shutdown_event_(shutdown_event.Pass()), |
| 49 sync_channel_(sync_channel.Pass()) { |
| 50 } |
| 51 |
| 52 TestThreadSafeSender::~TestThreadSafeSender() { |
| 53 } |
| 54 |
| 55 } // namespace content |
OLD | NEW |