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

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

Issue 10170020: Rework chromeos::FlimflamDevice/ServiceClient with CallMethodWithErrorCallback (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROMEOS_DBUS_FLIMFLAM_CLIENT_HELPER_H_ 5 #ifndef CHROMEOS_DBUS_FLIMFLAM_CLIENT_HELPER_H_
6 #define CHROMEOS_DBUS_FLIMFLAM_CLIENT_HELPER_H_ 6 #define CHROMEOS_DBUS_FLIMFLAM_CLIENT_HELPER_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "chromeos/dbus/blocking_method_caller.h" 13 #include "chromeos/dbus/blocking_method_caller.h"
14 #include "chromeos/dbus/dbus_method_call_status.h" 14 #include "chromeos/dbus/dbus_method_call_status.h"
15 15
16 namespace base { 16 namespace base {
17 17
18 class Value; 18 class Value;
19 class DictionaryValue; 19 class DictionaryValue;
20 20
21 } // namespace base 21 } // namespace base
22 22
23 namespace dbus { 23 namespace dbus {
24 24
25 class Bus; 25 class Bus;
26 class ErrorResponse;
26 class MessageWriter; 27 class MessageWriter;
27 class MethodCall; 28 class MethodCall;
28 class ObjectPath; 29 class ObjectPath;
29 class ObjectProxy; 30 class ObjectProxy;
30 class Response; 31 class Response;
31 class Signal; 32 class Signal;
32 33
33 } // namespace dbus 34 } // namespace dbus
34 35
35 namespace chromeos { 36 namespace chromeos {
(...skipping 11 matching lines...) Expand all
47 // A callback to handle responses for methods with ObjectPath results. 48 // A callback to handle responses for methods with ObjectPath results.
48 typedef base::Callback<void( 49 typedef base::Callback<void(
49 DBusMethodCallStatus call_status, 50 DBusMethodCallStatus call_status,
50 const dbus::ObjectPath& result)> ObjectPathCallback; 51 const dbus::ObjectPath& result)> ObjectPathCallback;
51 52
52 // A callback to handle responses for methods with DictionaryValue results. 53 // A callback to handle responses for methods with DictionaryValue results.
53 typedef base::Callback<void( 54 typedef base::Callback<void(
54 DBusMethodCallStatus call_status, 55 DBusMethodCallStatus call_status,
55 const base::DictionaryValue& result)> DictionaryValueCallback; 56 const base::DictionaryValue& result)> DictionaryValueCallback;
56 57
58 // A callback to handle erros for method call.
59 typedef base::Callback<void(const std::string& error_name,
60 const std::string& error_message)> ErrorCallback;
61
57 FlimflamClientHelper(dbus::Bus* bus, dbus::ObjectProxy* proxy); 62 FlimflamClientHelper(dbus::Bus* bus, dbus::ObjectProxy* proxy);
58 63
59 virtual ~FlimflamClientHelper(); 64 virtual ~FlimflamClientHelper();
60 65
61 // Sets PropertyChanged signal handler. 66 // Sets PropertyChanged signal handler.
62 void SetPropertyChangedHandler(const PropertyChangedHandler& handler); 67 void SetPropertyChangedHandler(const PropertyChangedHandler& handler);
63 68
64 // Resets PropertyChanged signal handler. 69 // Resets PropertyChanged signal handler.
65 void ResetPropertyChangedHandler(); 70 void ResetPropertyChangedHandler();
66 71
67 // Starts monitoring PropertyChanged signal. 72 // Starts monitoring PropertyChanged signal.
68 void MonitorPropertyChanged(const std::string& interface_name); 73 void MonitorPropertyChanged(const std::string& interface_name);
69 74
70 // Calls a method without results. 75 // Calls a method without results.
71 void CallVoidMethod(dbus::MethodCall* method_call, 76 void CallVoidMethod(dbus::MethodCall* method_call,
72 const VoidCallback& callback); 77 const VoidCallback& callback);
73 78
74 // Calls a method with an object path result. 79 // Calls a method with an object path result.
75 void CallObjectPathMethod(dbus::MethodCall* method_call, 80 void CallObjectPathMethod(dbus::MethodCall* method_call,
76 const ObjectPathCallback& callback); 81 const ObjectPathCallback& callback);
77 82
78 // Calls a method with a dictionary value result. 83 // Calls a method with a dictionary value result.
79 void CallDictionaryValueMethod(dbus::MethodCall* method_call, 84 void CallDictionaryValueMethod(dbus::MethodCall* method_call,
80 const DictionaryValueCallback& callback); 85 const DictionaryValueCallback& callback);
81 86
87 // Calls a method without results with error callback.
88 void CallVoidMethodWithErrorCallback(dbus::MethodCall* method_call,
89 const base::Closure& callback,
90 const ErrorCallback& error_callback);
91
82 // DEPRECATED DO NOT USE: Calls a method without results. 92 // DEPRECATED DO NOT USE: Calls a method without results.
83 bool CallVoidMethodAndBlock(dbus::MethodCall* method_call); 93 bool CallVoidMethodAndBlock(dbus::MethodCall* method_call);
84 94
85 // DEPRECATED DO NOT USE: Calls a method with an object path result. 95 // DEPRECATED DO NOT USE: Calls a method with an object path result.
86 dbus::ObjectPath CallObjectPathMethodAndBlock(dbus::MethodCall* method_call); 96 dbus::ObjectPath CallObjectPathMethodAndBlock(dbus::MethodCall* method_call);
87 97
88 // DEPRECATED DO NOT USE: Calls a method with a dictionary value result. 98 // DEPRECATED DO NOT USE: Calls a method with a dictionary value result.
89 // The caller is responsible to delete the result. 99 // The caller is responsible to delete the result.
90 // This method returns NULL when method call fails. 100 // This method returns NULL when method call fails.
91 base::DictionaryValue* CallDictionaryValueMethodAndBlock( 101 base::DictionaryValue* CallDictionaryValueMethodAndBlock(
(...skipping 17 matching lines...) Expand all
109 void OnVoidMethod(const VoidCallback& callback, dbus::Response* response); 119 void OnVoidMethod(const VoidCallback& callback, dbus::Response* response);
110 120
111 // Handles responses for methods with ObjectPath results. 121 // Handles responses for methods with ObjectPath results.
112 void OnObjectPathMethod(const ObjectPathCallback& callback, 122 void OnObjectPathMethod(const ObjectPathCallback& callback,
113 dbus::Response* response); 123 dbus::Response* response);
114 124
115 // Handles responses for methods with DictionaryValue results. 125 // Handles responses for methods with DictionaryValue results.
116 void OnDictionaryValueMethod(const DictionaryValueCallback& callback, 126 void OnDictionaryValueMethod(const DictionaryValueCallback& callback,
117 dbus::Response* response); 127 dbus::Response* response);
118 128
129 // Handles responses for methods without results.
130 // Used by CallVoidMethodWithErrorCallback().
131 void OnVoidMethodWithErrorCallback(const base::Closure& callback,
132 dbus::Response* response);
133
134 // Handles errors for method calls.
135 void OnError(const ErrorCallback& error_callback,
136 dbus::ErrorResponse* response);
137
119 base::WeakPtrFactory<FlimflamClientHelper> weak_ptr_factory_; 138 base::WeakPtrFactory<FlimflamClientHelper> weak_ptr_factory_;
120 // TODO(hashimoto): Remove this when we no longer need to make blocking calls. 139 // TODO(hashimoto): Remove this when we no longer need to make blocking calls.
121 BlockingMethodCaller blocking_method_caller_; 140 BlockingMethodCaller blocking_method_caller_;
122 dbus::ObjectProxy* proxy_; 141 dbus::ObjectProxy* proxy_;
123 PropertyChangedHandler property_changed_handler_; 142 PropertyChangedHandler property_changed_handler_;
124 143
125 DISALLOW_COPY_AND_ASSIGN(FlimflamClientHelper); 144 DISALLOW_COPY_AND_ASSIGN(FlimflamClientHelper);
126 }; 145 };
127 146
128 } // namespace chromeos 147 } // namespace chromeos
129 148
130 #endif // CHROMEOS_DBUS_FLIMFLAM_CLIENT_HELPER_H_ 149 #endif // CHROMEOS_DBUS_FLIMFLAM_CLIENT_HELPER_H_
OLDNEW
« no previous file with comments | « no previous file | chromeos/dbus/flimflam_client_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698