summaryrefslogtreecommitdiffstats
path: root/chromeos/dbus/system_clock_client.h
blob: 3b84501325e79a922eb7800ad1ecc6456a21e6bb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROMEOS_DBUS_SYSTEM_CLOCK_CLIENT_H_
#define CHROMEOS_DBUS_SYSTEM_CLOCK_CLIENT_H_

#include "base/callback.h"
#include "chromeos/chromeos_export.h"
#include "chromeos/dbus/dbus_client.h"

namespace chromeos {

// SystemClockClient is used to communicate with the system clock.
class CHROMEOS_EXPORT SystemClockClient : public DBusClient {
 public:
  // Interface for observing changes from the system clock.
  class Observer {
   public:
    // Called when the status is updated.
    virtual void SystemClockUpdated();

    // Called when the system clock has become settable or unsettable, e.g.,
    // when the clock syncs with or goes out of sync with the network.
    virtual void SystemClockCanSetTimeChanged(bool can_set_time);

   protected:
    virtual ~Observer() {}
  };

  ~SystemClockClient() override;

  // Adds the given observer.
  virtual void AddObserver(Observer* observer) = 0;
  // Removes the given observer if this object has the observer.
  virtual void RemoveObserver(Observer* observer) = 0;
  // Returns true if this object has the given observer.
  virtual bool HasObserver(const Observer* observer) const = 0;

  // Sets the system clock.
  virtual void SetTime(int64 time_in_seconds) = 0;

  // Checks if the system time can be set.
  virtual bool CanSetTime() = 0;

  // Creates the instance.
  static SystemClockClient* Create();

 protected:
  // Create() should be used instead.
  SystemClockClient();

 private:
  DISALLOW_COPY_AND_ASSIGN(SystemClockClient);
};

}  // namespace chromeos

#endif  // CHROMEOS_DBUS_SYSTEM_CLOCK_CLIENT_H_