 Chromium Code Reviews
 Chromium Code Reviews Issue 12093058:
  Screensaver implementation for ChromeOS.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 12093058:
  Screensaver implementation for ChromeOS.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| OLD | NEW | 
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chromeos/dbus/power_manager_client.h" | 5 #include "chromeos/dbus/power_manager_client.h" | 
| 6 | 6 | 
| 7 #include <algorithm> | 7 #include <algorithm> | 
| 8 | 8 | 
| 9 #include "base/bind.h" | 9 #include "base/bind.h" | 
| 10 #include "base/callback.h" | 10 #include "base/callback.h" | 
| 11 #include "base/format_macros.h" | 11 #include "base/format_macros.h" | 
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" | 
| 13 #include "base/message_loop.h" | |
| 13 #include "base/observer_list.h" | 14 #include "base/observer_list.h" | 
| 14 #include "base/stringprintf.h" | 15 #include "base/stringprintf.h" | 
| 15 #include "base/threading/platform_thread.h" | 16 #include "base/threading/platform_thread.h" | 
| 16 #include "base/time.h" | 17 #include "base/time.h" | 
| 17 #include "base/timer.h" | 18 #include "base/timer.h" | 
| 18 #include "chromeos/dbus/power_manager/input_event.pb.h" | 19 #include "chromeos/dbus/power_manager/input_event.pb.h" | 
| 19 #include "chromeos/dbus/power_manager/suspend.pb.h" | 20 #include "chromeos/dbus/power_manager/suspend.pb.h" | 
| 20 #include "chromeos/dbus/power_state_control.pb.h" | 21 #include "chromeos/dbus/power_state_control.pb.h" | 
| 21 #include "chromeos/dbus/power_supply_properties.pb.h" | 22 #include "chromeos/dbus/power_supply_properties.pb.h" | 
| 22 #include "chromeos/dbus/video_activity_update.pb.h" | 23 #include "chromeos/dbus/video_activity_update.pb.h" | 
| (...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 793 } | 794 } | 
| 794 | 795 | 
| 795 virtual void RequestRestart() OVERRIDE {} | 796 virtual void RequestRestart() OVERRIDE {} | 
| 796 virtual void RequestShutdown() OVERRIDE {} | 797 virtual void RequestShutdown() OVERRIDE {} | 
| 797 | 798 | 
| 798 virtual void CalculateIdleTime(const CalculateIdleTimeCallback& callback) | 799 virtual void CalculateIdleTime(const CalculateIdleTimeCallback& callback) | 
| 799 OVERRIDE { | 800 OVERRIDE { | 
| 800 callback.Run(0); | 801 callback.Run(0); | 
| 801 } | 802 } | 
| 802 | 803 | 
| 803 virtual void RequestIdleNotification(int64 threshold) OVERRIDE {} | 804 virtual void RequestIdleNotification(int64 threshold) OVERRIDE { | 
| 
Matt Perry
2013/01/31 00:37:23
When is this called? I know it's a stub, but it'll
 
rkc
2013/01/31 02:15:46
This will only get called when running ChromeOS_Ch
 | |
| 805 MessageLoop::current()->PostDelayedTask( | |
| 806 FROM_HERE, | |
| 807 base::Bind(&PowerManagerClientStubImpl::TriggerIdleNotify, | |
| 808 base::Unretained(this), | |
| 809 threshold), | |
| 810 base::TimeDelta::FromMilliseconds(threshold)); | |
| 811 } | |
| 812 | |
| 804 virtual void NotifyUserActivity( | 813 virtual void NotifyUserActivity( | 
| 805 const base::TimeTicks& last_activity_time) OVERRIDE {} | 814 const base::TimeTicks& last_activity_time) OVERRIDE {} | 
| 806 virtual void NotifyVideoActivity( | 815 virtual void NotifyVideoActivity( | 
| 807 const base::TimeTicks& last_activity_time, | 816 const base::TimeTicks& last_activity_time, | 
| 808 bool is_fullscreen) OVERRIDE {} | 817 bool is_fullscreen) OVERRIDE {} | 
| 809 virtual void RequestPowerStateOverrides( | 818 virtual void RequestPowerStateOverrides( | 
| 810 uint32 request_id, | 819 uint32 request_id, | 
| 811 base::TimeDelta duration, | 820 base::TimeDelta duration, | 
| 812 int overrides, | 821 int overrides, | 
| 813 const PowerStateRequestIdCallback& callback) OVERRIDE { | 822 const PowerStateRequestIdCallback& callback) OVERRIDE { | 
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 856 FOR_EACH_OBSERVER(Observer, observers_, PowerChanged(status_)); | 865 FOR_EACH_OBSERVER(Observer, observers_, PowerChanged(status_)); | 
| 857 } | 866 } | 
| 858 | 867 | 
| 859 void SetBrightness(double percent, bool user_initiated) { | 868 void SetBrightness(double percent, bool user_initiated) { | 
| 860 brightness_ = std::min(std::max(0.0, percent), 100.0); | 869 brightness_ = std::min(std::max(0.0, percent), 100.0); | 
| 861 int brightness_level = static_cast<int>(brightness_); | 870 int brightness_level = static_cast<int>(brightness_); | 
| 862 FOR_EACH_OBSERVER(Observer, observers_, | 871 FOR_EACH_OBSERVER(Observer, observers_, | 
| 863 BrightnessChanged(brightness_level, user_initiated)); | 872 BrightnessChanged(brightness_level, user_initiated)); | 
| 864 } | 873 } | 
| 865 | 874 | 
| 875 void TriggerIdleNotify(int64 threshold) { | |
| 876 FOR_EACH_OBSERVER(Observer, observers_, IdleNotify(threshold)); | |
| 877 } | |
| 878 | |
| 866 bool discharging_; | 879 bool discharging_; | 
| 867 int battery_percentage_; | 880 int battery_percentage_; | 
| 868 double brightness_; | 881 double brightness_; | 
| 869 int pause_count_; | 882 int pause_count_; | 
| 870 ObserverList<Observer> observers_; | 883 ObserverList<Observer> observers_; | 
| 871 base::RepeatingTimer<PowerManagerClientStubImpl> timer_; | 884 base::RepeatingTimer<PowerManagerClientStubImpl> timer_; | 
| 872 PowerSupplyStatus status_; | 885 PowerSupplyStatus status_; | 
| 873 uint32 next_request_id_; | 886 uint32 next_request_id_; | 
| 874 }; | 887 }; | 
| 875 | 888 | 
| 876 PowerManagerClient::PowerManagerClient() { | 889 PowerManagerClient::PowerManagerClient() { | 
| 877 } | 890 } | 
| 878 | 891 | 
| 879 PowerManagerClient::~PowerManagerClient() { | 892 PowerManagerClient::~PowerManagerClient() { | 
| 880 } | 893 } | 
| 881 | 894 | 
| 882 PowerManagerClient* PowerManagerClient::Create( | 895 PowerManagerClient* PowerManagerClient::Create( | 
| 883 DBusClientImplementationType type, | 896 DBusClientImplementationType type, | 
| 884 dbus::Bus* bus) { | 897 dbus::Bus* bus) { | 
| 885 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 898 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) | 
| 886 return new PowerManagerClientImpl(bus); | 899 return new PowerManagerClientImpl(bus); | 
| 887 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 900 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 
| 888 return new PowerManagerClientStubImpl(); | 901 return new PowerManagerClientStubImpl(); | 
| 889 } | 902 } | 
| 890 | 903 | 
| 891 } // namespace chromeos | 904 } // namespace chromeos | 
| OLD | NEW |