| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 CHROMEOS_DBUS_SYSTEM_CLOCK_CLIENT_H_ | 5 #ifndef CHROMEOS_DBUS_SYSTEM_CLOCK_CLIENT_H_ |
| 6 #define CHROMEOS_DBUS_SYSTEM_CLOCK_CLIENT_H_ | 6 #define CHROMEOS_DBUS_SYSTEM_CLOCK_CLIENT_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "chromeos/chromeos_export.h" | 12 #include "chromeos/chromeos_export.h" |
| 13 #include "chromeos/dbus/dbus_client.h" | 13 #include "chromeos/dbus/dbus_client.h" |
| 14 | 14 |
| 15 namespace chromeos { | 15 namespace chromeos { |
| 16 | 16 |
| 17 // SystemClockClient is used to communicate with the system clock. | 17 // SystemClockClient is used to communicate with the system clock. |
| 18 class CHROMEOS_EXPORT SystemClockClient : public DBusClient { | 18 class CHROMEOS_EXPORT SystemClockClient : public DBusClient { |
| 19 public: | 19 public: |
| 20 // Interface for observing changes from the system clock. | 20 // Interface for observing changes from the system clock. |
| 21 class Observer { | 21 class Observer { |
| 22 public: | 22 public: |
| 23 // Called when the status is updated. | 23 // Called when the status is updated. |
| 24 virtual void SystemClockUpdated(); | 24 virtual void SystemClockUpdated() {} |
| 25 | 25 |
| 26 // Called when the system clock has become settable or unsettable, e.g., | 26 // Called when the system clock has become settable or unsettable, e.g. |
| 27 // when the clock syncs with or goes out of sync with the network. | 27 // when the clock syncs with or goes out of sync with the network. |
| 28 virtual void SystemClockCanSetTimeChanged(bool can_set_time); | 28 virtual void SystemClockCanSetTimeChanged(bool can_set_time) {} |
| 29 | 29 |
| 30 protected: | 30 protected: |
| 31 virtual ~Observer() {} | 31 virtual ~Observer() {} |
| 32 }; | 32 }; |
| 33 | 33 |
| 34 ~SystemClockClient() override; | |
| 35 | |
| 36 // Adds the given observer. | 34 // Adds the given observer. |
| 37 virtual void AddObserver(Observer* observer) = 0; | 35 virtual void AddObserver(Observer* observer) = 0; |
| 38 // Removes the given observer if this object has the observer. | 36 // Removes the given observer if this object has the observer. |
| 39 virtual void RemoveObserver(Observer* observer) = 0; | 37 virtual void RemoveObserver(Observer* observer) = 0; |
| 40 // Returns true if this object has the given observer. | 38 // Returns true if this object has the given observer. |
| 41 virtual bool HasObserver(const Observer* observer) const = 0; | 39 virtual bool HasObserver(const Observer* observer) const = 0; |
| 42 | 40 |
| 43 // Sets the system clock. | 41 // Sets the system clock. |
| 44 virtual void SetTime(int64_t time_in_seconds) = 0; | 42 virtual void SetTime(int64_t time_in_seconds) = 0; |
| 45 | 43 |
| 46 // Checks if the system time can be set. | 44 // Checks if the system time can be set. |
| 47 virtual bool CanSetTime() = 0; | 45 virtual bool CanSetTime() = 0; |
| 48 | 46 |
| 49 // Creates the instance. | 47 // Creates the instance. |
| 50 static SystemClockClient* Create(); | 48 static SystemClockClient* Create(); |
| 51 | 49 |
| 52 protected: | 50 protected: |
| 53 // Create() should be used instead. | 51 // Create() should be used instead. |
| 54 SystemClockClient(); | 52 SystemClockClient(); |
| 55 | 53 |
| 56 private: | 54 private: |
| 57 DISALLOW_COPY_AND_ASSIGN(SystemClockClient); | 55 DISALLOW_COPY_AND_ASSIGN(SystemClockClient); |
| 58 }; | 56 }; |
| 59 | 57 |
| 60 } // namespace chromeos | 58 } // namespace chromeos |
| 61 | 59 |
| 62 #endif // CHROMEOS_DBUS_SYSTEM_CLOCK_CLIENT_H_ | 60 #endif // CHROMEOS_DBUS_SYSTEM_CLOCK_CLIENT_H_ |
| OLD | NEW |