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

Unified Diff: mojo/public/cpp/bindings/tests/connector_unittest.cc

Issue 2350883003: Mojo C++ bindings: fix Connector teardown. (Closed)
Patch Set: Created 4 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 | « mojo/public/cpp/bindings/lib/connector.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/tests/connector_unittest.cc
diff --git a/mojo/public/cpp/bindings/tests/connector_unittest.cc b/mojo/public/cpp/bindings/tests/connector_unittest.cc
index e84cce6f94de178ff22509f9743a47b88b3062c0..87f88924cc2d608aeae9d023ab9fa7bbac929509 100644
--- a/mojo/public/cpp/bindings/tests/connector_unittest.cc
+++ b/mojo/public/cpp/bindings/tests/connector_unittest.cc
@@ -14,6 +14,7 @@
#include "base/callback_helpers.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h"
+#include "base/threading/thread.h"
#include "base/threading/thread_task_runner_handle.h"
#include "mojo/public/cpp/bindings/lib/message_builder.h"
#include "mojo/public/cpp/bindings/tests/message_queue.h"
@@ -572,6 +573,27 @@ TEST_F(ConnectorTest, ProcessWhenNested) {
ASSERT_EQ(2u, accumulator.size());
}
+TEST_F(ConnectorTest, DestroyOnDifferentThreadAfterClose) {
+ std::unique_ptr<Connector> connector(
+ new Connector(std::move(handle0_), Connector::SINGLE_THREADED_SEND,
+ base::ThreadTaskRunnerHandle::Get()));
+
+ connector->CloseMessagePipe();
+
+ base::Thread another_thread("ThreadForDestroyingConnector");
+ another_thread.Start();
+
+ base::RunLoop run_loop;
+ another_thread.task_runner()->PostTaskAndReply(
+ FROM_HERE,
+ base::Bind(
+ [](std::unique_ptr<Connector> connector) { connector.reset(); },
+ base::Passed(std::move(connector))),
+ run_loop.QuitClosure());
+
+ run_loop.Run();
+}
+
} // namespace
} // namespace test
} // namespace mojo
« no previous file with comments | « mojo/public/cpp/bindings/lib/connector.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698