OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef COMPONENTS_ARC_POWER_ARC_POWER_BRIDGE_H_ | 5 #ifndef COMPONENTS_ARC_POWER_ARC_POWER_BRIDGE_H_ |
6 #define COMPONENTS_ARC_POWER_ARC_POWER_BRIDGE_H_ | 6 #define COMPONENTS_ARC_POWER_ARC_POWER_BRIDGE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "components/arc/arc_bridge_service.h" | 11 #include "components/arc/arc_bridge_service.h" |
12 #include "components/arc/arc_service.h" | 12 #include "components/arc/arc_service.h" |
| 13 #include "components/arc/instance_holder.h" |
13 #include "mojo/public/cpp/bindings/binding.h" | 14 #include "mojo/public/cpp/bindings/binding.h" |
14 #include "ui/display/chromeos/display_configurator.h" | 15 #include "ui/display/chromeos/display_configurator.h" |
15 | 16 |
16 namespace arc { | 17 namespace arc { |
17 | 18 |
18 // ARC Power Client sets power management policy based on requests from | 19 // ARC Power Client sets power management policy based on requests from |
19 // ARC instances. | 20 // ARC instances. |
20 class ArcPowerBridge : public ArcService, | 21 class ArcPowerBridge : public ArcService, |
21 public ArcBridgeService::Observer, | 22 public InstanceHolder<mojom::PowerInstance>::Observer, |
22 public ui::DisplayConfigurator::Observer, | 23 public ui::DisplayConfigurator::Observer, |
23 public mojom::PowerHost { | 24 public mojom::PowerHost { |
24 public: | 25 public: |
25 explicit ArcPowerBridge(ArcBridgeService* bridge_service); | 26 explicit ArcPowerBridge(ArcBridgeService* bridge_service); |
26 ~ArcPowerBridge() override; | 27 ~ArcPowerBridge() override; |
27 | 28 |
28 // ArcBridgeService::Observer overrides. | 29 // InstanceHolder<mojom::PowerInstance>::Observer overrides. |
29 void OnPowerInstanceReady() override; | 30 void OnInstanceReady(mojom::PowerInstance* power_instance, |
30 void OnPowerInstanceClosed() override; | 31 uint32_t version) override; |
| 32 void OnInstanceClosed(mojom::PowerInstance*) override; |
31 | 33 |
32 // DisplayConfigurator::Observer overrides. | 34 // DisplayConfigurator::Observer overrides. |
33 void OnPowerStateChanged(chromeos::DisplayPowerState power_state) override; | 35 void OnPowerStateChanged(chromeos::DisplayPowerState power_state) override; |
34 | 36 |
35 // mojom::PowerHost overrides. | 37 // mojom::PowerHost overrides. |
36 void OnAcquireDisplayWakeLock(mojom::DisplayWakeLockType type) override; | 38 void OnAcquireDisplayWakeLock(mojom::DisplayWakeLockType type) override; |
37 void OnReleaseDisplayWakeLock(mojom::DisplayWakeLockType type) override; | 39 void OnReleaseDisplayWakeLock(mojom::DisplayWakeLockType type) override; |
38 | 40 |
39 void IsDisplayOn(const IsDisplayOnCallback& callback) override; | 41 void IsDisplayOn(const IsDisplayOnCallback& callback) override; |
40 | 42 |
41 private: | 43 private: |
42 void ReleaseAllDisplayWakeLocks(); | 44 void ReleaseAllDisplayWakeLocks(); |
43 | 45 |
44 mojo::Binding<mojom::PowerHost> binding_; | 46 mojo::Binding<mojom::PowerHost> binding_; |
45 | 47 |
46 // Stores a mapping of type -> wake lock ID for all wake locks | 48 // Stores a mapping of type -> wake lock ID for all wake locks |
47 // held by ARC. | 49 // held by ARC. |
48 std::multimap<mojom::DisplayWakeLockType, int> wake_locks_; | 50 std::multimap<mojom::DisplayWakeLockType, int> wake_locks_; |
49 | 51 |
50 DISALLOW_COPY_AND_ASSIGN(ArcPowerBridge); | 52 DISALLOW_COPY_AND_ASSIGN(ArcPowerBridge); |
51 }; | 53 }; |
52 | 54 |
53 } // namespace arc | 55 } // namespace arc |
54 | 56 |
55 #endif // COMPONENTS_ARC_POWER_ARC_POWER_BRIDGE_H_ | 57 #endif // COMPONENTS_ARC_POWER_ARC_POWER_BRIDGE_H_ |
OLD | NEW |