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

Side by Side Diff: third_party/WebKit/Source/modules/notifications/NotificationImageLoader.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: Rebase. Fix ASAN. Cleanups. Address peter's comments. 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 NotificationImageLoader_h
6 #define NotificationImageLoader_h
7
8 #include "core/loader/ThreadableLoader.h"
9 #include "core/loader/ThreadableLoaderClient.h"
10 #include "platform/SharedBuffer.h"
11 #include "platform/heap/Handle.h"
12 #include "third_party/skia/include/core/SkBitmap.h"
Peter Beverloo 2016/04/18 15:22:37 nit: could forward declare SkBitmap
Michael van Ouwerkerk 2016/04/18 17:03:15 Done.
13 #include "wtf/Functional.h"
14 #include "wtf/OwnPtr.h"
15 #include "wtf/PassOwnPtr.h"
16 #include "wtf/RefPtr.h"
17
18 namespace blink {
19
20 class ExecutionContext;
21 class KURL;
22 class ResourceError;
23
24 // Asynchronously downloads an image when given a url, decodes the loaded data,
25 // and passes the bitmap to the given callback.
26 class NotificationImageLoader final : public GarbageCollectedFinalized<Notificat ionImageLoader>, public ThreadableLoaderClient {
27 public:
28 // The bitmap may be empty if the request failed or the image data could not
29 // be decoded.
30 using ImageCallback = Function<void(const SkBitmap&)>;
31
32 NotificationImageLoader();
33 ~NotificationImageLoader() override;
34
35 // Asynchronously downloads an image from the given url, decodes the loaded
36 // data, and passes the bitmap to the callback.
37 void start(ExecutionContext*, const KURL&, PassOwnPtr<ImageCallback>);
38
39 // Cancels the pending load, if there is one. The |m_imageCallback| will not
40 // be run.
41 void stop();
42
43 // ThreadableLoaderClient interface.
44 void didReceiveData(const char* data, unsigned length) override;
45 void didFinishLoading(unsigned long resourceIdentifier, double finishTime) o verride;
46 void didFail(const ResourceError&) override;
47 void didFailRedirectCheck() override;
48
49 DEFINE_INLINE_TRACE() {}
50
51 private:
52 void runCallbackWithEmptyBitmap();
53
54 bool m_stopped;
55 RefPtr<SharedBuffer> m_data;
56 OwnPtr<ImageCallback> m_imageCallback;
57 OwnPtr<ThreadableLoader> m_threadableLoader;
58 };
59
60 } // namespace blink
61
62 #endif // NotificationImageLoader_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698