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

Unified 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: address comments Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: components/arc/intent_helper/activity_icon_loader.h
diff --git a/components/arc/intent_helper/activity_icon_loader.h b/components/arc/intent_helper/activity_icon_loader.h
index 41d2ace9640a7a63f950b7199d965c3ce36fb3a2..aa40200588cff2a919a6383eee13f7389015e5a0 100644
--- a/components/arc/intent_helper/activity_icon_loader.h
+++ b/components/arc/intent_helper/activity_icon_loader.h
@@ -44,6 +44,19 @@ class ActivityIconLoader : public base::RefCounted<ActivityIconLoader> {
std::string activity_name;
};
+ enum class GetResult {
+ // Succeeded. The callback will be called asynchronously.
+ SUCCEEDED_ASYNC,
+ // Succeeded. The callback has already been called synchronously.
+ SUCCEEDED_SYNC,
+ // Failed. The intent_helper instance is not yet ready. This is a temporary
+ // error.
+ FAILED_ARC_NOT_READY,
+ // Failed. Either ARC is not supported at all or intent_helper instance
+ // version is too old.
+ FAILED_ARC_NOT_SUPPORTED,
+ };
+
using ActivityToIconsMap = std::map<ActivityName, Icons>;
using OnIconsReadyCallback =
base::Callback<void(std::unique_ptr<ActivityToIconsMap>)>;
@@ -55,17 +68,21 @@ class ActivityIconLoader : public base::RefCounted<ActivityIconLoader> {
// Retrieves icons for the |activities| and calls |cb|. The |cb| is called
// back exactly once, either synchronously in the GetActivityIcons() when
- // all icons were already cached locally, or asynchronously with icons fetched
- // from ARC side.
- // Returns true in the former synchronous case, where everything is done.
- bool GetActivityIcons(const std::vector<ActivityName>& activities,
- const OnIconsReadyCallback& cb);
+ // the result is _not_ SUCCEEDED_ASYNC (i.e. all icons are already cached
+ // locally or ARC is not ready/supported). Otherwise, the callback is run
+ // later asynchronously with icons fetched from ARC side.
+ GetResult GetActivityIcons(const std::vector<ActivityName>& activities,
+ const OnIconsReadyCallback& cb);
void OnIconsResizedForTesting(const OnIconsReadyCallback& cb,
std::unique_ptr<ActivityToIconsMap> result);
void AddIconToCacheForTesting(const ActivityName& activity,
const gfx::Image& image);
+ // Returns true if |result| indicates that the |cb| object passed to
+ // GetActivityIcons() has already called.
+ static bool HasIconsReadyCallbackRun(GetResult result);
+
const ActivityToIconsMap& cached_icons_for_testing() { return cached_icons_; }
private:
« no previous file with comments | « chrome/browser/task_management/providers/arc/arc_process_task.cc ('k') | components/arc/intent_helper/activity_icon_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698