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

Side by Side Diff: chrome/browser/notifications/sync_notifier/notification_bitmap_fetcher.h

Issue 15295018: Continue bitmap fetching for notifications. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Synced Notification Bitmap Fetching - refactor unit tests into browser test Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2013 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 CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_NOTIFICATION_BITMAP_FETCHER_H _
6 #define CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_NOTIFICATION_BITMAP_FETCHER_H _
7
8 #include "base/gtest_prod_util.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop/message_loop_proxy.h"
dcheng 2013/05/29 20:40:29 This isn't used in the header.
Pete Williamson 2013/05/30 00:13:18 Done.
11 #include "chrome/browser/image_decoder.h"
12 #include "googleurl/src/gurl.h"
13 #include "net/url_request/url_fetcher_delegate.h"
14 #include "third_party/skia/include/core/SKBitmap.h"
15
16 namespace net {
17 class URLFetcher;
18 } // namespace net
19
20 class NotificationBitmapFetcherTest;
21 class NotificationBitmapFetcherBrowserTest;
dcheng 2013/05/29 20:40:29 Not needed.
Pete Williamson 2013/05/30 00:13:18 Done.
22
23 namespace notifier {
24
25 // A delegate interface for users of NotificationBitmapFetcher.
26 class NotificationBitmapFetcherDelegate {
27 public:
28 // This will be called when the bitmap has been fetched, successfully or not.
29 virtual void OnFetchComplete(GURL url, const SkBitmap* bitmap) = 0;
30
31 protected:
32 virtual ~NotificationBitmapFetcherDelegate() {}
33 };
34
35 class NotificationBitmapFetcher
36 : public net::URLFetcherDelegate,
37 public ImageDecoder::Delegate,
38 public base::RefCountedThreadSafe<NotificationBitmapFetcher> {
39 public:
40 explicit NotificationBitmapFetcher(
41 const GURL& url,
42 NotificationBitmapFetcherDelegate* delegate);
43 ~NotificationBitmapFetcher();
44
45 // Start fetching the URL with the fetcher. The operation will be continued
46 // in the OnURLFetchComplete callback.
47 void StartImageFetch();
48
49 // Methods inherited from URLFetcherDelegate
50
51 // This will be called when the URL has been fetched, successfully or not.
52 // Use accessor methods on |source| to get the results.
53 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
54
55 // This will be called when some part of the response is read. |current|
56 // denotes the number of bytes received up to the call, and |total| is the
57 // expected total size of the response (or -1 if not determined).
58 virtual void OnURLFetchDownloadProgress(const net::URLFetcher* source,
59 int64 current, int64 total) OVERRIDE;
60
61 // Methods inherited from ImageDecoder::Delegate
62
63 // Called when image is decoded. |decoder| is used to identify the image in
64 // case of decoding several images simultaneously. This will not be called
65 // on the UI thread.
66 virtual void OnImageDecoded(const ImageDecoder* decoder,
67 const SkBitmap& decoded_image) OVERRIDE;
68
69 // Called when decoding image failed.
70 virtual void OnDecodeImageFailed(const ImageDecoder* decoder) OVERRIDE;
71
72 // Used to pass in a fetcher for dependency injection in tests.
73 void SetURLFetcherForTest(scoped_ptr<net::URLFetcher>& url_fetcher);
74
75 private:
76 scoped_ptr<net::URLFetcher> url_fetcher_;
77 scoped_refptr<ImageDecoder> image_decoder_;
78 const GURL url_;
79 scoped_ptr<SkBitmap> bitmap_;
80 NotificationBitmapFetcherDelegate* const delegate_;
81
82 DISALLOW_COPY_AND_ASSIGN(NotificationBitmapFetcher);
83 };
84
85 } // namespace notifier
86
87 #endif // CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_NOTIFICATION_BITMAP_FETCHE R_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698