OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 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_CHROMEOS_APP_MODE_KIOSK_APP_ICON_LOADER_H_ | |
6 #define CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_ICON_LOADER_H_ | |
7 | |
8 #include "base/memory/ref_counted_memory.h" | |
9 #include "base/memory/weak_ptr.h" | |
10 #include "base/sequenced_task_runner.h" | |
11 #include "ui/gfx/image/image_skia.h" | |
12 | |
13 namespace base { | |
14 class FilePath; | |
15 } | |
16 | |
17 namespace chromeos { | |
18 | |
19 // Loads locally stored icon data and decodes it. | |
20 class KioskAppIconLoader { | |
21 public: | |
22 enum LoadResult { | |
23 SUCCESS, | |
24 FAILED_TO_LOAD, | |
25 FAILED_TO_DECODE, | |
26 }; | |
27 | |
28 class Delegate { | |
29 public: | |
30 Delegate() = default; | |
xiyuan
2017/03/31 15:10:03
No need to define a ctor for interface.
Sergey Poromov
2017/03/31 18:38:58
Done.
| |
31 | |
32 virtual void OnIconLoadSuccess(const gfx::ImageSkia& icon) = 0; | |
33 virtual void OnIconLoadFailure() = 0; | |
34 | |
35 protected: | |
36 virtual ~Delegate() = default; | |
37 | |
38 private: | |
39 DISALLOW_COPY_AND_ASSIGN(Delegate); | |
40 }; | |
41 | |
42 explicit KioskAppIconLoader(Delegate* delegate); | |
43 | |
44 ~KioskAppIconLoader(); | |
45 | |
46 void Start(const base::FilePath& icon_path); | |
47 | |
48 private: | |
49 class IconImageRequest; | |
50 | |
51 // Loads the icon from locally stored |icon_path| on the blocking pool | |
52 void LoadOnBlockingPool(const base::FilePath& icon_path); | |
53 void ReportResultOnBlockingPool(LoadResult result); | |
54 void NotifyDelegate(LoadResult result); | |
55 void ReportResultOnUIThread(LoadResult result); | |
56 | |
57 Delegate* const delegate_; | |
58 | |
59 scoped_refptr<base::SequencedTaskRunner> task_runner_; | |
60 | |
61 gfx::ImageSkia icon_; | |
62 | |
63 base::WeakPtrFactory<KioskAppIconLoader> weak_factory_; | |
64 | |
65 DISALLOW_COPY_AND_ASSIGN(KioskAppIconLoader); | |
66 }; | |
67 | |
68 } // namespace chromeos | |
69 | |
70 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_ICON_LOADER_H_ | |
OLD | NEW |