Chromium Code Reviews| Index: content/child/notifications/pending_notification.h |
| diff --git a/content/child/notifications/pending_notification.h b/content/child/notifications/pending_notification.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a543ae0030627ea9bb3a5ed2c609191f877deae5 |
| --- /dev/null |
| +++ b/content/child/notifications/pending_notification.h |
| @@ -0,0 +1,77 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_CHILD_NOTIFICATIONS_PENDING_NOTIFICATION_H_ |
| +#define CONTENT_CHILD_NOTIFICATIONS_PENDING_NOTIFICATION_H_ |
| + |
| +#include <set> |
| +#include <vector> |
| + |
| +#include "base/callback_forward.h" |
| +#include "base/macros.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "content/child/notifications/notification_image_loader.h" |
| +#include "third_party/WebKit/public/platform/WebURL.h" |
| +#include "third_party/WebKit/public/platform/modules/notifications/WebNotificationData.h" |
| +#include "third_party/skia/include/core/SkBitmap.h" |
| + |
| +namespace base { |
| +class SingleThreadTaskRunner; |
| +} |
| + |
| +namespace content { |
| + |
| +struct NotificationResources; |
| + |
| +// Stores the information associated with a pending notification, and fetches |
| +// resources for it on the main thread. |
| +class PendingNotification { |
| + public: |
| + PendingNotification( |
| + scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner, |
| + const blink::WebNotificationData& notification_data, |
|
Peter Beverloo
2016/02/05 15:43:21
The only reason that PendingNotification stores th
Michael van Ouwerkerk
2016/02/08 14:38:52
Ugh. The constructor does a bit more than that, an
|
| + const base::Closure& fetches_finished_callback); |
| + ~PendingNotification(); |
| + |
| + // Fetches all resources asynchronously on the main thread. |
| + void FetchResources(); |
| + |
| + // Returns a new NotificationResources populated with the resources that have |
| + // been fetched. |
| + NotificationResources GetResources(); |
| + |
| + private: |
| + // Fetches an image using |image_web_url| asynchronously on the main thread. |
| + // The |image_callback| will be called on the worker thread. |
| + void FetchImageResource(const blink::WebURL& image_web_url, |
| + const ImageLoadCompletedCallback& image_callback); |
| + |
| + // To be called on the worker thread when the notification icon has been |
| + // fetched. |
| + void DidFetchNotificationIcon(const SkBitmap& notification_icon); |
| + |
| + // To be called on the worker thread when an action icon has been fetched. |
| + void DidFetchActionIcon(size_t action_index, const SkBitmap& action_icon); |
| + |
| + scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; |
| + |
| + blink::WebNotificationData notification_data_; |
| + |
| + SkBitmap notification_icon_; |
| + |
| + std::vector<SkBitmap> action_icons_; |
| + |
| + base::Closure fetches_finished_barrier_closure_; |
| + |
| + std::set<scoped_refptr<NotificationImageLoader>> image_loaders_; |
|
Peter Beverloo
2016/02/05 15:43:21
nit: May as well use a std::vector<> for this, sin
Michael van Ouwerkerk
2016/02/08 14:38:52
Done.
|
| + |
| + base::WeakPtrFactory<PendingNotification> weak_factory_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(PendingNotification); |
| +}; |
| + |
| +} // namespace content |
| + |
| +#endif // CONTENT_CHILD_NOTIFICATIONS_PENDING_NOTIFICATION_H_ |