Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 DBUS_OBJECT_PROXY_H_ | 5 #ifndef DBUS_OBJECT_PROXY_H_ |
| 6 #define DBUS_OBJECT_PROXY_H_ | 6 #define DBUS_OBJECT_PROXY_H_ |
| 7 | 7 |
| 8 #include <dbus/dbus.h> | 8 #include <dbus/dbus.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 207 void OnConnected(OnConnectedCallback on_connected_callback, | 207 void OnConnected(OnConnectedCallback on_connected_callback, |
| 208 const std::string& interface_name, | 208 const std::string& interface_name, |
| 209 const std::string& signal_name, | 209 const std::string& signal_name, |
| 210 bool success); | 210 bool success); |
| 211 | 211 |
| 212 // Handles the incoming request messages and dispatches to the signal | 212 // Handles the incoming request messages and dispatches to the signal |
| 213 // callbacks. | 213 // callbacks. |
| 214 DBusHandlerResult HandleMessage(DBusConnection* connection, | 214 DBusHandlerResult HandleMessage(DBusConnection* connection, |
| 215 DBusMessage* raw_message); | 215 DBusMessage* raw_message); |
| 216 | 216 |
| 217 // Verifies the sender, checks if we know about the signal, and invokes the | |
| 218 // callback if any. | |
|
satorux1
2012/10/25 08:56:23
callback if any -> callback associated with the si
Haruki Sato
2012/10/26 05:03:24
Removed method.
| |
| 219 DBusHandlerResult VerifySenderAndDispatch(scoped_ptr<dbus::Signal> signal); | |
| 220 | |
| 217 // Runs the method. Helper function for HandleMessage(). | 221 // Runs the method. Helper function for HandleMessage(). |
| 218 void RunMethod(base::TimeTicks start_time, | 222 void RunMethod(base::TimeTicks start_time, |
| 219 SignalCallback signal_callback, | 223 SignalCallback signal_callback, |
| 220 Signal* signal); | 224 Signal* signal); |
| 221 | 225 |
| 222 // Redirects the function call to HandleMessage(). | 226 // Redirects the function call to HandleMessage(). |
| 223 static DBusHandlerResult HandleMessageThunk(DBusConnection* connection, | 227 static DBusHandlerResult HandleMessageThunk(DBusConnection* connection, |
| 224 DBusMessage* raw_message, | 228 DBusMessage* raw_message, |
| 225 void* user_data); | 229 void* user_data); |
| 226 | 230 |
| 227 // Helper method for logging response errors appropriately. | 231 // Helper method for logging response errors appropriately. |
| 228 void LogMethodCallFailure(const base::StringPiece& interface_name, | 232 void LogMethodCallFailure(const base::StringPiece& interface_name, |
| 229 const base::StringPiece& method_name, | 233 const base::StringPiece& method_name, |
| 230 const base::StringPiece& error_name, | 234 const base::StringPiece& error_name, |
| 231 const base::StringPiece& error_message) const; | 235 const base::StringPiece& error_message) const; |
| 232 | 236 |
| 233 // Used as ErrorCallback by CallMethod(). | 237 // Used as ErrorCallback by CallMethod(). |
| 234 void OnCallMethodError(const std::string& interface_name, | 238 void OnCallMethodError(const std::string& interface_name, |
| 235 const std::string& method_name, | 239 const std::string& method_name, |
| 236 ResponseCallback response_callback, | 240 ResponseCallback response_callback, |
| 237 ErrorResponse* error_response); | 241 ErrorResponse* error_response); |
| 238 | 242 |
| 243 // Adds the match rule to the bus and associate the callback with the signal. | |
| 244 bool AddMatchRuleWithCallback(const std::string& match_rule, | |
| 245 const std::string& absolute_signal_name, | |
| 246 SignalCallback signal_callback); | |
| 247 | |
| 248 // Adds the match rule to the bus so that HandleMessage can see the signal. | |
| 249 bool AddMatchRuleWithoutCallback(const std::string& match_rule, | |
| 250 const std::string& absolute_signal_name); | |
| 251 | |
| 252 // Calls D-Bus's GetNameOwner method asynchronously to update the owner of | |
| 253 // |service_name_|. |pending_signal| will be processed after receiving the | |
| 254 // response for GetNameOwner. If |pending_signal| is NULL, it just update | |
| 255 // the owner information. | |
| 256 DBusHandlerResult UpdateNameOwnerAsync(scoped_ptr<Signal> pending_signal); | |
| 257 | |
| 258 // Handles NameOwnerChanged signal from D-Bus's special message bus. | |
| 259 DBusHandlerResult HandleNameOwnerChanged(dbus::Signal* signal); | |
| 260 | |
| 261 // Helper Processes the response of GetNameOwner method call. | |
| 262 void OnGetNameOwner(Signal* signal, Response* callback); | |
| 263 | |
| 264 // Helper function for OnGetNameOwner. | |
| 265 void OnGetNameOwnerOnDbusThread(Signal* signal, Response* callback); | |
| 266 | |
| 267 // Processes the error response of GetNameOwner method call. | |
| 268 void OnGetNameOwnerError(Signal* signal, ErrorResponse* callback); | |
| 269 | |
| 270 // Helper function for OnGetNameOwnerError. | |
| 271 void OnGetNameOwnerErrorOnDbusThread(Signal* signal, ErrorResponse* callback); | |
| 272 | |
| 239 scoped_refptr<Bus> bus_; | 273 scoped_refptr<Bus> bus_; |
| 240 std::string service_name_; | 274 std::string service_name_; |
| 241 ObjectPath object_path_; | 275 ObjectPath object_path_; |
| 242 | 276 |
| 243 // True if the message filter was added. | 277 // True if the message filter was added. |
| 244 bool filter_added_; | 278 bool filter_added_; |
| 245 | 279 |
| 246 // The method table where keys are absolute signal names (i.e. interface | 280 // The method table where keys are absolute signal names (i.e. interface |
| 247 // name + signal name), and values are the corresponding callbacks. | 281 // name + signal name), and values are the corresponding callbacks. |
| 248 typedef std::map<std::string, SignalCallback> MethodTable; | 282 typedef std::map<std::string, SignalCallback> MethodTable; |
| 249 MethodTable method_table_; | 283 MethodTable method_table_; |
| 250 | 284 |
| 251 std::set<std::string> match_rules_; | 285 std::set<std::string> match_rules_; |
| 252 | 286 |
| 253 const bool ignore_service_unknown_errors_; | 287 const bool ignore_service_unknown_errors_; |
| 254 | 288 |
| 289 // Known name owner of the well-known bus name represnted by |service_name_|. | |
| 290 std::string service_name_owner_; | |
| 291 | |
| 255 DISALLOW_COPY_AND_ASSIGN(ObjectProxy); | 292 DISALLOW_COPY_AND_ASSIGN(ObjectProxy); |
| 256 }; | 293 }; |
| 257 | 294 |
| 258 } // namespace dbus | 295 } // namespace dbus |
| 259 | 296 |
| 260 #endif // DBUS_OBJECT_PROXY_H_ | 297 #endif // DBUS_OBJECT_PROXY_H_ |
| OLD | NEW |