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

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: Address comments 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
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..ebf6a1ced4464fb76b43a6fba5e68aa884199871 100644
--- a/components/arc/test/fake_arc_bridge_bootstrap.cc
+++ b/components/arc/test/fake_arc_bridge_bootstrap.cc
@@ -4,37 +4,56 @@
#include "components/arc/test/fake_arc_bridge_bootstrap.h"
-#include <utility>
Luis Héctor Chávez 2016/09/23 05:13:38 Why was this removed? You're still calling std::mo
hidehiko 2016/09/26 14:31:49 I removed std::move etc. at all in earlier PS so t
-
#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
« components/arc/arc_bridge_service_impl.h ('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