buffet: Replace CallbackList with vector<Callback>
We don't remove callback at runtime, so callbacks on WeakPtr
are enough there.
BUG=brillo:697
TEST=FEATURE=test emerge-gizmo buffet
Change-Id: I02573979b208d0e9df62e59f4bb3bbec92608b71
Reviewed-on: https://chromium-review.googlesource.com/270279
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
Commit-Queue: Vitaly Buka <vitalybuka@chromium.org>
Tested-by: Vitaly Buka <vitalybuka@chromium.org>
diff --git a/buffet/commands/command_manager.h b/buffet/commands/command_manager.h
index 072d055..b2b9eba 100644
--- a/buffet/commands/command_manager.h
+++ b/buffet/commands/command_manager.h
@@ -10,7 +10,6 @@
#include <vector>
#include <base/callback.h>
-#include <base/callback_list.h>
#include <base/files/file_path.h>
#include <base/macros.h>
#include <base/memory/weak_ptr.h>
@@ -35,13 +34,6 @@
// dispatched to the device.
class CommandManager final {
public:
- // A token given by CommandManager in response to AddOnCommandDefChanged().
- // When the CallbackToken is destroyed, the registered notification
- // callback associated with it will automatically be removed from the command
- // manager's callback list.
- using CallbackToken =
- std::unique_ptr<base::CallbackList<void()>::Subscription>;
-
CommandManager();
explicit CommandManager(
const base::WeakPtr<chromeos::dbus_utils::ExportedObjectManager>&
@@ -50,9 +42,8 @@
explicit CommandManager(CommandDispachInterface* dispatch_interface);
// Sets callback which is called when command definitions is changed.
- CallbackToken AddOnCommandDefChanged(
- const base::Closure& callback) WARN_UNUSED_RESULT {
- return CallbackToken{on_command_changed_.Add(callback).release()};
+ void AddOnCommandDefChanged(const base::Closure& callback) {
+ return on_command_changed_.push_back(callback);
}
// Returns the command definitions for the device.
@@ -114,7 +105,7 @@
CommandDictionary dictionary_; // Command definitions/schemas.
CommandQueue command_queue_;
DBusCommandDispacher command_dispatcher_;
- base::CallbackList<void()> on_command_changed_;
+ std::vector<base::Callback<void()>> on_command_changed_;
DISALLOW_COPY_AND_ASSIGN(CommandManager);
};