Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(106)

Side by Side Diff: chromeos/dbus/flimflam_client_helper.h

Issue 10915106: Renaming instances of "flimflam" with "shill", now that we're only (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Upload after merge Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chromeos/dbus/dbus_thread_manager.cc ('k') | chromeos/dbus/flimflam_client_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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_FLIMFLAM_CLIENT_HELPER_H_
6 #define CHROMEOS_DBUS_FLIMFLAM_CLIENT_HELPER_H_
7
8 #include <string>
9
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "base/memory/weak_ptr.h"
13 #include "chromeos/dbus/blocking_method_caller.h"
14 #include "chromeos/dbus/dbus_method_call_status.h"
15
16 namespace base {
17
18 class Value;
19 class DictionaryValue;
20
21 } // namespace base
22
23 namespace dbus {
24
25 class Bus;
26 class ErrorResponse;
27 class MessageWriter;
28 class MethodCall;
29 class ObjectPath;
30 class ObjectProxy;
31 class Response;
32 class Signal;
33
34 } // namespace dbus
35
36 namespace chromeos {
37
38 // A class to help implement Flimflam clients.
39 class FlimflamClientHelper {
40 public:
41 // A callback to handle PropertyChanged signals.
42 typedef base::Callback<void(const std::string& name,
43 const base::Value& value)> PropertyChangedHandler;
44
45 // A callback to handle responses for methods with DictionaryValue results.
46 typedef base::Callback<void(
47 DBusMethodCallStatus call_status,
48 const base::DictionaryValue& result)> DictionaryValueCallback;
49
50 // A callback to handle responses for methods with DictionaryValue reuslts.
51 // This is used by CallDictionaryValueMethodWithErrorCallback.
52 typedef base::Callback<void(const base::DictionaryValue& result
53 )> DictionaryValueCallbackWithoutStatus;
54
55 // A callback to handle erros for method call.
56 typedef base::Callback<void(const std::string& error_name,
57 const std::string& error_message)> ErrorCallback;
58
59 FlimflamClientHelper(dbus::Bus* bus, dbus::ObjectProxy* proxy);
60
61 virtual ~FlimflamClientHelper();
62
63 // Sets PropertyChanged signal handler.
64 void SetPropertyChangedHandler(const PropertyChangedHandler& handler);
65
66 // Resets PropertyChanged signal handler.
67 void ResetPropertyChangedHandler();
68
69 // Starts monitoring PropertyChanged signal.
70 void MonitorPropertyChanged(const std::string& interface_name);
71
72 // Calls a method without results.
73 void CallVoidMethod(dbus::MethodCall* method_call,
74 const VoidDBusMethodCallback& callback);
75
76 // Calls a method with an object path result.
77 void CallObjectPathMethod(dbus::MethodCall* method_call,
78 const ObjectPathDBusMethodCallback& callback);
79
80 // Calls a method with a dictionary value result.
81 void CallDictionaryValueMethod(dbus::MethodCall* method_call,
82 const DictionaryValueCallback& callback);
83
84 // Calls a method without results with error callback.
85 void CallVoidMethodWithErrorCallback(dbus::MethodCall* method_call,
86 const base::Closure& callback,
87 const ErrorCallback& error_callback);
88
89 // Calls a method with a dictionary value result with error callback.
90 void CallDictionaryValueMethodWithErrorCallback(
91 dbus::MethodCall* method_call,
92 const DictionaryValueCallbackWithoutStatus& callback,
93 const ErrorCallback& error_callback);
94
95 // DEPRECATED DO NOT USE: Calls a method without results.
96 bool CallVoidMethodAndBlock(dbus::MethodCall* method_call);
97
98 // DEPRECATED DO NOT USE: Calls a method with an object path result.
99 dbus::ObjectPath CallObjectPathMethodAndBlock(dbus::MethodCall* method_call);
100
101 // DEPRECATED DO NOT USE: Calls a method with a dictionary value result.
102 // The caller is responsible to delete the result.
103 // This method returns NULL when method call fails.
104 base::DictionaryValue* CallDictionaryValueMethodAndBlock(
105 dbus::MethodCall* method_call);
106
107 // Appends the value (basic types and string-to-string dictionary) to the
108 // writer as a variant.
109 static void AppendValueDataAsVariant(dbus::MessageWriter* writer,
110 const base::Value& value);
111
112 private:
113 // Handles the result of signal connection setup.
114 void OnSignalConnected(const std::string& interface,
115 const std::string& signal,
116 bool success);
117
118 // Handles PropertyChanged signal.
119 void OnPropertyChanged(dbus::Signal* signal);
120
121 // Handles responses for methods without results.
122 void OnVoidMethod(const VoidDBusMethodCallback& callback,
123 dbus::Response* response);
124
125 // Handles responses for methods with ObjectPath results.
126 void OnObjectPathMethod(const ObjectPathDBusMethodCallback& callback,
127 dbus::Response* response);
128
129 // Handles responses for methods with DictionaryValue results.
130 void OnDictionaryValueMethod(const DictionaryValueCallback& callback,
131 dbus::Response* response);
132
133 // Handles responses for methods without results.
134 // Used by CallVoidMethodWithErrorCallback().
135 void OnVoidMethodWithErrorCallback(const base::Closure& callback,
136 dbus::Response* response);
137
138 // Handles responses for methods with DictionaryValue results.
139 // Used by CallDictionaryValueMethodWithErrorCallback().
140 void OnDictionaryValueMethodWithErrorCallback(
141 const DictionaryValueCallbackWithoutStatus& callback,
142 const ErrorCallback& error_callback,
143 dbus::Response* response);
144
145 // Handles errors for method calls.
146 void OnError(const ErrorCallback& error_callback,
147 dbus::ErrorResponse* response);
148
149 // TODO(hashimoto): Remove this when we no longer need to make blocking calls.
150 BlockingMethodCaller blocking_method_caller_;
151 dbus::ObjectProxy* proxy_;
152 PropertyChangedHandler property_changed_handler_;
153
154 // Note: This should remain the last member so it'll be destroyed and
155 // invalidate its weak pointers before any other members are destroyed.
156 base::WeakPtrFactory<FlimflamClientHelper> weak_ptr_factory_;
157
158 DISALLOW_COPY_AND_ASSIGN(FlimflamClientHelper);
159 };
160
161 } // namespace chromeos
162
163 #endif // CHROMEOS_DBUS_FLIMFLAM_CLIENT_HELPER_H_
OLDNEW
« no previous file with comments | « chromeos/dbus/dbus_thread_manager.cc ('k') | chromeos/dbus/flimflam_client_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698