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

Unified Diff: ipc/ipc_sync_channel_unittest.cc

Issue 10914161: Fix ownership of the helper thread in IPCSyncChannelTest.SyncMessageFilter (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ipc/ipc_sync_channel_unittest.cc
diff --git a/ipc/ipc_sync_channel_unittest.cc b/ipc/ipc_sync_channel_unittest.cc
index 996ef99c4920995b0a20e8a432a4275d3a098526..e9ec02155a8d2ec97f444c288bea5e3cb24aa16c 100644
--- a/ipc/ipc_sync_channel_unittest.cc
+++ b/ipc/ipc_sync_channel_unittest.cc
@@ -1086,18 +1086,17 @@ namespace {
class TestSyncMessageFilter : public SyncMessageFilter {
public:
- TestSyncMessageFilter(base::WaitableEvent* shutdown_event, Worker* worker)
+ TestSyncMessageFilter(base::WaitableEvent* shutdown_event,
+ Worker* worker,
+ scoped_refptr<base::MessageLoopProxy> message_loop)
: SyncMessageFilter(shutdown_event),
worker_(worker),
- thread_("helper_thread") {
- base::Thread::Options options;
- options.message_loop_type = MessageLoop::TYPE_DEFAULT;
- thread_.StartWithOptions(options);
+ message_loop_(message_loop) {
}
virtual void OnFilterAdded(Channel* channel) {
SyncMessageFilter::OnFilterAdded(channel);
- thread_.message_loop()->PostTask(
+ message_loop_->PostTask(
FROM_HERE,
base::Bind(&TestSyncMessageFilter::SendMessageOnHelperThread, this));
}
@@ -1115,20 +1114,26 @@ class TestSyncMessageFilter : public SyncMessageFilter {
virtual ~TestSyncMessageFilter() {}
Worker* worker_;
- base::Thread thread_;
+ scoped_refptr<base::MessageLoopProxy> message_loop_;
};
class SyncMessageFilterServer : public Worker {
public:
SyncMessageFilterServer()
- : Worker(Channel::MODE_SERVER, "sync_message_filter_server") {
- filter_ = new TestSyncMessageFilter(shutdown_event(), this);
+ : Worker(Channel::MODE_SERVER, "sync_message_filter_server"),
+ thread_("helper_thread") {
+ base::Thread::Options options;
+ options.message_loop_type = MessageLoop::TYPE_DEFAULT;
+ thread_.StartWithOptions(options);
+ filter_ = new TestSyncMessageFilter(shutdown_event(), this,
+ thread_.message_loop_proxy());
}
void Run() {
channel()->AddFilter(filter_.get());
}
+ base::Thread thread_;
scoped_refptr<TestSyncMessageFilter> filter_;
};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698