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

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

Issue 2194193002: Fix ArcBridgeBootstrap race issues. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix ArcBridgeBootstrap race issues. 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_bootstrap.cc
diff --git a/components/arc/test/fake_arc_bridge_bootstrap.cc b/components/arc/test/fake_arc_bridge_bootstrap.cc
index 054ebad5b402fe32ad523cc944bdd527c240bc6e..44c080e6866ee36d4d942dbd0dec636513a5d6e3 100644
--- a/components/arc/test/fake_arc_bridge_bootstrap.cc
+++ b/components/arc/test/fake_arc_bridge_bootstrap.cc
@@ -4,37 +4,47 @@
#include "components/arc/test/fake_arc_bridge_bootstrap.h"
-#include <utility>
-
#include "base/logging.h"
-#include "components/arc/common/arc_bridge.mojom.h"
-#include "components/arc/test/fake_arc_bridge_instance.h"
-#include "mojo/public/cpp/bindings/interface_request.h"
namespace arc {
-FakeArcBridgeBootstrap::FakeArcBridgeBootstrap(FakeArcBridgeInstance* instance)
- : instance_(instance) {
- instance_->set_delegate(this);
-}
+FakeArcBridgeBootstrap::FakeArcBridgeBootstrap() = default;
+
+FakeArcBridgeBootstrap::~FakeArcBridgeBootstrap() = default;
void FakeArcBridgeBootstrap::Start() {
DCHECK(delegate_);
- mojom::ArcBridgeInstancePtr instance;
- instance_->Bind(mojo::GetProxy(&instance));
- delegate_->OnConnectionEstablished(std::move(instance));
+ if (boot_failure_emulation_enabled_) {
+ delegate_->OnStopped(boot_failure_reason_);
+ } else if (!boot_suspended_) {
+ delegate_->OnReady();
+ }
}
void FakeArcBridgeBootstrap::Stop() {
- DCHECK(delegate_);
- instance_->Unbind();
- delegate_->OnStopped(ArcBridgeService::StopReason::SHUTDOWN);
+ StopWithReason(ArcBridgeService::StopReason::SHUTDOWN);
}
-void FakeArcBridgeBootstrap::OnStopped(ArcBridgeService::StopReason reason) {
+void FakeArcBridgeBootstrap::StopWithReason(
+ ArcBridgeService::StopReason reason) {
DCHECK(delegate_);
- instance_->Unbind();
delegate_->OnStopped(reason);
}
+void FakeArcBridgeBootstrap::EnableBootFailureEmulation(
+ ArcBridgeService::StopReason reason) {
+ DCHECK(!boot_failure_emulation_enabled_);
+ DCHECK(!boot_suspended_);
+
+ boot_failure_emulation_enabled_ = true;
+ boot_failure_reason_ = reason;
+}
+
+void FakeArcBridgeBootstrap::SuspendBoot() {
+ DCHECK(!boot_failure_emulation_enabled_);
+ DCHECK(!boot_suspended_);
+
+ boot_suspended_ = true;
+}
+
} // namespace arc
« components/arc/arc_bridge_bootstrap.cc ('K') | « components/arc/test/fake_arc_bridge_bootstrap.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698