| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_CHROMEOS_ARC_ARC_WALLPAPER_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_ARC_ARC_WALLPAPER_HANDLER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_ARC_ARC_WALLPAPER_HANDLER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_ARC_ARC_WALLPAPER_HANDLER_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <set> | 11 #include <set> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "chrome/browser/image_decoder.h" |
| 15 #include "components/arc/set_wallpaper_delegate.h" | 16 #include "components/arc/set_wallpaper_delegate.h" |
| 16 | 17 |
| 17 class SkBitmap; | 18 class SkBitmap; |
| 18 | 19 |
| 19 namespace arc { | 20 namespace arc { |
| 20 | 21 |
| 21 // Lives on the UI thread. | 22 // Lives on the UI thread. |
| 22 class ArcWallpaperHandler : public SetWallpaperDelegate { | 23 class ArcWallpaperHandler : public SetWallpaperDelegate, |
| 24 public ImageDecoder::ImageRequest { |
| 23 public: | 25 public: |
| 24 ArcWallpaperHandler(); | 26 ArcWallpaperHandler(); |
| 25 ~ArcWallpaperHandler() override; | 27 ~ArcWallpaperHandler() override; |
| 26 | 28 |
| 27 // SetWallpaperDelegate implementation. | 29 // SetWallpaperDelegate implementation. |
| 28 void SetWallpaper(const std::vector<uint8_t>& jpeg_data) override; | 30 void SetWallpaper(const std::vector<uint8_t>& jpeg_data) override; |
| 29 | 31 |
| 32 // ImageDecoder::ImageRequest implementation. |
| 33 void OnImageDecoded(const SkBitmap& bitmap) override; |
| 34 void OnDecodeImageFailed() override; |
| 35 |
| 30 private: | 36 private: |
| 31 class ImageRequestImpl; | |
| 32 | |
| 33 // Called from ImageRequestImpl on decode completion. | |
| 34 void OnImageDecoded(ImageRequestImpl* request, const SkBitmap& bitmap); | |
| 35 void OnDecodeImageFailed(ImageRequestImpl* request); | |
| 36 | |
| 37 // The set of in-flight decode requests. | |
| 38 std::set<std::unique_ptr<ImageRequestImpl>> inflight_requests_; | |
| 39 | |
| 40 DISALLOW_COPY_AND_ASSIGN(ArcWallpaperHandler); | 37 DISALLOW_COPY_AND_ASSIGN(ArcWallpaperHandler); |
| 41 }; | 38 }; |
| 42 | 39 |
| 43 } // namespace arc | 40 } // namespace arc |
| 44 | 41 |
| 45 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_WALLPAPER_HANDLER_H_ | 42 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_WALLPAPER_HANDLER_H_ |
| OLD | NEW |