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/files/file_path.h" | |
9 #include "base/memory/ref_counted_memory.h" | |
10 #include "base/memory/weak_ptr.h" | |
11 #include "base/sequenced_task_runner.h" | |
12 #include "ui/gfx/image/image_skia.h" | |
13 | |
14 namespace chromeos { | |
15 | |
16 // Loads locally stored icon data and decodes it. | |
17 class KioskAppIconLoader { | |
18 public: | |
19 enum LoadResult { | |
20 SUCCESS, | |
21 FAILED_TO_LOAD, | |
22 FAILED_TO_DECODE, | |
23 }; | |
24 | |
25 class Delegate { | |
26 public: | |
27 Delegate() = default; | |
28 | |
29 virtual void OnIconLoadSuccess(const gfx::ImageSkia& icon) = 0; | |
30 virtual void OnIconLoadFailure() = 0; | |
31 | |
32 protected: | |
33 virtual ~Delegate() = default; | |
34 | |
35 private: | |
36 DISALLOW_COPY_AND_ASSIGN(Delegate); | |
37 }; | |
38 | |
39 KioskAppIconLoader(const base::WeakPtr<Delegate>& client, | |
40 const base::FilePath& icon_path); | |
41 | |
42 void Start(); | |
43 | |
44 private: | |
45 friend class base::RefCountedThreadSafe<KioskAppIconLoader>; | |
46 | |
47 class IconImageRequest; | |
48 | |
49 ~KioskAppIconLoader(); | |
50 | |
51 // Loads the icon from locally stored |icon_path_| on the blocking pool | |
52 void LoadOnBlockingPool(); | |
53 void ReportResultOnBlockingPool(LoadResult result); | |
54 void NotifyClient(); | |
55 void ReportResultOnUIThread(); | |
56 | |
57 base::WeakPtr<Delegate> client_; | |
xiyuan
2017/03/28 16:50:09
nit: client_ -> delegate_ or Delegate -> Client to
Sergey Poromov
2017/03/29 16:03:44
Done.
| |
58 base::FilePath icon_path_; | |
xiyuan
2017/03/28 16:50:09
nit: Make LoadOnBlockingPool take a const base::Fi
Sergey Poromov
2017/03/29 16:03:44
Done.
| |
59 | |
60 LoadResult load_result_; | |
xiyuan
2017/03/28 16:50:10
nit: Make NotifyClient take a LoadResult and get r
Sergey Poromov
2017/03/29 16:03:44
Done.
| |
61 scoped_refptr<base::SequencedTaskRunner> task_runner_; | |
62 | |
63 gfx::ImageSkia icon_; | |
64 scoped_refptr<base::RefCountedString> raw_icon_; | |
65 | |
66 DISALLOW_COPY_AND_ASSIGN(KioskAppIconLoader); | |
67 }; | |
68 | |
69 } // namespace chromeos | |
70 | |
71 #endif // CHROME_BROWSER_CHROMEOS_APP_MODE_KIOSK_APP_ICON_LOADER_H_ | |
OLD | NEW |