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

Unified Diff: ui/arc/notification/arc_notification_manager.cc

Issue 1596663002: arc-bridge: Introduce the ArcService class (Closed) Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: Addressed feedback Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: ui/arc/notification/arc_notification_manager.cc
diff --git a/ui/arc/notification/arc_notification_manager.cc b/ui/arc/notification/arc_notification_manager.cc
index 91b8c269b2517fc2bced797f96c0d924b6744f94..baa84eab7fc2ce58a420135e9a3ef034558f5c7a 100644
--- a/ui/arc/notification/arc_notification_manager.cc
+++ b/ui/arc/notification/arc_notification_manager.cc
@@ -9,27 +9,29 @@
namespace arc {
-ArcNotificationManager::ArcNotificationManager(ArcBridgeService* arc_bridge,
- const AccountId& main_profile_id)
- : arc_bridge_(arc_bridge),
+ArcNotificationManager::ArcNotificationManager(
+ ArcBridgeService* arc_bridge_service,
+ const AccountId& main_profile_id)
+ : arc_bridge_service_(arc_bridge_service),
main_profile_id_(main_profile_id),
binding_(this) {
- // This must be initialized after ArcBridgeService.
- DCHECK(arc_bridge_);
- DCHECK_EQ(arc_bridge_, ArcBridgeService::Get());
- arc_bridge_->AddObserver(this);
+ DCHECK(arc_bridge_service_);
+ arc_bridge_service_->AddObserver(this);
+
+ // If NotificationsInstance was ready before we AddObserver(), we won't get
+ // OnNotificationsInstanceReady events. For such case, we have to call it
+ // explicitly.
+ if (arc_bridge_service_->notifications_instance())
+ OnNotificationsInstanceReady();
}
ArcNotificationManager::~ArcNotificationManager() {
- // This should be free'd before ArcBridgeService.
- DCHECK(ArcBridgeService::Get());
- DCHECK_EQ(arc_bridge_, ArcBridgeService::Get());
- arc_bridge_->RemoveObserver(this);
+ arc_bridge_service_->RemoveObserver(this);
}
void ArcNotificationManager::OnNotificationsInstanceReady() {
NotificationsInstance* notifications_instance =
- arc_bridge_->notifications_instance();
+ arc_bridge_service_->notifications_instance();
if (!notifications_instance) {
VLOG(2) << "Request to refresh app list when bridge service is not ready.";
return;
@@ -75,7 +77,7 @@ void ArcNotificationManager::SendNotificationRemovedFromChrome(
scoped_ptr<ArcNotificationItem> item(items_.take_and_erase(it));
- arc_bridge_->notifications_instance()->SendNotificationEventToAndroid(
+ arc_bridge_service_->notifications_instance()->SendNotificationEventToAndroid(
key, ARC_NOTIFICATION_EVENT_CLOSED);
}
@@ -87,7 +89,7 @@ void ArcNotificationManager::SendNotificationClickedOnChrome(
return;
}
- arc_bridge_->notifications_instance()->SendNotificationEventToAndroid(
+ arc_bridge_service_->notifications_instance()->SendNotificationEventToAndroid(
key, ARC_NOTIFICATION_EVENT_BODY_CLICKED);
}
« components/arc/arc_service.h ('K') | « ui/arc/notification/arc_notification_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698