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 #include "chromeos/dbus/system_clock_client.h" | 5 #include "chromeos/dbus/system_clock_client.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "chromeos/dbus/fake_system_clock_client.h" |
8 #include "dbus/bus.h" | 9 #include "dbus/bus.h" |
9 #include "dbus/message.h" | 10 #include "dbus/message.h" |
10 #include "dbus/object_path.h" | 11 #include "dbus/object_path.h" |
11 #include "dbus/object_proxy.h" | 12 #include "dbus/object_proxy.h" |
12 #include "third_party/cros_system_api/dbus/service_constants.h" | 13 #include "third_party/cros_system_api/dbus/service_constants.h" |
13 | 14 |
14 namespace chromeos { | 15 namespace chromeos { |
15 | 16 |
16 // The SystemClockClient implementation used in production. | 17 // The SystemClockClient implementation used in production. |
17 class SystemClockClientImpl : public SystemClockClient { | 18 class SystemClockClientImpl : public SystemClockClient { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 dbus::ObjectProxy* system_clock_proxy_; | 69 dbus::ObjectProxy* system_clock_proxy_; |
69 ObserverList<Observer> observers_; | 70 ObserverList<Observer> observers_; |
70 | 71 |
71 // Note: This should remain the last member so it'll be destroyed and | 72 // Note: This should remain the last member so it'll be destroyed and |
72 // invalidate its weak pointers before any other members are destroyed. | 73 // invalidate its weak pointers before any other members are destroyed. |
73 base::WeakPtrFactory<SystemClockClientImpl> weak_ptr_factory_; | 74 base::WeakPtrFactory<SystemClockClientImpl> weak_ptr_factory_; |
74 | 75 |
75 DISALLOW_COPY_AND_ASSIGN(SystemClockClientImpl); | 76 DISALLOW_COPY_AND_ASSIGN(SystemClockClientImpl); |
76 }; | 77 }; |
77 | 78 |
78 // The SystemClockClient implementation used on Linux desktop, | |
79 // which does nothing. | |
80 class SystemClockClientStubImpl : public SystemClockClient { | |
81 public: | |
82 SystemClockClientStubImpl() {} | |
83 ~SystemClockClientStubImpl() {} | |
84 | |
85 // SystemClockClient overrides: | |
86 virtual void AddObserver(Observer* observer) OVERRIDE {} | |
87 virtual void RemoveObserver(Observer* observer) OVERRIDE {} | |
88 virtual bool HasObserver(Observer* observer) OVERRIDE { return false; } | |
89 | |
90 private: | |
91 DISALLOW_COPY_AND_ASSIGN(SystemClockClientStubImpl); | |
92 }; | |
93 | |
94 SystemClockClient::SystemClockClient() { | 79 SystemClockClient::SystemClockClient() { |
95 } | 80 } |
96 | 81 |
97 SystemClockClient::~SystemClockClient() { | 82 SystemClockClient::~SystemClockClient() { |
98 } | 83 } |
99 | 84 |
100 // static | 85 // static |
101 SystemClockClient* SystemClockClient::Create( | 86 SystemClockClient* SystemClockClient::Create( |
102 DBusClientImplementationType type, | 87 DBusClientImplementationType type, |
103 dbus::Bus* bus) { | 88 dbus::Bus* bus) { |
104 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) { | 89 if (type == REAL_DBUS_CLIENT_IMPLEMENTATION) { |
105 return new SystemClockClientImpl(bus); | 90 return new SystemClockClientImpl(bus); |
106 } | 91 } |
107 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); | 92 DCHECK_EQ(STUB_DBUS_CLIENT_IMPLEMENTATION, type); |
108 return new SystemClockClientStubImpl(); | 93 return new FakeSystemClockClient(); |
109 } | 94 } |
110 | 95 |
111 } // namespace chromeos | 96 } // namespace chromeos |
OLD | NEW |