1 // Copyright 2018 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_CHROMEOS_POWER_AUTO_SCREEN_BRIGHTNESS_CONTROLLER_H_ 6 #define CHROME_BROWSER_CHROMEOS_POWER_AUTO_SCREEN_BRIGHTNESS_CONTROLLER_H_ 7 8 #include <memory> 9 10 #include "base/macros.h" 11 #include "base/memory/ref_counted.h" 12 #include "base/sequenced_task_runner.h" 13 #include "components/session_manager/core/session_manager_observer.h" 14 15 namespace chromeos { 16 namespace power { 17 namespace auto_screen_brightness { 18 19 class Adapter; 20 class AlsReaderImpl; 21 class BrightnessMonitorImpl; 22 class MetricsReporter; 23 class ModelConfigLoaderImpl; 24 class ModellerImpl; 25 26 // This controller class sets up and destroys all components needed for the auto 27 // screen brightness feature. 28 class Controller : public session_manager::SessionManagerObserver { 29 public: 30 Controller(); 31 ~Controller() override; 32 33 // session_manager::SessionManagerObserver overrides: 34 void OnUserSessionStarted(bool is_primary_user) override; 35 36 private: 37 // Initializes all components of the adaptive brightness system. 38 // Controller will initialize the components once only, when the first user 39 // signs in. By definition, the first sign-in user is the primary user, the 40 // model will be personalized to this primary user. 41 void InitializeComponents(); 42 43 // Whether all components of the adaptive brightness system are initialized. 44 bool is_initialized_ = false; 45 46 // Whether Controller is waiting for session manager's notification about 47 // user sign-ins. 48 bool observing_session_manager_ = false; 49 50 std::unique_ptr<MetricsReporter> metrics_reporter_; 51 std::unique_ptr<AlsReaderImpl> als_reader_; 52 std::unique_ptr<BrightnessMonitorImpl> brightness_monitor_; 53 std::unique_ptr<ModelConfigLoaderImpl> model_config_loader_; 54 std::unique_ptr<ModellerImpl> modeller_; 55 std::unique_ptr<Adapter> adapter_; 56 57 DISALLOW_COPY_AND_ASSIGN(Controller); 58 }; 59 60 } // namespace auto_screen_brightness 61 } // namespace power 62 } // namespace chromeos 63 64 #endif // CHROME_BROWSER_CHROMEOS_POWER_AUTO_SCREEN_BRIGHTNESS_CONTROLLER_H_ 65