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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/notifications/NotificationResourcesLoader.h
diff --git a/third_party/WebKit/Source/modules/notifications/NotificationResourcesLoader.h b/third_party/WebKit/Source/modules/notifications/NotificationResourcesLoader.h
new file mode 100644
index 0000000000000000000000000000000000000000..f3a7f2bf92d2ce161d345e5b73c2ff37aeb69dba
--- /dev/null
+++ b/third_party/WebKit/Source/modules/notifications/NotificationResourcesLoader.h
@@ -0,0 +1,79 @@
+// 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 NotificationResourcesLoader_h
+#define NotificationResourcesLoader_h
+
+#include "core/dom/ContextLifecycleObserver.h"
+#include "modules/ModulesExport.h"
+#include "modules/notifications/NotificationImageLoader.h"
+#include "platform/heap/GarbageCollected.h"
+#include "platform/heap/Handle.h"
+#include "platform/heap/HeapAllocator.h"
+#include "platform/heap/ThreadState.h"
+#include "third_party/skia/include/core/SkBitmap.h"
+#include "wtf/Functional.h"
+#include "wtf/OwnPtr.h"
+#include "wtf/PassOwnPtr.h"
+#include "wtf/Vector.h"
+#include <memory>
+
+namespace blink {
+
+class ExecutionContext;
+struct WebNotificationData;
+struct WebNotificationResources;
+
+class MODULES_EXPORT NotificationResourcesLoader final
+ : public GarbageCollectedFinalized<NotificationResourcesLoader>
+ , public ContextLifecycleObserver {
+ USING_GARBAGE_COLLECTED_MIXIN(NotificationResourcesLoader);
+ USING_PRE_FINALIZER(NotificationResourcesLoader, stop);
+public:
+ 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.
+ NotificationResourcesLoader(ExecutionContext*,
+ PassOwnPtr<CompletionCallback>);
Peter Beverloo 2016/04/13 18:32:28 micro nit: nowrap
Michael van Ouwerkerk 2016/04/14 13:42:12 Done.
+ ~NotificationResourcesLoader();
+
+ // Starts fetching the resources specified in the given WebNotificationData.
+ // If all the urls for the resources are empty or invalid,
+ // |m_completionCallback| will be run synchronously, otherwise it will be
+ // run asynchronously when all fetches have finished. Should not be called
+ // 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.
+ void start(const WebNotificationData&);
+
+ // Returns a new WebNotificationResources populated with the resources that
+ // have been fetched.
+ std::unique_ptr<WebNotificationResources> getResources() const;
+
+ // ContextLifecycleObserver interface.
+ void contextDestroyed() override;
+
+ DECLARE_VIRTUAL_TRACE();
+
+private:
+ void loadImage(const KURL&,
+ 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.
+ void didLoadIcon(const SkBitmap& image);
+ void didLoadBadge(const SkBitmap& image);
+ void didLoadActionIcon(size_t actionIndex, const SkBitmap& image);
+
+ // Decrements |m_pendingRequestCount| and runs |m_completionCallback| if
+ // there are no more pending requests.
+ void didFinishRequest();
+
+ // 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.
+ void stop();
+
+ OwnPtr<CompletionCallback> m_completionCallback;
+ int m_pendingRequestCount;
+ HeapVector<Member<NotificationImageLoader>> m_imageLoaders;
+ SkBitmap m_icon;
+ SkBitmap m_badge;
+ Vector<SkBitmap> m_actionIcons;
+};
+
+} // namespace blink
+
+#endif // NotificationResourcesLoader_h

Powered by Google App Engine
This is Rietveld 408576698