| 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() override; |
| 30 void OnPowerInstanceClosed() override; | 31 void OnInstanceClosed() override; |
| 31 | 32 |
| 32 // DisplayConfigurator::Observer overrides. | 33 // DisplayConfigurator::Observer overrides. |
| 33 void OnPowerStateChanged(chromeos::DisplayPowerState power_state) override; | 34 void OnPowerStateChanged(chromeos::DisplayPowerState power_state) override; |
| 34 | 35 |
| 35 // mojom::PowerHost overrides. | 36 // mojom::PowerHost overrides. |
| 36 void OnAcquireDisplayWakeLock(mojom::DisplayWakeLockType type) override; | 37 void OnAcquireDisplayWakeLock(mojom::DisplayWakeLockType type) override; |
| 37 void OnReleaseDisplayWakeLock(mojom::DisplayWakeLockType type) override; | 38 void OnReleaseDisplayWakeLock(mojom::DisplayWakeLockType type) override; |
| 38 | 39 |
| 39 void IsDisplayOn(const IsDisplayOnCallback& callback) override; | 40 void IsDisplayOn(const IsDisplayOnCallback& callback) override; |
| 40 | 41 |
| 41 private: | 42 private: |
| 42 void ReleaseAllDisplayWakeLocks(); | 43 void ReleaseAllDisplayWakeLocks(); |
| 43 | 44 |
| 44 mojo::Binding<mojom::PowerHost> binding_; | 45 mojo::Binding<mojom::PowerHost> binding_; |
| 45 | 46 |
| 46 // Stores a mapping of type -> wake lock ID for all wake locks | 47 // Stores a mapping of type -> wake lock ID for all wake locks |
| 47 // held by ARC. | 48 // held by ARC. |
| 48 std::multimap<mojom::DisplayWakeLockType, int> wake_locks_; | 49 std::multimap<mojom::DisplayWakeLockType, int> wake_locks_; |
| 49 | 50 |
| 50 DISALLOW_COPY_AND_ASSIGN(ArcPowerBridge); | 51 DISALLOW_COPY_AND_ASSIGN(ArcPowerBridge); |
| 51 }; | 52 }; |
| 52 | 53 |
| 53 } // namespace arc | 54 } // namespace arc |
| 54 | 55 |
| 55 #endif // COMPONENTS_ARC_POWER_ARC_POWER_BRIDGE_H_ | 56 #endif // COMPONENTS_ARC_POWER_ARC_POWER_BRIDGE_H_ |
| OLD | NEW |