OLD | NEW |
---|---|
(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 <vector> | |
9 | |
10 #include "base/callback_forward.h" | |
11 #include "base/macros.h" | |
12 #include "base/memory/ref_counted.h" | |
13 #include "base/memory/weak_ptr.h" | |
14 #include "content/child/notifications/notification_image_loader.h" | |
15 #include "third_party/WebKit/public/platform/WebURL.h" | |
16 #include "third_party/WebKit/public/platform/modules/notifications/WebNotificati onData.h" | |
17 #include "third_party/skia/include/core/SkBitmap.h" | |
18 | |
19 namespace base { | |
20 class SingleThreadTaskRunner; | |
21 } | |
22 | |
23 namespace content { | |
24 | |
25 struct NotificationResources; | |
26 | |
27 // Stores the information associated with a pending notification, and fetches | |
28 // resources for it on the main thread. | |
29 class PendingNotification { | |
30 public: | |
31 explicit PendingNotification( | |
32 const scoped_refptr<base::SingleThreadTaskRunner>& main_task_runner); | |
33 ~PendingNotification(); | |
34 | |
35 // Fetches all resources asynchronously on the main thread. | |
36 void FetchResources(const blink::WebNotificationData& notification_data, | |
37 const base::Closure& fetches_finished_callback); | |
38 | |
39 // Returns a new NotificationResources populated with the resources that have | |
40 // been fetched. | |
41 NotificationResources GetResources(); | |
Peter Beverloo
2016/02/10 18:14:32
nit: const qualifier on the method.
Michael van Ouwerkerk
2016/02/10 18:23:44
Done.
| |
42 | |
43 private: | |
44 // Fetches an image using |image_web_url| asynchronously on the main thread. | |
45 // The |image_callback| will be called on the worker thread. | |
46 void FetchImageResource(const blink::WebURL& image_web_url, | |
47 const ImageLoadCompletedCallback& image_callback); | |
48 | |
49 // To be called on the worker thread when the notification icon has been | |
50 // fetched. | |
51 void DidFetchNotificationIcon(const SkBitmap& notification_icon); | |
52 | |
53 // To be called on the worker thread when an action icon has been fetched. | |
54 void DidFetchActionIcon(size_t action_index, const SkBitmap& action_icon); | |
55 | |
56 scoped_refptr<base::SingleThreadTaskRunner> main_task_runner_; | |
57 | |
58 SkBitmap notification_icon_; | |
59 | |
60 std::vector<SkBitmap> action_icons_; | |
61 | |
62 base::Closure fetches_finished_barrier_closure_; | |
63 | |
64 std::vector<scoped_refptr<NotificationImageLoader>> image_loaders_; | |
65 | |
66 base::WeakPtrFactory<PendingNotification> weak_factory_; | |
67 | |
68 DISALLOW_COPY_AND_ASSIGN(PendingNotification); | |
69 }; | |
70 | |
71 } // namespace content | |
72 | |
73 #endif // CONTENT_CHILD_NOTIFICATIONS_PENDING_NOTIFICATION_H_ | |
OLD | NEW |