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

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

Issue 1620203004: Notification action icons prototype. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make it work on Android and clean up. 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef CONTENT_CHILD_NOTIFICATIONS_PENDING_NOTIFICATION_H_
6 #define CONTENT_CHILD_NOTIFICATIONS_PENDING_NOTIFICATION_H_
7
8 #include <set>
9 #include <vector>
10
11 #include "base/callback_forward.h"
12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/weak_ptr.h"
16 #include "content/child/notifications/notification_image_loader.h"
17 #include "third_party/WebKit/public/platform/WebURL.h"
18 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati onData.h"
19 #include "third_party/skia/include/core/SkBitmap.h"
20
21 namespace base {
22 class SingleThreadTaskRunner;
23 }
24
25 namespace content {
26
27 struct NotificationResources;
28
29 // Stores the information associated with a pending notification, and fetches
30 // resources for it on the main thread.
31 class PendingNotification {
32 public:
33 PendingNotification(
34 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner,
35 const blink::WebNotificationData& notification_data,
36 const base::Closure& fetches_finished_callback);
37 ~PendingNotification() = default;
38
39 // Fetches all resources asynchronously on the main thread.
40 void FetchResources();
41
42 NotificationResources GetResources();
43
44 private:
45 // Fetches an image using |image_web_url| asynchronously on the main thread.
46 // The |image_callback| will be called on the worker thread.
47 void FetchImageResource(const blink::WebURL& image_web_url,
48 const ImageLoadCompletedCallback& image_callback);
49
50 // To be called on the worker thread when the notification icon has been
51 // fetched.
52 void DidFetchNotificationIcon(const SkBitmap& notification_icon);
53
54 // To be called on the worker thread when an action icon has been fetched.
55 void DidFetchActionIcon(int action_index, const SkBitmap& action_icon);
56
57 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_;
58
59 blink::WebNotificationData notification_data_;
60
61 SkBitmap notification_icon_;
62
63 std::vector<SkBitmap> action_icons_;
64
65 base::Closure fetches_finished_barrier_closure_;
66
67 std::set<scoped_refptr<NotificationImageLoader>> image_loaders_;
68
69 base::WeakPtrFactory<PendingNotification> weak_factory_;
70
71 DISALLOW_COPY_AND_ASSIGN(PendingNotification);
72 };
73
74 } // namespace content
75
76 #endif // CONTENT_CHILD_NOTIFICATIONS_PENDING_NOTIFICATION_H_
OLDNEW
« no previous file with comments | « content/child/notifications/notification_manager.cc ('k') | content/child/notifications/pending_notification.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698