Commit f9ac141a authored by David Black's avatar David Black Committed by Commit Bot

Use checked observers for Assistant.

This is preferred over unchecked observers.

Bug: b:120097552
Change-Id: Id44822dce375e3400baa336fee3154ad99d18d7f
Reviewed-on: https://chromium-review.googlesource.com/c/1354569
Commit-Queue: David Black <dmblack@google.com>
Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611999}
parent ed79eae3
......@@ -140,7 +140,7 @@ class ASH_EXPORT AssistantController
// The observer list should be initialized early so that sub-controllers may
// register as observers during their construction.
base::ObserverList<AssistantControllerObserver>::Unchecked observers_;
base::ObserverList<AssistantControllerObserver> observers_;
mojo::BindingSet<mojom::AssistantController> assistant_controller_bindings_;
......
......@@ -9,6 +9,7 @@
#include <string>
#include "base/macros.h"
#include "base/observer_list_types.h"
class GURL;
......@@ -20,7 +21,9 @@ enum class DeepLinkType;
} // namespace util
} // namespace assistant
class AssistantControllerObserver {
// A checked observer which receives notification of changes to the
// AssistantController.
class AssistantControllerObserver : public base::CheckedObserver {
public:
// Invoked when the AssistantController has been fully constructed.
virtual void OnAssistantControllerConstructed() {}
......@@ -40,7 +43,7 @@ class AssistantControllerObserver {
protected:
AssistantControllerObserver() = default;
virtual ~AssistantControllerObserver() = default;
~AssistantControllerObserver() override = default;
DISALLOW_COPY_AND_ASSIGN(AssistantControllerObserver);
};
......
......@@ -44,7 +44,7 @@ class AssistantCacheModel {
std::vector<AssistantSuggestionPtr> conversation_starters_;
base::ObserverList<AssistantCacheModelObserver>::Unchecked observers_;
base::ObserverList<AssistantCacheModelObserver> observers_;
DISALLOW_COPY_AND_ASSIGN(AssistantCacheModel);
};
......
......@@ -8,12 +8,14 @@
#include <map>
#include "base/macros.h"
#include "base/observer_list_types.h"
#include "chromeos/services/assistant/public/mojom/assistant.mojom.h"
namespace ash {
// An observer which receives notification of changes to the Assistant cache.
class AssistantCacheModelObserver {
// A checked observer which receives notification of changes to the Assistant
// cache.
class AssistantCacheModelObserver : public base::CheckedObserver {
public:
using AssistantSuggestion = chromeos::assistant::mojom::AssistantSuggestion;
......@@ -22,7 +24,7 @@ class AssistantCacheModelObserver {
const std::map<int, const AssistantSuggestion*>& conversation_starters) {}
protected:
virtual ~AssistantCacheModelObserver() = default;
~AssistantCacheModelObserver() override = default;
};
} // namespace ash
......
......@@ -147,7 +147,7 @@ class AssistantInteractionModel {
std::unique_ptr<AssistantResponse> pending_response_;
std::shared_ptr<AssistantResponse> response_;
base::ObserverList<AssistantInteractionModelObserver>::Unchecked observers_;
base::ObserverList<AssistantInteractionModelObserver> observers_;
DISALLOW_COPY_AND_ASSIGN(AssistantInteractionModel);
};
......
......@@ -10,6 +10,7 @@
#include <vector>
#include "base/macros.h"
#include "base/observer_list_types.h"
namespace ash {
......@@ -19,9 +20,9 @@ enum class InputModality;
enum class InteractionState;
enum class MicState;
// An observer which receives notification of changes to an Assistant
// A checked observer which receives notification of changes to an Assistant
// interaction.
class AssistantInteractionModelObserver {
class AssistantInteractionModelObserver : public base::CheckedObserver {
public:
// Invoked when the interaction state is changed.
virtual void OnInteractionStateChanged(InteractionState interaction_state) {}
......@@ -58,7 +59,7 @@ class AssistantInteractionModelObserver {
protected:
AssistantInteractionModelObserver() = default;
virtual ~AssistantInteractionModelObserver() = default;
~AssistantInteractionModelObserver() override = default;
DISALLOW_COPY_AND_ASSIGN(AssistantInteractionModelObserver);
};
......
......@@ -35,7 +35,7 @@ class AssistantScreenContextModel {
ScreenContextRequestState request_state_ = ScreenContextRequestState::kIdle;
base::ObserverList<AssistantScreenContextModelObserver>::Unchecked observers_;
base::ObserverList<AssistantScreenContextModelObserver> observers_;
DISALLOW_COPY_AND_ASSIGN(AssistantScreenContextModel);
};
......
......@@ -6,12 +6,15 @@
#define ASH_ASSISTANT_MODEL_ASSISTANT_SCREEN_CONTEXT_MODEL_OBSERVER_H_
#include "base/macros.h"
#include "base/observer_list_types.h"
namespace ash {
enum class ScreenContextRequestState;
class AssistantScreenContextModelObserver {
// A checked observer which receives notification of changes to the Assistant
// screen context model state.
class AssistantScreenContextModelObserver : public base::CheckedObserver {
public:
// Invoked when the screen context request state is changed.
virtual void OnScreenContextRequestStateChanged(
......@@ -19,7 +22,7 @@ class AssistantScreenContextModelObserver {
protected:
AssistantScreenContextModelObserver() = default;
virtual ~AssistantScreenContextModelObserver() = default;
~AssistantScreenContextModelObserver() override = default;
DISALLOW_COPY_AND_ASSIGN(AssistantScreenContextModelObserver);
};
......
......@@ -86,7 +86,7 @@ class AssistantUiModel {
AssistantSource entry_point_ = AssistantSource::kUnspecified;
base::ObserverList<AssistantUiModelObserver>::Unchecked observers_;
base::ObserverList<AssistantUiModelObserver> observers_;
// Usable work area for Assistant. Value is only meaningful when Assistant
// UI exists.
......
......@@ -6,6 +6,7 @@
#define ASH_ASSISTANT_MODEL_ASSISTANT_UI_MODEL_OBSERVER_H_
#include "base/macros.h"
#include "base/observer_list_types.h"
#include "ui/gfx/geometry/rect.h"
namespace ash {
......@@ -14,8 +15,9 @@ enum class AssistantSource;
enum class AssistantUiMode;
enum class AssistantVisibility;
// An observer which receives notification of changes to the Assistant UI model.
class AssistantUiModelObserver {
// A checked observer which receives notification of changes to the Assistant UI
// model.
class AssistantUiModelObserver : public base::CheckedObserver {
public:
// Invoked when the UI mode is changed.
virtual void OnUiModeChanged(AssistantUiMode ui_mode) {}
......@@ -34,7 +36,7 @@ class AssistantUiModelObserver {
protected:
AssistantUiModelObserver() = default;
virtual ~AssistantUiModelObserver() = default;
~AssistantUiModelObserver() override = default;
DISALLOW_COPY_AND_ASSIGN(AssistantUiModelObserver);
};
......
......@@ -41,7 +41,7 @@ enum class DialogPlateButtonId {
// DialogPlateObserver ---------------------------------------------------------
class DialogPlateObserver {
class DialogPlateObserver : public base::CheckedObserver {
public:
// Invoked when the dialog plate button identified by |id| is pressed.
virtual void OnDialogPlateButtonPressed(DialogPlateButtonId id) {}
......@@ -50,7 +50,7 @@ class DialogPlateObserver {
virtual void OnDialogPlateContentsCommitted(const std::string& text) {}
protected:
virtual ~DialogPlateObserver() = default;
~DialogPlateObserver() override = default;
};
// DialogPlate -----------------------------------------------------------------
......@@ -124,7 +124,7 @@ class DialogPlate : public views::View,
std::unique_ptr<ui::CallbackLayerAnimationObserver> animation_observer_;
std::unique_ptr<AssistantQueryHistory::Iterator> query_history_iterator_;
base::ObserverList<DialogPlateObserver>::Unchecked observers_;
base::ObserverList<DialogPlateObserver> observers_;
DISALLOW_COPY_AND_ASSIGN(DialogPlate);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment