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

Unified Diff: chrome/browser/ui/app_list/chrome_app_list_item.cc

Issue 2614803002: Prevent appearing INVALID position ordinal in sync. (Closed)
Patch Set: update_unit_tests Created 3 years, 11 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: chrome/browser/ui/app_list/chrome_app_list_item.cc
diff --git a/chrome/browser/ui/app_list/chrome_app_list_item.cc b/chrome/browser/ui/app_list/chrome_app_list_item.cc
index 934638ff7118a014ef787076e99404cc43c8c956..ca281a192f3bb424622a8c43bf4c88880888f7ff 100644
--- a/chrome/browser/ui/app_list/chrome_app_list_item.cc
+++ b/chrome/browser/ui/app_list/chrome_app_list_item.cc
@@ -62,10 +62,16 @@ void ChromeAppListItem::UpdateFromSync(
void ChromeAppListItem::SetDefaultPositionIfApplicable() {
syncer::StringOrdinal page_ordinal;
syncer::StringOrdinal launch_ordinal;
- if (GetAppSorting()->GetDefaultOrdinals(id(), &page_ordinal,
- &launch_ordinal) &&
- page_ordinal.IsValid() && launch_ordinal.IsValid()) {
- set_position(syncer::StringOrdinal(page_ordinal.ToInternalValue() +
- launch_ordinal.ToInternalValue()));
+ extensions::AppSorting* app_sorting = GetAppSorting();
+ if (!app_sorting->GetDefaultOrdinals(id(), &page_ordinal,
+ &launch_ordinal) ||
+ !page_ordinal.IsValid() || !launch_ordinal.IsValid()) {
+ app_sorting->EnsureValidOrdinals(id(), syncer::StringOrdinal());
+ page_ordinal = app_sorting->GetPageOrdinal(id());
+ launch_ordinal = app_sorting->GetAppLaunchOrdinal(id());
}
+ DCHECK(page_ordinal.IsValid());
+ DCHECK(launch_ordinal.IsValid());
+ set_position(syncer::StringOrdinal(page_ordinal.ToInternalValue() +
+ launch_ordinal.ToInternalValue()));
}

Powered by Google App Engine
This is Rietveld 408576698