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

Side by Side Diff: content/child/notifications/pending_notifications_tracker.h

Issue 1634933006: Use NotificationResources instead of a bare SkBitmap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_CHILD_NOTIFICATIONS_PENDING_NOTIFICATIONS_TRACKER_H_ 5 #ifndef CONTENT_CHILD_NOTIFICATIONS_PENDING_NOTIFICATIONS_TRACKER_H_
6 #define CONTENT_CHILD_NOTIFICATIONS_PENDING_NOTIFICATIONS_TRACKER_H_ 6 #define CONTENT_CHILD_NOTIFICATIONS_PENDING_NOTIFICATIONS_TRACKER_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/id_map.h" 10 #include "base/id_map.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati onManager.h"
16 15
17 class SkBitmap; 16 class SkBitmap;
18 17
19 namespace base { 18 namespace base {
20 class SingleThreadTaskRunner; 19 class SingleThreadTaskRunner;
21 } 20 }
22 21
23 namespace blink { 22 namespace blink {
24 struct WebNotificationData; 23 struct WebNotificationData;
25 class WebNotificationDelegate; 24 class WebNotificationDelegate;
26 } 25 }
27 26
28 namespace content { 27 namespace content {
29 28
30 class NotificationImageLoader; 29 class NotificationImageLoader;
31 class NotificationManager; 30 struct NotificationResources;
32 31
33 // Type definition for the callback signature which is to be invoked when the 32 // Type definition for the callback signature which is to be invoked when the
34 // resources associated with a notification have been fetched. 33 // resources associated with a notification have been fetched.
35 using NotificationResourcesFetchedCallback = 34 using NotificationResourcesFetchedCallback =
36 base::Callback<void(const SkBitmap&)>; 35 base::Callback<void(const NotificationResources&)>;
37 36
38 // Tracks all aspects of all pending Web Notifications. Most notably, it's in 37 // Tracks all aspects of all pending Web Notifications. Most notably, it's in
39 // charge of ensuring that all resource fetches associated with the notification 38 // charge of ensuring that all resource fetches associated with the notification
40 // are completed as expected. The data associated with the notifications is 39 // are completed as expected. The data associated with the notifications is
41 // stored in this class, to maintain thread integrity of their members. 40 // stored in this class, to maintain thread integrity of their members.
42 // 41 //
43 // The pending notification tracker is owned by the NotificationManager, and 42 // The pending notification tracker is owned by the NotificationManager, and
44 // lives on the thread that manager has been associated with. 43 // lives on the thread that manager has been associated with.
45 class PendingNotificationsTracker { 44 class PendingNotificationsTracker {
46 public: 45 public:
(...skipping 16 matching lines...) Expand all
63 62
64 // Cancels all pending and in-fligth fetches for the page notification 63 // Cancels all pending and in-fligth fetches for the page notification
65 // identified by |delegate|. Returns if the notification was cancelled. 64 // identified by |delegate|. Returns if the notification was cancelled.
66 bool CancelPageNotificationFetches(blink::WebNotificationDelegate* delegate); 65 bool CancelPageNotificationFetches(blink::WebNotificationDelegate* delegate);
67 66
68 private: 67 private:
69 // To be called on the worker thread when the pending page notification 68 // To be called on the worker thread when the pending page notification
70 // identified by |notification_id| has finished fetching the icon. 69 // identified by |notification_id| has finished fetching the icon.
71 void DidFetchPageNotification(blink::WebNotificationDelegate* delegate, 70 void DidFetchPageNotification(blink::WebNotificationDelegate* delegate,
72 int notification_id, 71 int notification_id,
73 const SkBitmap& icon); 72 const SkBitmap& icon);
Peter Beverloo 2016/01/26 15:43:23 I imagine that you'll update these as a second ste
Michael van Ouwerkerk 2016/01/26 16:24:21 These methods will probably be nuked from orbit [1
74 73
75 // To be called on the worker thread when the pending persistent notification 74 // To be called on the worker thread when the pending persistent notification
76 // identified by |notification_id| has finished fetching the icon. 75 // identified by |notification_id| has finished fetching the icon.
77 void DidFetchPersistentNotification(int notification_id, 76 void DidFetchPersistentNotification(int notification_id,
78 const SkBitmap& icon); 77 const SkBitmap& icon);
79 78
80 // Common code for starting to fetch resources associated with any kind of 79 // Common code for starting to fetch resources associated with any kind of
81 // notification. Will return the id of the pending notification as allocated 80 // notification. Will return the id of the pending notification as allocated
82 // in the |pending_notifications_| map. 81 // in the |pending_notifications_| map.
83 int FetchNotificationResources( 82 int FetchNotificationResources(
(...skipping 13 matching lines...) Expand all
97 std::map<blink::WebNotificationDelegate*, int> delegate_to_pending_id_map_; 96 std::map<blink::WebNotificationDelegate*, int> delegate_to_pending_id_map_;
98 97
99 base::WeakPtrFactory<PendingNotificationsTracker> weak_factory_; 98 base::WeakPtrFactory<PendingNotificationsTracker> weak_factory_;
100 99
101 DISALLOW_COPY_AND_ASSIGN(PendingNotificationsTracker); 100 DISALLOW_COPY_AND_ASSIGN(PendingNotificationsTracker);
102 }; 101 };
103 102
104 } // namespace content 103 } // namespace content
105 104
106 #endif // CONTENT_CHILD_NOTIFICATIONS_PENDING_NOTIFICATIONS_TRACKER_H_ 105 #endif // CONTENT_CHILD_NOTIFICATIONS_PENDING_NOTIFICATIONS_TRACKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698