- add sources.
[platform/framework/web/crosswalk.git] / src / chromeos / dbus / shill_profile_client.h
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.
4
5 #ifndef CHROMEOS_DBUS_SHILL_PROFILE_CLIENT_H_
6 #define CHROMEOS_DBUS_SHILL_PROFILE_CLIENT_H_
7
8 #include <string>
9
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"
16
17 namespace base {
18
19 class Value;
20 class DictionaryValue;
21
22 }  // namespace base
23
24 namespace dbus {
25
26 class ObjectPath;
27
28 }  // namespace dbus
29
30 namespace chromeos {
31
32 class ShillPropertyChangedObserver;
33
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 {
38  public:
39   typedef ShillClientHelper::PropertyChangedHandler PropertyChangedHandler;
40   typedef ShillClientHelper::DictionaryValueCallbackWithoutStatus
41       DictionaryValueCallbackWithoutStatus;
42   typedef ShillClientHelper::ErrorCallback ErrorCallback;
43
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.
48   class TestInterface {
49    public:
50     virtual void AddProfile(const std::string& profile_path,
51                             const std::string& userhash) = 0;
52
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;
60
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;
66
67     // Sets |profiles| to the current list of profile paths.
68     virtual void GetProfilePaths(std::vector<std::string>* profiles) = 0;
69
70    protected:
71     virtual ~TestInterface() {}
72   };
73
74   virtual ~ShillProfileClient();
75
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);
79
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;
84
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;
89
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;
96
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;
103
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;
110
111   // Returns an interface for testing (stub only), or returns NULL.
112   virtual TestInterface* GetTestInterface() = 0;
113
114  protected:
115   friend class ShillProfileClientTest;
116
117   // Create() should be used instead.
118   ShillProfileClient();
119
120  private:
121   DISALLOW_COPY_AND_ASSIGN(ShillProfileClient);
122 };
123
124 }  // namespace chromeos
125
126 #endif  // CHROMEOS_DBUS_SHILL_PROFILE_CLIENT_H_