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

Unified Diff: chrome/browser/notifications/notification_platform_bridge_linux.h

Issue 2821533003: Refactor NotificationPlatformBridgeLinux (Closed)
Patch Set: Fix icon file getting prematurely deleted Created 3 years, 8 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: 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 c63e1db1c42e9cd9d2ac62998dc3ba410d261c41..64cbde7e4eba453a1f9cda478ea5b4df05645a18 100644
--- a/chrome/browser/notifications/notification_platform_bridge_linux.h
+++ b/chrome/browser/notifications/notification_platform_bridge_linux.h
@@ -5,22 +5,14 @@
#ifndef CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_LINUX_H_
#define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_PLATFORM_BRIDGE_LINUX_H_
-#include <gio/gio.h>
-
#include <unordered_map>
#include "base/macros.h"
-#include "base/memory/weak_ptr.h"
#include "chrome/browser/notifications/notification_platform_bridge.h"
-#include "content/public/browser/notification_observer.h"
-#include "content/public/browser/notification_registrar.h"
-#include "ui/base/glib/glib_signal.h"
-#include "ui/base/glib/scoped_gobject.h"
-class NotificationPlatformBridgeLinux : public NotificationPlatformBridge,
- public content::NotificationObserver {
+class NotificationPlatformBridgeLinux : public NotificationPlatformBridge {
public:
- explicit NotificationPlatformBridgeLinux(GDBusProxy* notification_proxy);
+ NotificationPlatformBridgeLinux();
~NotificationPlatformBridgeLinux() override;
@@ -37,71 +29,14 @@ class NotificationPlatformBridgeLinux : public NotificationPlatformBridge,
bool incognito,
const DisplayedNotificationsCallback& callback) const override;
- // Called from NotifyCompleteReceiver().
- void NotifyCompleteInternal(gpointer user_data, GVariant* value);
+ // Waits until the D-Bus connection has been created. Returns true
+ // if the connection was successful.
+ bool BlockUntilReady();
private:
- struct NotificationData;
- struct ResourceFiles;
+ class NativeNotificationThread;
- // content::NotificationObserver:
- void Observe(int type,
- const content::NotificationSource& source,
- const content::NotificationDetails& details) override;
-
- // Sets up a task to call NotifyNow() after an IO thread writes the
- // necessary resource files.
- void Notify(const Notification& notification,
- NotificationData* data,
- GAsyncReadyCallback callback,
- gpointer user_data);
-
- // Makes the "Notify" call to D-Bus.
- void NotifyNow(const Notification& notification,
- base::WeakPtr<NotificationData> data,
- GAsyncReadyCallback callback,
- gpointer user_data,
- std::unique_ptr<ResourceFiles> resource_files);
-
- // Makes the "CloseNotification" call to D-Bus.
- void CloseNow(uint32_t dbus_id);
-
- void ForwardNotificationOperation(uint32_t dbus_id,
- NotificationCommon::Operation operation,
- int action_index);
-
- // GSignalReceiver: The function that GLib calls into for
- // ActionInvoked and NotificationClosed signals.
- CHROMEG_CALLBACK_3(NotificationPlatformBridgeLinux,
- void,
- GSignalReceiver,
- GDBusProxy*,
- const char*,
- const char*,
- GVariant*);
-
- NotificationData* FindNotificationData(const std::string& notification_id,
- const std::string& profile_id,
- bool is_incognito);
-
- NotificationData* FindNotificationData(uint32_t dbus_id);
-
- ScopedGObject<GDBusProxy> notification_proxy_;
-
- // Used to disconnect from "g-signal" during destruction.
- gulong proxy_signal_handler_ = 0;
-
- // A std::set<std::unique_ptr<T>> doesn't work well because
- // 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_;
-
- content::NotificationRegistrar registrar_;
-
- base::WeakPtrFactory<NotificationPlatformBridgeLinux> weak_factory_;
+ std::unique_ptr<NativeNotificationThread> thread_;
Lei Zhang 2017/04/17 23:32:14 Is there an easy way to reuse an existing thread?
Tom (Use chromium acct) 2017/04/18 01:41:11 Create() needs to block, so I'm reluctant to put t
Lei Zhang 2017/04/18 02:39:58 Yes, that sounds like how many other DBus clients
DISALLOW_COPY_AND_ASSIGN(NotificationPlatformBridgeLinux);
};

Powered by Google App Engine
This is Rietveld 408576698