Chromium Code Reviews| Index: chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc |
| diff --git a/chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc b/chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc |
| index 7a5f456ffc98a150b05541e4c90e5fd55e944951..46e49411019cbf501c383ca13106e1aace3443ec 100644 |
| --- a/chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc |
| +++ b/chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc |
| @@ -317,6 +317,23 @@ base::FilePath ArcAppListPrefs::GetIconPath( |
| return ToIconPath(GetAppPath(app_id), scale_factor); |
| } |
| +bool ArcAppListPrefs::IsIconRequestRecorded( |
| + const std::string& app_id, |
| + ui::ScaleFactor scale_factor) const { |
| + const auto iter = request_icon_recorded_.find(app_id); |
| + if (iter == request_icon_recorded_.end()) |
| + return false; |
| + return iter->second & 1 << scale_factor; |
|
Luis Héctor Chávez
2017/03/15 20:28:51
nit: (1 << scale_factor).
(even if the precedence
lgcheng
2017/03/15 22:05:33
Done.
|
| +} |
| + |
| +void ArcAppListPrefs::MaybeRemoveIconRequestRecord(const std::string& app_id) { |
| + request_icon_recorded_.erase(app_id); |
| +} |
| + |
| +void ArcAppListPrefs::ClearIconRequestRecord() { |
| + request_icon_recorded_.clear(); |
| +} |
| + |
| void ArcAppListPrefs::RequestIcon(const std::string& app_id, |
| ui::ScaleFactor scale_factor) { |
| // ArcSessionManager can be terminated during test tear down, before callback |
| @@ -330,12 +347,15 @@ void ArcAppListPrefs::RequestIcon(const std::string& app_id, |
| return; |
| } |
| - // In case app is not ready, defer this request. |
| - if (!ready_apps_.count(app_id)) { |
| - request_icon_deferred_[app_id] = |
| - request_icon_deferred_[app_id] | 1 << scale_factor; |
| + // In case app is not ready, recorded request will be send to ARC when app |
| + // becomes ready. |
| + // This record will prevent ArcAppIcon from resending request to ARC for app |
| + // when icon file decode failure is sufferd in case app sends bad icon. |
| + request_icon_recorded_[app_id] = |
| + request_icon_recorded_[app_id] | 1 << scale_factor; |
|
Luis Héctor Chávez
2017/03/15 20:28:51
same here: (1 << scale_factor)
lgcheng
2017/03/15 22:05:33
Done.
|
| + |
| + if (!ready_apps_.count(app_id)) |
| return; |
| - } |
| if (!app_instance_holder_->has_instance()) { |
| // AppInstance should be ready since we have app_id in ready_apps_. This |
| @@ -371,6 +391,12 @@ void ArcAppListPrefs::RequestIcon(const std::string& app_id, |
| } |
| } |
| +void ArcAppListPrefs::MaybeRequestIcon(const std::string& app_id, |
| + ui::ScaleFactor scale_factor) { |
| + if (!IsIconRequestRecorded(app_id, scale_factor)) |
| + RequestIcon(app_id, scale_factor); |
| +} |
| + |
| void ArcAppListPrefs::SetNotificationsEnabled(const std::string& app_id, |
| bool enabled) { |
| if (!IsRegistered(app_id)) { |
| @@ -739,6 +765,7 @@ void ArcAppListPrefs::OnInstanceClosed() { |
| default_apps_installations_.clear(); |
| detect_default_app_availability_timeout_.Stop(); |
| binding_.Close(); |
| + ClearIconRequestRecord(); |
| if (sync_service_) { |
| sync_service_->StopSyncing(syncer::ARC_PACKAGE); |
| @@ -837,14 +864,13 @@ void ArcAppListPrefs::AddAppAndShortcut( |
| } |
| if (app_ready) { |
| - auto deferred_icons = request_icon_deferred_.find(app_id); |
| - if (deferred_icons != request_icon_deferred_.end()) { |
| + auto deferred_icons = request_icon_recorded_.find(app_id); |
|
xiyuan
2017/03/15 20:30:26
nit: deferred_icons -> pending_icons
lgcheng
2017/03/15 22:05:33
Done.
|
| + if (deferred_icons != request_icon_recorded_.end()) { |
| for (uint32_t i = ui::SCALE_FACTOR_100P; i < ui::NUM_SCALE_FACTORS; ++i) { |
| if (deferred_icons->second & (1 << i)) { |
| RequestIcon(app_id, static_cast<ui::ScaleFactor>(i)); |
| } |
| } |
| - request_icon_deferred_.erase(deferred_icons); |
| } |
| bool deferred_notifications_enabled; |
| @@ -862,6 +888,8 @@ void ArcAppListPrefs::RemoveApp(const std::string& app_id) { |
| arc::RemoveCachedIcon(app_info->icon_resource_id); |
| } |
| + MaybeRemoveIconRequestRecord(app_id); |
| + |
| // From now, app is not available. |
| ready_apps_.erase(app_id); |