Commit c9d051c8 authored by nancy's avatar nancy Committed by Commit Bot

Fix the icon load issue when Playstore is off and on.

When Playstore is removed, OnAppStatesChanged is called, and then
OnAppRemoved is called.
1: Playstore removed  2: OnAppStatesChanged 3: OnAppRemoved

When OnAppStatesChanged is called, ArcApps updates the icon key, so
AppServiceAppItem and AppServiceAppIconLoader reload icon with mojom.
1: Playstore removed
2: OnAppStatesChanged -> AppServiceAppItem::LoadIcon
                      -> AppServiceAppIconLoader::LoadIcon

Before ArcApps receives the load calls, ArcIconOnceLoader's
OnAppRemoved has clear the ArcAppIcon. So when ArcIconOnceLoader
receives the load icon calls from AppServiceAppItem and
AppServiceAppIconLoader, ArcIconOnceLoader won't clear the ArcAppIcon
again, and ArcIconOnceLoader still calls ArcIconOnceLoader to
load icon.
1: Playstore removed
2: OnAppStatesChanged -> AppServiceAppItem::LoadIcon
                      -> AppServiceAppIconLoader::LoadIcon
3: OnAppRemoved -> ArcIconOnceLoader::OnAppRemoved
4: ArcIconOnceLoader::LoadIcon -> Create ArcAppIcon to load icon

However, the ARC apps have been removed, so ArcAppIcon can't load the
icon, and ArcIconOnceLoader and IconCoalescer just keep waiting the icon
load result.

Modify ArcApps, when the app has been removed, don't call
ArcIconOnceLoader to load the icon.

Tried to update ArcAppIcon to return result when time out, but that
method doesn't work. Because when Playstore is re-enabled,
MaybeRequestIcon should be called to ask Arc pref to reload the icon,
but ArcIconOnceLoader doesn't know when the app is re-installed, so it
can't call MaybeRequestIcon to reload the icon, so when Playstore is
re-enabled, it still can't load the icon.

b:149229735

Change-Id: I2ac61fe598f9e9d0314a248150f8897c3eb57e83
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2072337
Commit-Queue: Nancy Wang <nancylingwang@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#750449}
parent 7545fd48
...@@ -470,6 +470,18 @@ void ArcApps::LoadIcon(const std::string& app_id, ...@@ -470,6 +470,18 @@ void ArcApps::LoadIcon(const std::string& app_id,
LoadPlayStoreIcon(icon_compression, size_hint_in_dip, icon_effects, LoadPlayStoreIcon(icon_compression, size_hint_in_dip, icon_effects,
std::move(callback)); std::move(callback));
} else { } else {
const ArcAppListPrefs* arc_prefs = ArcAppListPrefs::Get(profile_);
DCHECK(arc_prefs);
// If the app has been removed, immediately terminate the icon request since
// it can't possibly succeed.
std::unique_ptr<ArcAppListPrefs::AppInfo> app_info =
arc_prefs->GetApp(app_id);
if (!app_info) {
std::move(callback).Run(apps::mojom::IconValue::New());
return;
}
arc_icon_once_loader_.LoadIcon( arc_icon_once_loader_.LoadIcon(
app_id, size_hint_in_dip, icon_compression, app_id, size_hint_in_dip, icon_compression,
base::BindOnce(&OnArcAppIconCompletelyLoaded, icon_compression, base::BindOnce(&OnArcAppIconCompletelyLoaded, icon_compression,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment