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.h"
14 #include "chromeos/dbus/dbus_client_implementation_type.h"
15 #include "chromeos/dbus/shill_client_helper.h"
20 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 : public DBusClient {
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.
46 // TODO(stevenjb): remove dependencies on entry_path -> service_path
47 // mappings in some of the TestInterface implementations.
50 virtual void AddProfile(const std::string& profile_path,
51 const std::string& userhash) = 0;
53 // Adds an entry to the profile only. |entry_path| corresponds to a
54 // 'service_path' and a corresponding entry will be added to
55 // ShillManagerClient ServiceCompleteList. No checking or updating of
56 // ShillServiceClient is performed.
57 virtual void AddEntry(const std::string& profile_path,
58 const std::string& entry_path,
59 const base::DictionaryValue& properties) = 0;
61 // Adds a service to the profile, copying properties from the
62 // ShillServiceClient entry (which must be present). Also sets the Profile
63 // property of the service in ShillServiceClient.
64 virtual bool AddService(const std::string& profile_path,
65 const std::string& service_path) = 0;
67 // Sets |profiles| to the current list of profile paths.
68 virtual void GetProfilePaths(std::vector<std::string>* profiles) = 0;
71 virtual ~TestInterface() {}
74 virtual ~ShillProfileClient();
76 // Factory function, creates a new instance which is owned by the caller.
77 // For normal usage, access the singleton via DBusThreadManager::Get().
78 static ShillProfileClient* Create(DBusClientImplementationType type);
80 // Adds a property changed |observer| for the profile at |profile_path|.
81 virtual void AddPropertyChangedObserver(
82 const dbus::ObjectPath& profile_path,
83 ShillPropertyChangedObserver* observer) = 0;
85 // Removes a property changed |observer| for the profile at |profile_path|.
86 virtual void RemovePropertyChangedObserver(
87 const dbus::ObjectPath& profile_path,
88 ShillPropertyChangedObserver* observer) = 0;
90 // Calls GetProperties method.
91 // |callback| is called after the method call succeeds.
92 virtual void GetProperties(
93 const dbus::ObjectPath& profile_path,
94 const DictionaryValueCallbackWithoutStatus& callback,
95 const ErrorCallback& error_callback) = 0;
97 // Calls GetEntry method.
98 // |callback| is called after the method call succeeds.
99 virtual void GetEntry(const dbus::ObjectPath& profile_path,
100 const std::string& entry_path,
101 const DictionaryValueCallbackWithoutStatus& callback,
102 const ErrorCallback& error_callback) = 0;
104 // Calls DeleteEntry method.
105 // |callback| is called after the method call succeeds.
106 virtual void DeleteEntry(const dbus::ObjectPath& profile_path,
107 const std::string& entry_path,
108 const base::Closure& callback,
109 const ErrorCallback& error_callback) = 0;
111 // Returns an interface for testing (stub only), or returns NULL.
112 virtual TestInterface* GetTestInterface() = 0;
115 friend class ShillProfileClientTest;
117 // Create() should be used instead.
118 ShillProfileClient();
121 DISALLOW_COPY_AND_ASSIGN(ShillProfileClient);
124 } // namespace chromeos
126 #endif // CHROMEOS_DBUS_SHILL_PROFILE_CLIENT_H_