0

[FastPair] Add Mediator to ash/shell

This changes adds quick_pair::Mediator to //ash/shell. This class is
the entry point for the Quick Pair system which enables Fast Pair.

Fixed: 1227437
Change-Id: Ia9b7e32d8df2efb5524ac86ff607bec7d77aa200
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3011114
Commit-Queue: Shane Fitzpatrick <shanefitz@google.com>
Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#899773}
This commit is contained in:
Shane Fitzpatrick
2021-07-09 00:06:50 +00:00
committed by Chromium LUCI CQ
parent 7711d63edb
commit ed125634f7
5 changed files with 43 additions and 1 deletions

@ -1842,6 +1842,7 @@ component("ash") {
"//ash/login/resources:resources_grit",
"//ash/public/cpp/ambient/proto",
"//ash/quick_pair",
"//ash/quick_pair/keyed_service",
"//ash/services/recording",
"//ash/services/recording/public/mojom",
"//ash/system/machine_learning:user_settings_event_proto",

@ -9,10 +9,33 @@
#include "ash/quick_pair/common/device.h"
#include "ash/quick_pair/common/logging.h"
#include "ash/quick_pair/feature_status_tracker/quick_pair_feature_status_tracker.h"
#include "ash/quick_pair/feature_status_tracker/quick_pair_feature_status_tracker_impl.h"
#include "ash/quick_pair/scanning/scanner_broker_impl.h"
namespace ash {
namespace quick_pair {
namespace {
Mediator::Factory* g_test_factory = nullptr;
}
// static
std::unique_ptr<Mediator> Mediator::Factory::Create() {
if (g_test_factory)
return g_test_factory->BuildInstance();
return std::make_unique<Mediator>(
std::make_unique<FeatureStatusTrackerImpl>(),
std::make_unique<ScannerBrokerImpl>());
}
// static
void Mediator::Factory::SetFactoryForTesting(Factory* factory) {
g_test_factory = factory;
}
Mediator::Mediator(std::unique_ptr<FeatureStatusTracker> feature_status_tracker,
std::unique_ptr<ScannerBroker> scanner_broker)
: feature_status_tracker_(std::move(feature_status_tracker)),

@ -20,6 +20,16 @@ namespace quick_pair {
class Mediator : public FeatureStatusTracker::Observer,
public ScannerBroker::Observer {
public:
class Factory {
public:
static std::unique_ptr<Mediator> Create();
static void SetFactoryForTesting(Factory* factory);
virtual ~Factory() = default;
private:
virtual std::unique_ptr<Mediator> BuildInstance() = 0;
};
Mediator(std::unique_ptr<FeatureStatusTracker> feature_status_tracker,
std::unique_ptr<ScannerBroker> scanner_broker);
Mediator(const Mediator&) = delete;

@ -87,6 +87,7 @@
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/public/cpp/views_text_services_context_menu_impl.h"
#include "ash/quick_answers/quick_answers_controller_impl.h"
#include "ash/quick_pair/keyed_service/quick_pair_mediator.h"
#include "ash/root_window_controller.h"
#include "ash/screenshot_delegate.h"
#include "ash/session/session_controller_impl.h"
@ -559,7 +560,8 @@ Shell::Shell(std::unique_ptr<ShellDelegate> shell_delegate)
shell_delegate_(std::move(shell_delegate)),
shutdown_controller_(std::make_unique<ShutdownControllerImpl>()),
system_tray_notifier_(std::make_unique<SystemTrayNotifier>()),
native_cursor_manager_(nullptr) {
native_cursor_manager_(nullptr),
quick_pair_mediator_(quick_pair::Mediator::Factory::Create()) {
AccelerometerReader::GetInstance()->Initialize();
login_screen_controller_ =

@ -207,6 +207,10 @@ class ArcInputMethodBoundsTracker;
enum class LoginStatus;
namespace quick_pair {
class Mediator;
} // namespace quick_pair
// Shell is a singleton object that presents the Shell API and implements the
// RootWindow's delegate interface.
//
@ -889,6 +893,8 @@ class ASH_EXPORT Shell : public SessionObserver,
std::unique_ptr<OcclusionTrackerPauser> occlusion_tracker_pauser_;
std::unique_ptr<quick_pair::Mediator> quick_pair_mediator_;
base::ObserverList<ShellObserver>::Unchecked shell_observers_;
base::WeakPtrFactory<Shell> weak_factory_{this};