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

Side by Side Diff: content/renderer/notification_icon_loader.h

Issue 740543003: Remove the old Web Notification code-path (Chromium) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove unittest references Created 6 years, 1 month 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 2014 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 CONTENT_RENDERER_NOTIFICATION_ICON_LOADER_H_
6 #define CONTENT_RENDERER_NOTIFICATION_ICON_LOADER_H_
7
8 #include <vector>
9
10 #include "base/callback.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h"
13
14 class SkBitmap;
15
16 namespace blink {
17 class WebURL;
18 struct WebURLError;
19 class WebURLLoader;
20 }
21
22 namespace content {
23
24 // Downloads the icon associated with a notification and decodes the received
25 // image. This must be completed before notifications are shown to the user.
26 // Icon downloaders must not be re-used for multiple notifications or icons.
27 class NotificationIconLoader : public blink::WebURLLoaderClient {
28 typedef base::Callback<void(int, const SkBitmap&)> DownloadCompletedCallback;
29
30 public:
31 NotificationIconLoader(int notification_id,
32 const DownloadCompletedCallback& callback);
33
34 virtual ~NotificationIconLoader();
35
36 // Downloads the notification's image and invokes the callback with the
37 // decoded SkBitmap when the download has succeeded, or with an empty SkBitmap
38 // in case the download has failed.
39 void Start(const blink::WebURL& icon_url);
40
41 // Cancels the current image download. The callback will not be invoked.
42 void Cancel();
43
44 // blink::WebURLLoaderClient implementation.
45 virtual void didReceiveData(blink::WebURLLoader* loader,
46 const char* data,
47 int data_length,
48 int encoded_data_length);
49 virtual void didFinishLoading(blink::WebURLLoader* loader,
50 double finish_time,
51 int64_t total_encoded_data_length);
52 virtual void didFail(blink::WebURLLoader* loader,
53 const blink::WebURLError& error);
54
55 int notification_id() const {
56 return notification_id_;
57 }
58
59 private:
60 int notification_id_;
61 DownloadCompletedCallback callback_;
62
63 scoped_ptr<blink::WebURLLoader> loader_;
64 bool completed_;
65
66 std::vector<uint8_t> buffer_;
67
68 DISALLOW_COPY_AND_ASSIGN(NotificationIconLoader);
69 };
70
71 } // namespace content
72
73 #endif // CONTENT_RENDERER_NOTIFICATION_ICON_LOADER_H_
OLDNEW
« no previous file with comments | « content/renderer/active_notification_tracker_unittest.cc ('k') | content/renderer/notification_icon_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698