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

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: Rebase. 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 | « components/arc/test/fake_arc_bridge_bootstrap.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..5c2c2b9d83c1fe3d5e3a2a5859d207bb79dcc59d 100644
--- a/components/arc/test/fake_arc_bridge_bootstrap.cc
+++ b/components/arc/test/fake_arc_bridge_bootstrap.cc
@@ -4,37 +4,59 @@
#include "components/arc/test/fake_arc_bridge_bootstrap.h"
+#include <memory>
#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"
+#include "base/memory/ptr_util.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_) {
+ mojom::ArcBridgeInstancePtr instance_ptr;
+ instance_.Bind(mojo::GetProxy(&instance_ptr));
+ delegate_->OnConnectionEstablished(std::move(instance_ptr));
+ }
}
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();
+ 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;
+}
+
+// static
+std::unique_ptr<ArcBridgeBootstrap> FakeArcBridgeBootstrap::Create() {
+ return base::MakeUnique<FakeArcBridgeBootstrap>();
+}
+
} // namespace arc
« no previous file with comments | « 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