| 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:
|
|
|