Chromium Code Reviews| OLD | NEW |
|---|---|
| (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" | |
|
dcheng
2013/05/30 22:38:09
This include is no longer used.
| |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "chrome/browser/image_decoder.h" | |
| 11 #include "googleurl/src/gurl.h" | |
| 12 #include "net/url_request/url_fetcher_delegate.h" | |
| 13 #include "third_party/skia/include/core/SKBitmap.h" | |
| 14 | |
| 15 namespace net { | |
| 16 class URLFetcher; | |
| 17 } // namespace net | |
| 18 | |
| 19 namespace notifier { | |
| 20 | |
| 21 // A delegate interface for users of NotificationBitmapFetcher. | |
| 22 class NotificationBitmapFetcherDelegate { | |
| 23 public: | |
| 24 // This will be called when the bitmap has been fetched, successfully or not. | |
| 25 virtual void OnFetchComplete(const SkBitmap* bitmap) = 0; | |
| 26 | |
| 27 protected: | |
| 28 virtual ~NotificationBitmapFetcherDelegate() {} | |
| 29 }; | |
| 30 | |
| 31 class NotificationBitmapFetcher | |
| 32 : public net::URLFetcherDelegate, | |
| 33 public ImageDecoder::Delegate, | |
| 34 public base::RefCountedThreadSafe<NotificationBitmapFetcher> { | |
|
dcheng
2013/05/30 22:38:09
This no longer needs to be refcounted.
Pete Williamson
2013/05/31 00:17:39
Done.
| |
| 35 public: | |
| 36 explicit NotificationBitmapFetcher( | |
|
miket_OOO
2013/05/30 22:53:20
This doesn't need to be explicit anymore now that
Pete Williamson
2013/05/31 00:17:39
Done.
| |
| 37 const GURL& url, | |
| 38 NotificationBitmapFetcherDelegate* delegate); | |
|
dcheng
2013/05/30 22:38:09
Style nit: indent is wonky.
Pete Williamson
2013/05/31 00:17:39
Done.
| |
| 39 ~NotificationBitmapFetcher(); | |
|
dcheng
2013/05/30 22:38:09
Nit: Explicitly mark destructor virtual. Note that
| |
| 40 | |
| 41 // Start fetching the URL with the fetcher. The operation will be continued | |
| 42 // in the OnURLFetchComplete callback. | |
| 43 void Start(); | |
| 44 | |
| 45 // Methods inherited from URLFetcherDelegate | |
| 46 | |
| 47 // This will be called when the URL has been fetched, successfully or not. | |
| 48 // Use accessor methods on |source| to get the results. | |
| 49 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | |
| 50 | |
| 51 // This will be called when some part of the response is read. |current| | |
| 52 // denotes the number of bytes received up to the call, and |total| is the | |
| 53 // expected total size of the response (or -1 if not determined). | |
| 54 virtual void OnURLFetchDownloadProgress(const net::URLFetcher* source, | |
| 55 int64 current, int64 total) OVERRIDE; | |
| 56 | |
| 57 // Methods inherited from ImageDecoder::Delegate | |
| 58 | |
| 59 // Called when image is decoded. |decoder| is used to identify the image in | |
| 60 // case of decoding several images simultaneously. This will not be called | |
| 61 // on the UI thread. | |
| 62 virtual void OnImageDecoded(const ImageDecoder* decoder, | |
| 63 const SkBitmap& decoded_image) OVERRIDE; | |
| 64 | |
| 65 // Called when decoding image failed. | |
| 66 virtual void OnDecodeImageFailed(const ImageDecoder* decoder) OVERRIDE; | |
| 67 | |
| 68 // Used to pass in a fetcher for dependency injection in tests. | |
| 69 void SetURLFetcherForTest(scoped_ptr<net::URLFetcher> url_fetcher); | |
| 70 | |
| 71 private: | |
| 72 scoped_ptr<net::URLFetcher> url_fetcher_; | |
| 73 scoped_refptr<ImageDecoder> image_decoder_; | |
| 74 const GURL url_; | |
| 75 scoped_ptr<SkBitmap> bitmap_; | |
|
dcheng
2013/05/30 22:38:09
Note that you don't have to include SkBitmap here
| |
| 76 NotificationBitmapFetcherDelegate* const delegate_; | |
| 77 | |
| 78 DISALLOW_COPY_AND_ASSIGN(NotificationBitmapFetcher); | |
| 79 }; | |
| 80 | |
| 81 } // namespace notifier | |
| 82 | |
| 83 #endif // CHROME_BROWSER_NOTIFICATIONS_SYNC_NOTIFIER_NOTIFICATION_BITMAP_FETCHE R_H_ | |
| OLD | NEW |