blob: db06b3df412a89245f632840fb15634599c94c1f [file] [log] [blame]
Mattias Nissler980f2aa52019-02-13 13:21:491// Copyright 2019 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_SCHEDULER_CONFIGURATION_MANAGER_H_
6#define CHROME_BROWSER_CHROMEOS_SCHEDULER_CONFIGURATION_MANAGER_H_
7
Yusuke Sato1eab4d22019-10-03 05:39:018#include <utility>
9
Mattias Nissler980f2aa52019-02-13 13:21:4910#include "base/macros.h"
11#include "base/memory/weak_ptr.h"
Yusuke Sato1eab4d22019-10-03 05:39:0112#include "base/optional.h"
Yusuke Sato177847962019-09-30 19:45:3313#include "chromeos/system/scheduler_configuration_manager_base.h"
Mattias Nissler980f2aa52019-02-13 13:21:4914#include "components/prefs/pref_change_registrar.h"
15
16class PrefRegistrySimple;
17class PrefService;
18
19namespace chromeos {
20
21class DebugDaemonClient;
22
23// Tracks scheduler configuration as provided by the respective local state pref
24// and sends D-Bus IPC to reconfigure the system on config changes.
Greg Kerr33cd4662019-06-17 07:03:0125//
26// This is the policy to enable and disable Hyper-Threading (H/T) on Intel CPUs.
27// Conservative -> Hyper-Threading disabled.
28// Performance -> Hyper-Threading enabled.
29// For more information on why H/T is configurable, see
30// https://www.chromium.org/chromium-os/mds-on-chromeos
31//
Yusuke Sato177847962019-09-30 19:45:3332class SchedulerConfigurationManager : public SchedulerConfigurationManagerBase {
Mattias Nissler980f2aa52019-02-13 13:21:4933 public:
34 SchedulerConfigurationManager(DebugDaemonClient* debug_daemon_client,
35 PrefService* local_state);
Yusuke Sato177847962019-09-30 19:45:3336 ~SchedulerConfigurationManager() override;
Mattias Nissler980f2aa52019-02-13 13:21:4937
38 static void RegisterLocalStatePrefs(PrefRegistrySimple* registry);
39
Yusuke Sato1eab4d22019-10-03 05:39:0140 // SchedulerConfigurationManagerBase overrides:
41 base::Optional<std::pair<bool, size_t>> GetLastReply() const override;
42
Mattias Nissler980f2aa52019-02-13 13:21:4943 private:
44 void OnDebugDaemonReady(bool service_is_ready);
45 void OnPrefChange();
Yusuke Satoa29dbe42019-09-30 18:11:1646 void OnConfigurationSet(bool result, size_t num_cores_disabled);
Mattias Nissler980f2aa52019-02-13 13:21:4947
48 DebugDaemonClient* debug_daemon_client_ = nullptr;
49 PrefChangeRegistrar observer_;
50 bool debug_daemon_ready_ = false;
Yusuke Sato1eab4d22019-10-03 05:39:0151 base::Optional<std::pair<bool, size_t>> last_reply_;
52
Mattias Nissler980f2aa52019-02-13 13:21:4953 base::WeakPtrFactory<SchedulerConfigurationManager> weak_ptr_factory_{this};
54
55 DISALLOW_COPY_AND_ASSIGN(SchedulerConfigurationManager);
56};
57
58} // namespace chromeos
59
60#endif // CHROME_BROWSER_CHROMEOS_SCHEDULER_CONFIGURATION_MANAGER_H_