Index: chrome/browser/notifications/notification_platform_bridge_linux.h |
diff --git a/chrome/browser/notifications/notification_platform_bridge_linux.h b/chrome/browser/notifications/notification_platform_bridge_linux.h |
index 1b6380c769d270eabed7e47030326855b1a79d6f..bf9144fd5f5e75eea4c51a40996e4f5cf7cf7c61 100644 |
--- a/chrome/browser/notifications/notification_platform_bridge_linux.h |
+++ b/chrome/browser/notifications/notification_platform_bridge_linux.h |
@@ -7,8 +7,11 @@ |
#include <gio/gio.h> |
+#include <unordered_map> |
+ |
#include "base/macros.h" |
#include "chrome/browser/notifications/notification_platform_bridge.h" |
+#include "ui/base/glib/glib_util.h" |
class NotificationPlatformBridgeLinux : public NotificationPlatformBridge { |
public: |
@@ -30,7 +33,71 @@ class NotificationPlatformBridgeLinux : public NotificationPlatformBridge { |
const DisplayedNotificationsCallback& callback) const override; |
private: |
- GDBusProxy* const notification_proxy_; |
+ struct NotificationData { |
+ NotificationData(const std::string& notification_id, |
+ const std::string& profile_id, |
+ bool is_incognito, |
+ NotificationPlatformBridgeLinux* platform_bridge); |
+ |
+ ~NotificationData(); |
+ |
+ // The ID used by the notification server. Will be 0 until the |
+ // first "Notify" message completes. |
+ uint32_t dbus_id = 0; |
+ |
+ // Same parameters used by NotificationPlatformBridge::Display(). |
+ std::string notification_id; |
Lei Zhang
2017/04/06 03:59:54
Make the members set via ctor const?
Tom (Use chromium acct)
2017/04/06 05:05:35
Done.
|
+ std::string profile_id; |
+ bool is_incognito; |
Lei Zhang
2017/04/06 03:59:54
This is set but never read from right now. Is this
Tom (Use chromium acct)
2017/04/06 05:05:35
It will be used by GetDisplayed()
|
+ |
+ NotificationPlatformBridgeLinux* platform_bridge; |
+ |
+ // Used to cancel the initial "Notify" message so we don't call |
+ // NotificationPlatformBridgeLinux::OnNotifyComplete() with a |
+ // destroyed Notification. |
+ ScopedGObject<GCancellable> cancellable; |
+ |
+ // If not null, the data to update the notification with once |
+ // |dbus_id| becomes available. |
+ std::unique_ptr<Notification> update_data; |
+ NotificationCommon::Type update_type; |
+ |
+ // If true, indicates the notification should be closed once |
+ // |dbus_id| becomes available. |
+ bool should_close = false; |
+ }; |
+ |
+ // Callback used by GLib when the "Notify" message completes. |
Lei Zhang
2017/04/06 03:59:54
... the first time.
Tom (Use chromium acct)
2017/04/06 05:05:35
Done.
|
+ friend void OnNotifyComplete(GObject* source_object, |
+ GAsyncResult* result, |
+ gpointer user_data); |
+ |
+ // Called from ::OnNotifyComplete(). |
+ void OnNotifyComplete(NotificationData* data, GVariant* value); |
+ |
+ ScopedGObject<GDBusProxy> notification_proxy_; |
+ |
+ // A std::set<std::unique_ptr<T>> doesn't work well because |
Lei Zhang
2017/04/06 03:59:54
You'd need something like the ListValue::Find() im
Tom (Use chromium acct)
2017/04/06 05:05:35
Acknowledged.
|
+ // eg. std::set::erase(T) would require a std::unique_ptr<T> |
+ // argument, so the data would get double-destructed. |
+ template <typename T> |
+ using UnorderedUniqueSet = std::unordered_map<T*, std::unique_ptr<T>>; |
+ |
+ UnorderedUniqueSet<NotificationData> notifications_; |
+ |
+ // Makes the "Notify" call to D-Bus. |
+ void NotifyNow(uint32_t dbus_id, |
+ NotificationCommon::Type notification_type, |
+ const Notification& notification, |
+ GCancellable* cancellable, |
+ GAsyncReadyCallback callback, |
+ gpointer user_data); |
+ |
+ // Makes the "CloseNotification" call to D-Bus. |
+ void CloseNow(uint32_t dbus_id); |
+ |
+ NotificationData* FindNotificationData(const std::string& notification_id, |
+ const std::string& profile_id); |
DISALLOW_COPY_AND_ASSIGN(NotificationPlatformBridgeLinux); |
}; |