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

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

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/arc_service_manager.cc ('k') | components/arc/test/fake_arc_bridge_bootstrap.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/arc/test/fake_arc_bridge_bootstrap.h
diff --git a/components/arc/test/fake_arc_bridge_bootstrap.h b/components/arc/test/fake_arc_bridge_bootstrap.h
index edc5c1b7f11363cdadcf1c27aa53a0a0556f346f..5076a0738deb828ef23342a52f3aec6c81f265d2 100644
--- a/components/arc/test/fake_arc_bridge_bootstrap.h
+++ b/components/arc/test/fake_arc_bridge_bootstrap.h
@@ -5,6 +5,8 @@
#ifndef COMPONENTS_ARC_TEST_FAKE_ARC_BRIDGE_BOOTSTRAP_H_
#define COMPONENTS_ARC_TEST_FAKE_ARC_BRIDGE_BOOTSTRAP_H_
+#include <memory>
+
#include "base/macros.h"
#include "components/arc/arc_bridge_bootstrap.h"
#include "components/arc/test/fake_arc_bridge_instance.h"
@@ -12,22 +14,37 @@
namespace arc {
// A fake ArcBridgeBootstrap that creates a local connection.
-class FakeArcBridgeBootstrap : public ArcBridgeBootstrap,
- public FakeArcBridgeInstance::Delegate {
+class FakeArcBridgeBootstrap : public ArcBridgeBootstrap {
public:
- explicit FakeArcBridgeBootstrap(FakeArcBridgeInstance* instance);
- ~FakeArcBridgeBootstrap() override = default;
+ FakeArcBridgeBootstrap();
+ ~FakeArcBridgeBootstrap() override;
// ArcBridgeBootstrap:
void Start() override;
void Stop() override;
+ // To emulate unexpected stop, such as crash.
+ void StopWithReason(ArcBridgeService::StopReason reason);
+
+ // The following control Start() behavior for testing various situations.
+
+ // Enables/disables boot failure emulation, in which OnStopped(reason) will
+ // be called when Start() is called.
+ void EnableBootFailureEmulation(ArcBridgeService::StopReason reason);
+
+ // Emulate Start() is suspended at some phase, before OnReady() is invoked.
+ void SuspendBoot();
+
+ // Returns FakeArcBridgeBootstrap instance. This can be used for a factory
+ // in ArcBridgeServiceImpl.
+ static std::unique_ptr<ArcBridgeBootstrap> Create();
+
private:
- // FakeArcBridgeInstance::Delegate:
- void OnStopped(ArcBridgeService::StopReason reason) override;
+ bool boot_failure_emulation_enabled_ = false;
+ ArcBridgeService::StopReason boot_failure_reason_;
+ FakeArcBridgeInstance instance_;
- // Owned by the caller.
- FakeArcBridgeInstance* instance_;
+ bool boot_suspended_ = false;
DISALLOW_COPY_AND_ASSIGN(FakeArcBridgeBootstrap);
};
« no previous file with comments | « components/arc/arc_service_manager.cc ('k') | components/arc/test/fake_arc_bridge_bootstrap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698