| Index: content/child/notifications/pending_notifications_tracker.h
|
| diff --git a/content/child/notifications/pending_notifications_tracker.h b/content/child/notifications/pending_notifications_tracker.h
|
| index 53aa32104be2b92c751a5bffc90d012e36ede7ee..3f8429f078f3d3caf77e1a44be8105f4d3fd526d 100644
|
| --- a/content/child/notifications/pending_notifications_tracker.h
|
| +++ b/content/child/notifications/pending_notifications_tracker.h
|
| @@ -7,14 +7,10 @@
|
|
|
| #include <map>
|
|
|
| +#include "base/callback_forward.h"
|
| #include "base/id_map.h"
|
| #include "base/macros.h"
|
| #include "base/memory/ref_counted.h"
|
| -#include "base/memory/scoped_ptr.h"
|
| -#include "base/memory/weak_ptr.h"
|
| -#include "third_party/WebKit/public/platform/modules/notifications/WebNotificationManager.h"
|
| -
|
| -class SkBitmap;
|
|
|
| namespace base {
|
| class SingleThreadTaskRunner;
|
| @@ -27,19 +23,16 @@ class WebNotificationDelegate;
|
|
|
| namespace content {
|
|
|
| -class NotificationImageLoader;
|
| -class NotificationManager;
|
| +class PendingNotification;
|
| +struct NotificationResources;
|
|
|
| // Type definition for the callback signature which is to be invoked when the
|
| // resources associated with a notification have been fetched.
|
| -using NotificationResourcesFetchedCallback =
|
| - base::Callback<void(const SkBitmap&)>;
|
| -
|
| -// Tracks all aspects of all pending Web Notifications. Most notably, it's in
|
| -// charge of ensuring that all resource fetches associated with the notification
|
| -// are completed as expected. The data associated with the notifications is
|
| -// stored in this class, to maintain thread integrity of their members.
|
| -//
|
| +using NotificationResourcesCallback =
|
| + base::Callback<void(const NotificationResources&)>;
|
| +
|
| +// Tracks all pending Web Notifications as PendingNotification instances. The
|
| +// pending notifications (and their associated data) are stored in this class.
|
| // The pending notification tracker is owned by the NotificationManager, and
|
| // lives on the thread that manager has been associated with.
|
| class PendingNotificationsTracker {
|
| @@ -48,56 +41,38 @@ class PendingNotificationsTracker {
|
| scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner);
|
| ~PendingNotificationsTracker();
|
|
|
| - // Adds a page notification to the tracker. Resource fetches for the
|
| - // notification will be started on asynchronously the main thread.
|
| - void FetchPageNotificationResources(
|
| + // Adds a pending notification fo which to fetch resources. The |delegate| may
|
| + // be null, but if it is not it can be used to cancel the fetches. Resource
|
| + // fetches will be started asynchronously on the main thread.
|
| + void FetchNotificationResources(
|
| const blink::WebNotificationData& notification_data,
|
| blink::WebNotificationDelegate* delegate,
|
| - const NotificationResourcesFetchedCallback& callback);
|
| -
|
| - // Adds a persistent notification to the tracker. Resource fetches for the
|
| - // notification will be started asynchronously on the main thread.
|
| - void FetchPersistentNotificationResources(
|
| - const blink::WebNotificationData& notification_data,
|
| - const NotificationResourcesFetchedCallback& callback);
|
| + const NotificationResourcesCallback& resources_callback);
|
|
|
| - // Cancels all pending and in-fligth fetches for the page notification
|
| - // identified by |delegate|. Returns if the notification was cancelled.
|
| - bool CancelPageNotificationFetches(blink::WebNotificationDelegate* delegate);
|
| + // Cancels all pending and in-flight fetches for the notification
|
| + // identified by |delegate|. Returns whether the notification was cancelled.
|
| + bool CancelResourceFetches(blink::WebNotificationDelegate* delegate);
|
|
|
| private:
|
| - // To be called on the worker thread when the pending page notification
|
| - // identified by |notification_id| has finished fetching the icon.
|
| - void DidFetchPageNotification(blink::WebNotificationDelegate* delegate,
|
| - int notification_id,
|
| - const SkBitmap& icon);
|
| -
|
| - // To be called on the worker thread when the pending persistent notification
|
| - // identified by |notification_id| has finished fetching the icon.
|
| - void DidFetchPersistentNotification(int notification_id,
|
| - const SkBitmap& icon);
|
| -
|
| - // Common code for starting to fetch resources associated with any kind of
|
| - // notification. Will return the id of the pending notification as allocated
|
| - // in the |pending_notifications_| map.
|
| - int FetchNotificationResources(
|
| - const blink::WebNotificationData& notification_data,
|
| - const NotificationResourcesFetchedCallback& callback,
|
| - const scoped_refptr<NotificationImageLoader>& image_loader);
|
| + // To be called on the worker thread when the pending notification
|
| + // identified by |notification_id| has finished fetching the resources. The
|
| + // |delegate| may be null.
|
| + void FetchesFinished(blink::WebNotificationDelegate* delegate,
|
| + int notification_id,
|
| + const NotificationResourcesCallback& resources_callback);
|
|
|
| - scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
|
| + // Used to generate ids for tracking pending notifications.
|
| + int32_t next_notification_id_;
|
|
|
| - struct PendingNotification;
|
| + scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
|
|
|
| - // List of the notifications whose resources are still being fetched.
|
| + // The notifications whose resources are still being fetched.
|
| IDMap<PendingNotification, IDMapOwnPointer> pending_notifications_;
|
|
|
| // In order to be able to cancel pending page notifications by delegate, store
|
| // a mapping of the delegate to the pending notification id as well.
|
| std::map<blink::WebNotificationDelegate*, int> delegate_to_pending_id_map_;
|
|
|
| - base::WeakPtrFactory<PendingNotificationsTracker> weak_factory_;
|
| -
|
| DISALLOW_COPY_AND_ASSIGN(PendingNotificationsTracker);
|
| };
|
|
|
|
|