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

Unified Diff: components/arc/test/fake_arc_bridge_instance.cc

Issue 2135223002: Use spin runloop instead of WaitForIncomingMethodCall() for test codes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase only Created 4 years, 5 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: components/arc/test/fake_arc_bridge_instance.cc
diff --git a/components/arc/test/fake_arc_bridge_instance.cc b/components/arc/test/fake_arc_bridge_instance.cc
index d65734493ff361ada021987549e1bf148ccfb2de..c1f03f94e6ba218c66fe94e48f4efbcbb6bad0ce 100644
--- a/components/arc/test/fake_arc_bridge_instance.cc
+++ b/components/arc/test/fake_arc_bridge_instance.cc
@@ -6,6 +6,8 @@
#include <utility>
+#include "base/run_loop.h"
+
namespace arc {
FakeArcBridgeInstance::FakeArcBridgeInstance() : binding_(this) {}
@@ -14,6 +16,11 @@ FakeArcBridgeInstance::~FakeArcBridgeInstance() {}
void FakeArcBridgeInstance::Init(mojom::ArcBridgeHostPtr host) {
host_ptr_ = std::move(host);
init_calls_++;
+
+ // Wake WaitForInitCall().
+ if (!quit_closure_.is_null())
+ quit_closure_.Run();
+ quit_closure_.Reset();
}
void FakeArcBridgeInstance::Unbind() {
@@ -28,7 +35,10 @@ void FakeArcBridgeInstance::Bind(
}
void FakeArcBridgeInstance::WaitForInitCall() {
- binding_.WaitForIncomingMethodCall();
+ base::RunLoop run_loop;
+ quit_closure_ = run_loop.QuitClosure();
+ binding_.set_connection_error_handler(run_loop.QuitClosure());
+ run_loop.Run();
}
void FakeArcBridgeInstance::Stop(ArcBridgeService::StopReason reason) {
« no previous file with comments | « components/arc/test/fake_arc_bridge_instance.h ('k') | services/shell/tests/shutdown/shutdown_client_app.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698