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

Unified Diff: mojo/edk/embedder/embedder_unittest.cc

Issue 899993002: Add a thread-safe CreateChannel method to ChannelManager. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 10 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: mojo/edk/embedder/embedder_unittest.cc
diff --git a/mojo/edk/embedder/embedder_unittest.cc b/mojo/edk/embedder/embedder_unittest.cc
index ed4ea2e2df361e749eebf1ce3736fa4f40c615ed..fd1c04cd82fd0a2736afdc1db5616f161530c2f7 100644
--- a/mojo/edk/embedder/embedder_unittest.cc
+++ b/mojo/edk/embedder/embedder_unittest.cc
@@ -44,7 +44,7 @@ class ScopedTestChannel {
ScopedPlatformHandle platform_handle)
: io_thread_task_runner_(io_thread_task_runner),
bootstrap_message_pipe_(MOJO_HANDLE_INVALID),
- did_create_channel_event_(true, false),
+ did_create_channel_event_(true, false), // Manual reset.
channel_info_(nullptr) {
bootstrap_message_pipe_ =
CreateChannel(platform_handle.Pass(), io_thread_task_runner_,
@@ -58,7 +58,11 @@ class ScopedTestChannel {
// Destructor: Shuts down the channel. (As noted above, for this to happen,
// the I/O thread must be alive and pumping messages.)
- ~ScopedTestChannel() { DestroyChannel(channel_info_); }
+ ~ScopedTestChannel() {
+ // |WaitForChannelCreationCompletion()| must be called before destruction.
+ CHECK(did_create_channel_event_.IsSignaled());
+ DestroyChannel(channel_info_);
+ }
// Waits for channel creation to be completed.
void WaitForChannelCreationCompletion() { did_create_channel_event_.Wait(); }

Powered by Google App Engine
This is Rietveld 408576698