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

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: Call stop when all fetches have finished. 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"
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
27 : public GarbageCollectedFinalized<NotificationImageLoader>
28 , public ThreadableLoaderClient {
29 public:
30 // The bitmap may be empty if the request failed or the image data could not
31 // be decoded.
32 using ImageCallback = Function<void(const SkBitmap&)>;
33
34 NotificationImageLoader();
35 ~NotificationImageLoader() override;
36
37 // Asynchronously downloads an image from the given url, decodes the loaded
38 // data, and passes the bitmap to the callback.
39 void start(ExecutionContext*, const KURL&, PassOwnPtr<ImageCallback>);
40
41 // Cancels the pending load, if there is one. The |m_imageCallback| will not
42 // be run.
43 void stop();
44
45 // ThreadableLoaderClient interface.
46 void didReceiveData(const char* data, unsigned length) override;
47 void didFinishLoading(unsigned long resourceIdentifier, double finishTime) o verride;
48 void didFail(const ResourceError&) override;
49 void didFailRedirectCheck() override;
50
51 DEFINE_INLINE_TRACE() {}
52
53 private:
54 void runCallbackWithEmptyBitmap();
55
56 bool m_stopped;
57 RefPtr<SharedBuffer> m_data;
58 OwnPtr<ImageCallback> m_imageCallback;
59 OwnPtr<ThreadableLoader> m_threadableLoader;
60 };
61
62 } // namespace blink
63
64 #endif // NotificationImageLoader_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698