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

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

Issue 2821533003: Refactor NotificationPlatformBridgeLinux (Closed)
Patch Set: final comments 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 d86935c95a75f55430d1b4f42c1eda86d8522c56..b824ff7c3e7314db2a2b78e7d19a61db48280a01 100644
--- a/chrome/browser/notifications/notification_platform_bridge_linux.h
+++ b/chrome/browser/notifications/notification_platform_bridge_linux.h
@@ -5,22 +5,16 @@
#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/callback_forward.h"
#include "base/macros.h"
-#include "base/memory/weak_ptr.h"
+#include "base/memory/ref_counted.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 NotificationPlatformBridgeLinuxImpl;
+
+class NotificationPlatformBridgeLinux : public NotificationPlatformBridge {
public:
- explicit NotificationPlatformBridgeLinux(GDBusProxy* notification_proxy);
+ NotificationPlatformBridgeLinux();
~NotificationPlatformBridgeLinux() override;
@@ -36,72 +30,10 @@ class NotificationPlatformBridgeLinux : public NotificationPlatformBridge,
const std::string& profile_id,
bool incognito,
const GetDisplayedNotificationsCallback& callback) const override;
-
- // Called from NotifyCompleteReceiver().
- void NotifyCompleteInternal(gpointer user_data, GVariant* value);
+ void SetReadyCallback(NotificationBridgeReadyCallback callback) override;
private:
- struct NotificationData;
- struct ResourceFiles;
-
- // 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_;
+ scoped_refptr<NotificationPlatformBridgeLinuxImpl> impl_;
DISALLOW_COPY_AND_ASSIGN(NotificationPlatformBridgeLinux);
};

Powered by Google App Engine
This is Rietveld 408576698