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
3 // found in the LICENSE file.
5 #ifndef CHROMEOS_DBUS_SHILL_PROFILE_CLIENT_H_
6 #define CHROMEOS_DBUS_SHILL_PROFILE_CLIENT_H_
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "chromeos/chromeos_export.h"
13 #include "chromeos/dbus/dbus_client_implementation_type.h"
14 #include "chromeos/dbus/shill_client_helper.h"
19 class DictionaryValue
;
32 class ShillPropertyChangedObserver
;
34 // ShillProfileClient is used to communicate with the Shill Profile
35 // service. All methods should be called from the origin thread which
36 // initializes the DBusThreadManager instance.
37 class CHROMEOS_EXPORT ShillProfileClient
{
39 typedef ShillClientHelper::PropertyChangedHandler PropertyChangedHandler
;
40 typedef ShillClientHelper::DictionaryValueCallbackWithoutStatus
41 DictionaryValueCallbackWithoutStatus
;
42 typedef ShillClientHelper::ErrorCallback ErrorCallback
;
44 // Interface for setting up services for testing. Accessed through
45 // GetTestInterface(), only implemented in the stub implementation.
48 virtual void AddProfile(const std::string
& profile_path
,
49 const std::string
& userhash
) = 0;
50 virtual void AddEntry(const std::string
& profile_path
,
51 const std::string
& entry_path
,
52 const base::DictionaryValue
& properties
) = 0;
53 virtual bool AddService(const std::string
& service_path
) = 0;
56 virtual ~TestInterface() {}
59 virtual ~ShillProfileClient();
61 // Factory function, creates a new instance which is owned by the caller.
62 // For normal usage, access the singleton via DBusThreadManager::Get().
63 static ShillProfileClient
* Create(DBusClientImplementationType type
,
66 // Adds a property changed |observer| for the profile at |profile_path|.
67 virtual void AddPropertyChangedObserver(
68 const dbus::ObjectPath
& profile_path
,
69 ShillPropertyChangedObserver
* observer
) = 0;
71 // Removes a property changed |observer| for the profile at |profile_path|.
72 virtual void RemovePropertyChangedObserver(
73 const dbus::ObjectPath
& profile_path
,
74 ShillPropertyChangedObserver
* observer
) = 0;
76 // Calls GetProperties method.
77 // |callback| is called after the method call succeeds.
78 virtual void GetProperties(
79 const dbus::ObjectPath
& profile_path
,
80 const DictionaryValueCallbackWithoutStatus
& callback
,
81 const ErrorCallback
& error_callback
) = 0;
83 // Calls GetEntry method.
84 // |callback| is called after the method call succeeds.
85 virtual void GetEntry(const dbus::ObjectPath
& profile_path
,
86 const std::string
& entry_path
,
87 const DictionaryValueCallbackWithoutStatus
& callback
,
88 const ErrorCallback
& error_callback
) = 0;
90 // Calls DeleteEntry method.
91 // |callback| is called after the method call succeeds.
92 virtual void DeleteEntry(const dbus::ObjectPath
& profile_path
,
93 const std::string
& entry_path
,
94 const base::Closure
& callback
,
95 const ErrorCallback
& error_callback
) = 0;
97 // Returns an interface for testing (stub only), or returns NULL.
98 virtual TestInterface
* GetTestInterface() = 0;
101 // Create() should be used instead.
102 ShillProfileClient();
105 DISALLOW_COPY_AND_ASSIGN(ShillProfileClient
);
108 } // namespace chromeos
110 #endif // CHROMEOS_DBUS_SHILL_PROFILE_CLIENT_H_