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

Side by Side Diff: components/arc/intent_helper/activity_icon_loader.h

Issue 2034543003: Retry icon fetching after intent_helper is ready (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review Created 4 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
OLDNEW
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 COMPONENTS_ARC_INTENT_HELPER_ACTIVITY_ICON_LOADER_H_ 5 #ifndef COMPONENTS_ARC_INTENT_HELPER_ACTIVITY_ICON_LOADER_H_
6 #define COMPONENTS_ARC_INTENT_HELPER_ACTIVITY_ICON_LOADER_H_ 6 #define COMPONENTS_ARC_INTENT_HELPER_ACTIVITY_ICON_LOADER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
(...skipping 26 matching lines...) Expand all
37 37
38 // TODO(yusukes): Add const to these variables later. At this point, 38 // TODO(yusukes): Add const to these variables later. At this point,
39 // doing so seems to confuse g++ 4.6 on builders. 39 // doing so seems to confuse g++ 4.6 on builders.
40 std::string package_name; 40 std::string package_name;
41 41
42 // Can be empty. When |activity_name| is empty, the loader tries to fetch 42 // Can be empty. When |activity_name| is empty, the loader tries to fetch
43 // the package's default icon. 43 // the package's default icon.
44 std::string activity_name; 44 std::string activity_name;
45 }; 45 };
46 46
47 enum class GetResult {
48 // Succeeded. The callback will be called asynchronously.
49 SUCCEEDED_ASYNC,
50 // Succeeded. The callback has already been called synchronously.
51 SUCCEEDED_SYNC,
52 // Failed. The intent_helper instance is not yet ready. This is a temporary
53 // error.
54 FAILED_ARC_NOT_READY,
55 // Failed. Either ARC is not supported at all or intent_helper instance
56 // version is too old.
57 FAILED_ARC_NOT_SUPPORTED,
58 };
59
47 using ActivityToIconsMap = std::map<ActivityName, Icons>; 60 using ActivityToIconsMap = std::map<ActivityName, Icons>;
48 using OnIconsReadyCallback = 61 using OnIconsReadyCallback =
49 base::Callback<void(std::unique_ptr<ActivityToIconsMap>)>; 62 base::Callback<void(std::unique_ptr<ActivityToIconsMap>)>;
50 63
51 ActivityIconLoader(); 64 ActivityIconLoader();
52 65
53 // Removes icons associated with |package_name| from the cache. 66 // Removes icons associated with |package_name| from the cache.
54 void InvalidateIcons(const std::string& package_name); 67 void InvalidateIcons(const std::string& package_name);
55 68
56 // Retrieves icons for the |activities| and calls |cb|. The |cb| is called 69 // Retrieves icons for the |activities| and calls |cb|. The |cb| is called
57 // back exactly once, either synchronously in the GetActivityIcons() when 70 // back exactly once, either synchronously in the GetActivityIcons() when
58 // all icons were already cached locally, or asynchronously with icons fetched 71 // all icons were already cached locally, or asynchronously with icons fetched
59 // from ARC side. 72 // from ARC side.
60 // Returns true in the former synchronous case, where everything is done. 73 GetResult GetActivityIcons(const std::vector<ActivityName>& activities,
61 bool GetActivityIcons(const std::vector<ActivityName>& activities, 74 const OnIconsReadyCallback& cb);
62 const OnIconsReadyCallback& cb);
63 75
64 void OnIconsResizedForTesting(const OnIconsReadyCallback& cb, 76 void OnIconsResizedForTesting(const OnIconsReadyCallback& cb,
65 std::unique_ptr<ActivityToIconsMap> result); 77 std::unique_ptr<ActivityToIconsMap> result);
66 void AddIconToCacheForTesting(const ActivityName& activity, 78 void AddIconToCacheForTesting(const ActivityName& activity,
67 const gfx::Image& image); 79 const gfx::Image& image);
68 80
69 const ActivityToIconsMap& cached_icons_for_testing() { return cached_icons_; } 81 const ActivityToIconsMap& cached_icons_for_testing() { return cached_icons_; }
70 82
71 private: 83 private:
72 friend class base::RefCounted<ActivityIconLoader>; 84 friend class base::RefCounted<ActivityIconLoader>;
(...skipping 20 matching lines...) Expand all
93 ActivityToIconsMap cached_icons_; 105 ActivityToIconsMap cached_icons_;
94 106
95 base::ThreadChecker thread_checker_; 107 base::ThreadChecker thread_checker_;
96 108
97 DISALLOW_COPY_AND_ASSIGN(ActivityIconLoader); 109 DISALLOW_COPY_AND_ASSIGN(ActivityIconLoader);
98 }; 110 };
99 111
100 } // namespace arc 112 } // namespace arc
101 113
102 #endif // COMPONENTS_ARC_INTENT_HELPER_ACTIVITY_ICON_LOADER_H_ 114 #endif // COMPONENTS_ARC_INTENT_HELPER_ACTIVITY_ICON_LOADER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698