Only fsync leveldb's directory when the manifest is being updated.
[chromium-blink-merge.git] / chromeos / dbus / shill_device_client_stub.h
blobcc7edf2f8bf1a271b8c31e2332272e05479f921e
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
3 // found in the LICENSE file.
5 #ifndef CHROMEOS_DBUS_SHILL_DEVICE_CLIENT_STUB_H_
6 #define CHROMEOS_DBUS_SHILL_DEVICE_CLIENT_STUB_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "chromeos/dbus/shill_device_client.h"
13 namespace chromeos {
15 // A stub implementation of ShillDeviceClient.
16 // Implemented: Stub cellular device for SMS testing.
17 class ShillDeviceClientStub : public ShillDeviceClient,
18 public ShillDeviceClient::TestInterface {
19 public:
20 ShillDeviceClientStub();
21 virtual ~ShillDeviceClientStub();
23 // ShillDeviceClient overrides.
24 virtual void AddPropertyChangedObserver(
25 const dbus::ObjectPath& device_path,
26 ShillPropertyChangedObserver* observer) OVERRIDE;
27 virtual void RemovePropertyChangedObserver(
28 const dbus::ObjectPath& device_path,
29 ShillPropertyChangedObserver* observer) OVERRIDE;
30 virtual void GetProperties(const dbus::ObjectPath& device_path,
31 const DictionaryValueCallback& callback) OVERRIDE;
32 virtual base::DictionaryValue* CallGetPropertiesAndBlock(
33 const dbus::ObjectPath& device_path) OVERRIDE;
34 virtual void ProposeScan(const dbus::ObjectPath& device_path,
35 const VoidDBusMethodCallback& callback) OVERRIDE;
37 virtual void SetProperty(const dbus::ObjectPath& device_path,
38 const std::string& name,
39 const base::Value& value,
40 const base::Closure& callback,
41 const ErrorCallback& error_callback) OVERRIDE;
42 virtual void ClearProperty(const dbus::ObjectPath& device_path,
43 const std::string& name,
44 const VoidDBusMethodCallback& callback) OVERRIDE;
45 virtual void AddIPConfig(
46 const dbus::ObjectPath& device_path,
47 const std::string& method,
48 const ObjectPathDBusMethodCallback& callback) OVERRIDE;
49 virtual void RequirePin(const dbus::ObjectPath& device_path,
50 const std::string& pin,
51 bool require,
52 const base::Closure& callback,
53 const ErrorCallback& error_callback) OVERRIDE;
54 virtual void EnterPin(const dbus::ObjectPath& device_path,
55 const std::string& pin,
56 const base::Closure& callback,
57 const ErrorCallback& error_callback) OVERRIDE;
58 virtual void UnblockPin(const dbus::ObjectPath& device_path,
59 const std::string& puk,
60 const std::string& pin,
61 const base::Closure& callback,
62 const ErrorCallback& error_callback) OVERRIDE;
63 virtual void ChangePin(const dbus::ObjectPath& device_path,
64 const std::string& old_pin,
65 const std::string& new_pin,
66 const base::Closure& callback,
67 const ErrorCallback& error_callback) OVERRIDE;
68 virtual void Register(const dbus::ObjectPath& device_path,
69 const std::string& network_id,
70 const base::Closure& callback,
71 const ErrorCallback& error_callback) OVERRIDE;
72 virtual void SetCarrier(const dbus::ObjectPath& device_path,
73 const std::string& carrier,
74 const base::Closure& callback,
75 const ErrorCallback& error_callback) OVERRIDE;
76 virtual void Reset(const dbus::ObjectPath& device_path,
77 const base::Closure& callback,
78 const ErrorCallback& error_callback) OVERRIDE;
79 virtual ShillDeviceClient::TestInterface* GetTestInterface() OVERRIDE;
81 // ShillDeviceClient::TestInterface overrides.
82 virtual void AddDevice(const std::string& device_path,
83 const std::string& type,
84 const std::string& object_path) OVERRIDE;
85 virtual void RemoveDevice(const std::string& device_path) OVERRIDE;
86 virtual void ClearDevices() OVERRIDE;
87 virtual void SetDeviceProperty(const std::string& device_path,
88 const std::string& name,
89 const base::Value& value) OVERRIDE;
90 virtual std::string GetDevicePathForType(const std::string& type) OVERRIDE;
92 private:
93 typedef ObserverList<ShillPropertyChangedObserver> PropertyObserverList;
95 void SetDefaultProperties();
96 void PassStubDeviceProperties(const dbus::ObjectPath& device_path,
97 const DictionaryValueCallback& callback) const;
99 // Posts a task to run a void callback with status code |status|.
100 void PostVoidCallback(const VoidDBusMethodCallback& callback,
101 DBusMethodCallStatus status);
103 void NotifyObserversPropertyChanged(const dbus::ObjectPath& device_path,
104 const std::string& property);
105 base::DictionaryValue* GetDeviceProperties(const std::string& device_path);
106 PropertyObserverList& GetObserverList(const dbus::ObjectPath& device_path);
108 // Dictionary of <device_name, Dictionary>.
109 base::DictionaryValue stub_devices_;
110 // Observer list for each device.
111 std::map<dbus::ObjectPath, PropertyObserverList*> observer_list_;
113 // Note: This should remain the last member so it'll be destroyed and
114 // invalidate its weak pointers before any other members are destroyed.
115 base::WeakPtrFactory<ShillDeviceClientStub> weak_ptr_factory_;
117 DISALLOW_COPY_AND_ASSIGN(ShillDeviceClientStub);
120 } // namespace chromeos
122 #endif // CHROMEOS_DBUS_SHILL_DEVICE_CLIENT_STUB_H_