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

Side by Side Diff: third_party/WebKit/Source/modules/notifications/NotificationResourcesLoader.h

Issue 1847863002: Move notification resource loading from content/child to blink (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ImageFrame::getSkBitmap was removed. Created 4 years, 8 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 NotificationResourcesLoader_h
6 #define NotificationResourcesLoader_h
7
8 #include "core/dom/ContextLifecycleObserver.h"
9 #include "modules/ModulesExport.h"
10 #include "modules/notifications/NotificationImageLoader.h"
11 #include "platform/heap/GarbageCollected.h"
12 #include "platform/heap/Handle.h"
13 #include "platform/heap/HeapAllocator.h"
14 #include "platform/heap/ThreadState.h"
15 #include "third_party/skia/include/core/SkBitmap.h"
16 #include "wtf/Functional.h"
17 #include "wtf/OwnPtr.h"
18 #include "wtf/PassOwnPtr.h"
19 #include "wtf/Vector.h"
20 #include <memory>
21
22 namespace blink {
23
24 class ExecutionContext;
25 struct WebNotificationData;
26 struct WebNotificationResources;
27
28 class MODULES_EXPORT NotificationResourcesLoader final
29 : public GarbageCollectedFinalized<NotificationResourcesLoader>
30 , public ContextLifecycleObserver {
31 USING_GARBAGE_COLLECTED_MIXIN(NotificationResourcesLoader);
32 USING_PRE_FINALIZER(NotificationResourcesLoader, stop);
33 public:
34 using CompletionCallback = Function<void(NotificationResourcesLoader*)>;
Peter Beverloo 2016/04/13 18:32:28 Docs? Would be good to document that the instance
Michael van Ouwerkerk 2016/04/14 13:42:12 Done.
35 NotificationResourcesLoader(ExecutionContext*,
36 PassOwnPtr<CompletionCallback>);
Peter Beverloo 2016/04/13 18:32:28 micro nit: nowrap
Michael van Ouwerkerk 2016/04/14 13:42:12 Done.
37 ~NotificationResourcesLoader();
38
39 // Starts fetching the resources specified in the given WebNotificationData.
40 // If all the urls for the resources are empty or invalid,
41 // |m_completionCallback| will be run synchronously, otherwise it will be
42 // run asynchronously when all fetches have finished. Should not be called
43 // more than once.
Peter Beverloo 2016/04/13 18:32:28 Is there any way we can DCHECK for this contract?
Michael van Ouwerkerk 2016/04/14 13:42:12 I've added m_started for this.
44 void start(const WebNotificationData&);
45
46 // Returns a new WebNotificationResources populated with the resources that
47 // have been fetched.
48 std::unique_ptr<WebNotificationResources> getResources() const;
49
50 // ContextLifecycleObserver interface.
51 void contextDestroyed() override;
52
53 DECLARE_VIRTUAL_TRACE();
54
55 private:
56 void loadImage(const KURL&,
57 PassOwnPtr<NotificationImageLoader::ImageCallback>);
Peter Beverloo 2016/04/13 18:32:28 micro nit: nowrap (This is invalid per Chromium s
Michael van Ouwerkerk 2016/04/14 13:42:12 Done.
58 void didLoadIcon(const SkBitmap& image);
59 void didLoadBadge(const SkBitmap& image);
60 void didLoadActionIcon(size_t actionIndex, const SkBitmap& image);
61
62 // Decrements |m_pendingRequestCount| and runs |m_completionCallback| if
63 // there are no more pending requests.
64 void didFinishRequest();
65
66 // Stops every loader in |m_imageLoaders|.
Peter Beverloo 2016/04/13 18:32:28 nit: Also document that this is the pre-finalizer.
Michael van Ouwerkerk 2016/04/14 13:42:12 Done.
67 void stop();
68
69 OwnPtr<CompletionCallback> m_completionCallback;
70 int m_pendingRequestCount;
71 HeapVector<Member<NotificationImageLoader>> m_imageLoaders;
72 SkBitmap m_icon;
73 SkBitmap m_badge;
74 Vector<SkBitmap> m_actionIcons;
75 };
76
77 } // namespace blink
78
79 #endif // NotificationResourcesLoader_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698