| 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 CHROMEOS_DBUS_FLIMFLAM_CLIENT_HELPER_H_ | 5 #ifndef CHROMEOS_DBUS_SHILL_CLIENT_HELPER_H_ |
| 6 #define CHROMEOS_DBUS_FLIMFLAM_CLIENT_HELPER_H_ | 6 #define CHROMEOS_DBUS_SHILL_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 { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 28 class MethodCall; | 28 class MethodCall; |
| 29 class ObjectPath; | 29 class ObjectPath; |
| 30 class ObjectProxy; | 30 class ObjectProxy; |
| 31 class Response; | 31 class Response; |
| 32 class Signal; | 32 class Signal; |
| 33 | 33 |
| 34 } // namespace dbus | 34 } // namespace dbus |
| 35 | 35 |
| 36 namespace chromeos { | 36 namespace chromeos { |
| 37 | 37 |
| 38 // A class to help implement Flimflam clients. | 38 // A class to help implement Shill clients. |
| 39 class FlimflamClientHelper { | 39 class ShillClientHelper { |
| 40 public: | 40 public: |
| 41 // A callback to handle PropertyChanged signals. | 41 // A callback to handle PropertyChanged signals. |
| 42 typedef base::Callback<void(const std::string& name, | 42 typedef base::Callback<void(const std::string& name, |
| 43 const base::Value& value)> PropertyChangedHandler; | 43 const base::Value& value)> PropertyChangedHandler; |
| 44 | 44 |
| 45 // A callback to handle responses for methods with DictionaryValue results. | 45 // A callback to handle responses for methods with DictionaryValue results. |
| 46 typedef base::Callback<void( | 46 typedef base::Callback<void( |
| 47 DBusMethodCallStatus call_status, | 47 DBusMethodCallStatus call_status, |
| 48 const base::DictionaryValue& result)> DictionaryValueCallback; | 48 const base::DictionaryValue& result)> DictionaryValueCallback; |
| 49 | 49 |
| 50 // A callback to handle responses for methods with DictionaryValue reuslts. | 50 // A callback to handle responses for methods with DictionaryValue reuslts. |
| 51 // This is used by CallDictionaryValueMethodWithErrorCallback. | 51 // This is used by CallDictionaryValueMethodWithErrorCallback. |
| 52 typedef base::Callback<void(const base::DictionaryValue& result | 52 typedef base::Callback<void(const base::DictionaryValue& result |
| 53 )> DictionaryValueCallbackWithoutStatus; | 53 )> DictionaryValueCallbackWithoutStatus; |
| 54 | 54 |
| 55 // A callback to handle erros for method call. | 55 // A callback to handle erros for method call. |
| 56 typedef base::Callback<void(const std::string& error_name, | 56 typedef base::Callback<void(const std::string& error_name, |
| 57 const std::string& error_message)> ErrorCallback; | 57 const std::string& error_message)> ErrorCallback; |
| 58 | 58 |
| 59 FlimflamClientHelper(dbus::Bus* bus, dbus::ObjectProxy* proxy); | 59 ShillClientHelper(dbus::Bus* bus, dbus::ObjectProxy* proxy); |
| 60 | 60 |
| 61 virtual ~FlimflamClientHelper(); | 61 virtual ~ShillClientHelper(); |
| 62 | 62 |
| 63 // Sets PropertyChanged signal handler. | 63 // Sets PropertyChanged signal handler. |
| 64 void SetPropertyChangedHandler(const PropertyChangedHandler& handler); | 64 void SetPropertyChangedHandler(const PropertyChangedHandler& handler); |
| 65 | 65 |
| 66 // Resets PropertyChanged signal handler. | 66 // Resets PropertyChanged signal handler. |
| 67 void ResetPropertyChangedHandler(); | 67 void ResetPropertyChangedHandler(); |
| 68 | 68 |
| 69 // Starts monitoring PropertyChanged signal. | 69 // Starts monitoring PropertyChanged signal. |
| 70 void MonitorPropertyChanged(const std::string& interface_name); | 70 void MonitorPropertyChanged(const std::string& interface_name); |
| 71 | 71 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 void OnError(const ErrorCallback& error_callback, | 146 void OnError(const ErrorCallback& error_callback, |
| 147 dbus::ErrorResponse* response); | 147 dbus::ErrorResponse* response); |
| 148 | 148 |
| 149 // TODO(hashimoto): Remove this when we no longer need to make blocking calls. | 149 // TODO(hashimoto): Remove this when we no longer need to make blocking calls. |
| 150 BlockingMethodCaller blocking_method_caller_; | 150 BlockingMethodCaller blocking_method_caller_; |
| 151 dbus::ObjectProxy* proxy_; | 151 dbus::ObjectProxy* proxy_; |
| 152 PropertyChangedHandler property_changed_handler_; | 152 PropertyChangedHandler property_changed_handler_; |
| 153 | 153 |
| 154 // Note: This should remain the last member so it'll be destroyed and | 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. | 155 // invalidate its weak pointers before any other members are destroyed. |
| 156 base::WeakPtrFactory<FlimflamClientHelper> weak_ptr_factory_; | 156 base::WeakPtrFactory<ShillClientHelper> weak_ptr_factory_; |
| 157 | 157 |
| 158 DISALLOW_COPY_AND_ASSIGN(FlimflamClientHelper); | 158 DISALLOW_COPY_AND_ASSIGN(ShillClientHelper); |
| 159 }; | 159 }; |
| 160 | 160 |
| 161 } // namespace chromeos | 161 } // namespace chromeos |
| 162 | 162 |
| 163 #endif // CHROMEOS_DBUS_FLIMFLAM_CLIENT_HELPER_H_ | 163 #endif // CHROMEOS_DBUS_SHILL_CLIENT_HELPER_H_ |
| OLD | NEW |