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

Unified Diff: content/child/notifications/notification_manager.h

Issue 939513002: Factor out a PendingNotificationTracker from the NotificationManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@n-sounds
Patch Set: Created 5 years, 10 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: content/child/notifications/notification_manager.h
diff --git a/content/child/notifications/notification_manager.h b/content/child/notifications/notification_manager.h
index 47d979d5b2730d1fe5e9c58ad9b7a1ed0a8fb13a..ee64f3c10638cbe1dc88e687ca3b24ff16f9aee5 100644
--- a/content/child/notifications/notification_manager.h
+++ b/content/child/notifications/notification_manager.h
@@ -8,21 +8,15 @@
#include <map>
#include <set>
-#include "base/id_map.h"
#include "base/memory/ref_counted.h"
-#include "base/memory/weak_ptr.h"
#include "base/single_thread_task_runner.h"
#include "content/child/notifications/notification_dispatcher.h"
-#include "content/child/notifications/notification_image_loader.h"
+#include "content/child/notifications/pending_notifications_tracker.h"
#include "content/child/worker_task_runner.h"
#include "third_party/WebKit/public/platform/modules/notifications/WebNotificationManager.h"
class SkBitmap;
-namespace blink {
-class WebURL;
-}
-
namespace content {
class ThreadSafeSender;
@@ -73,56 +67,36 @@ class NotificationManager : public blink::WebNotificationManager,
void OnDidClose(int notification_id);
void OnDidClick(int notification_id);
- // Asynchronously starts loading |image_url| on the main thread and returns a
- // reference to the notification image loaded responsible for this. |callback|
- // will be invoked on the calling thread when the load is complete.
- scoped_refptr<NotificationImageLoader> CreateImageLoader(
- const blink::WebURL& image_url,
- const NotificationImageLoadedCallback& callback) const;
-
- // Sends an IPC to the browser process to display the notification,
- // accompanied by the downloaded icon.
- void DisplayNotification(const blink::WebSerializedOrigin& origin,
- const blink::WebNotificationData& notification_data,
- blink::WebNotificationDelegate* delegate,
- scoped_refptr<NotificationImageLoader> image_loader);
-
- // Sends an IPC to the browser process to display the persistent notification,
- // accompanied by the downloaded icon.
+ // To be called when a page notification is ready to be displayed. Will
+ // inform the browser process about all available data. The |delegate|,
+ // owned by Blink, will be used to feed back events associated with the
+ // notification to the JavaScript object.
+ void DisplayPageNotification(
+ const blink::WebSerializedOrigin& origin,
+ const blink::WebNotificationData& notification_data,
+ blink::WebNotificationDelegate* delegate,
+ const SkBitmap& icon);
+
+ // To be called when a persistent notification is ready to be displayed. Will
+ // inform the browser process about all available data. The |callbacks| will
+ // be used to inform the Promise pending in Blink that the notification has
+ // been send to the browser process to be displayed.
void DisplayPersistentNotification(
const blink::WebSerializedOrigin& origin,
const blink::WebNotificationData& notification_data,
int64 service_worker_registration_id,
- int request_id,
- scoped_refptr<NotificationImageLoader> image_loader);
-
- // Removes the notification identified by |delegate| from the set of
- // pending notifications, and returns whether it could be found.
- bool RemovePendingPageNotification(blink::WebNotificationDelegate* delegate);
+ scoped_ptr<blink::WebNotificationShowCallbacks> callbacks,
+ const SkBitmap& icon);
scoped_refptr<ThreadSafeSender> thread_safe_sender_;
- scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
scoped_refptr<NotificationDispatcher> notification_dispatcher_;
- // Tracking display requests for persistent notifications.
- IDMap<blink::WebNotificationShowCallbacks, IDMapOwnPointer>
- persistent_notification_requests_;
-
- // A map tracking Page-bound notifications whose icon is still being
- // downloaded. These downloads can be cancelled by the developer.
- std::map<blink::WebNotificationDelegate*,
- scoped_refptr<NotificationImageLoader>>
- pending_page_notifications_;
-
- // A set tracking Persistent notifications whose icon is still being
- // downloaded. These downloads cannot be cancelled by the developer.
- std::set<scoped_refptr<NotificationImageLoader>>
- pending_persistent_notifications_;
+ // Tracker which stores all pending Notifications, both page and persistent
+ // ones, until all their associated resources have been fetched.
+ PendingNotificationsTracker pending_notifications_;
// Map to store the delegate associated with a notification request Id.
- std::map<int, blink::WebNotificationDelegate*> active_notifications_;
-
- base::WeakPtrFactory<NotificationManager> weak_factory_;
+ std::map<int, blink::WebNotificationDelegate*> active_page_notifications_;
DISALLOW_COPY_AND_ASSIGN(NotificationManager);
};
« no previous file with comments | « content/child/notifications/notification_image_loader.cc ('k') | content/child/notifications/notification_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698