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

Unified Diff: content/test/test_thread_safe_sender.h

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 side-by-side diff with in-line comments
Download patch
Index: content/test/test_thread_safe_sender.h
diff --git a/content/test/test_thread_safe_sender.h b/content/test/test_thread_safe_sender.h
new file mode 100644
index 0000000000000000000000000000000000000000..8232371be3355c27cde0981cd21644fa9e34ca59
--- /dev/null
+++ b/content/test/test_thread_safe_sender.h
@@ -0,0 +1,51 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_TEST_TEST_THREAD_SAFE_SENDER_H_
+#define CONTENT_TEST_TEST_THREAD_SAFE_SENDER_H_
+
+#include "base/memory/ref_counted.h"
+#include "base/memory/scoped_ptr.h"
+#include "content/child/thread_safe_sender.h"
+
+namespace IPC {
+class SyncChannel;
+}
+
+namespace base {
+class SingleThreadTaskRunner;
+class Thread;
+class WaitableEvent;
+}
+
+namespace content {
+
+// This provides an implementation of ThreadSafeSender to be used from unit
+// tests. This creates its on IO thread and IPC::SyncChannel and controls their
+// lifetime.
+class TestThreadSafeSender : public ThreadSafeSender {
+ public:
+ static scoped_refptr<ThreadSafeSender> Create(
+ const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner);
+
+ private:
+ friend class base::RefCountedThreadSafe<ThreadSafeSender>;
+
+ TestThreadSafeSender(
+ const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner,
+ scoped_ptr<base::Thread> io_thread,
+ scoped_ptr<base::WaitableEvent> shutdown_event,
+ scoped_ptr<IPC::SyncChannel> sync_channel);
+ ~TestThreadSafeSender() override;
+
+ scoped_ptr<base::Thread> io_thread_;
+ scoped_ptr<base::WaitableEvent> shutdown_event_;
+ scoped_ptr<IPC::SyncChannel> sync_channel_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestThreadSafeSender);
+};
+
+} // namespace content
+
+#endif // CONTENT_TEST_TEST_THREAD_SAFE_SENDER_H_

Powered by Google App Engine
This is Rietveld 408576698