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

Unified Diff: chrome/browser/sync/glue/typed_url_model_associator.cc

Issue 7747040: Now gracefully deals with TypedURLs with no typed visits. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 4 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
« no previous file with comments | « no previous file | chrome/browser/sync/glue/typed_url_model_associator_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/glue/typed_url_model_associator.cc
diff --git a/chrome/browser/sync/glue/typed_url_model_associator.cc b/chrome/browser/sync/glue/typed_url_model_associator.cc
index bcb1a434f67bfb8d6f132602e59d350e216fa968..363695ca61d7c0797cdab77d92ba76b4c2e6e634 100644
--- a/chrome/browser/sync/glue/typed_url_model_associator.cc
+++ b/chrome/browser/sync/glue/typed_url_model_associator.cc
@@ -588,6 +588,11 @@ void TypedUrlModelAssociator::WriteToTypedUrlSpecifics(
if (transition == PageTransition::TYPED)
++typed_count;
}
+ // We should have at least one typed visit. This can sometimes happen if
+ // the history DB has an inaccurate count for some reason (there's been
+ // bugs in the history code in the past which has left users in the wild
+ // with incorrect counts - http://crbug.com/84258).
+ DCHECK(typed_count > 0);
if (typed_count > kMaxTypedUrlVisits) {
only_typed = true;
@@ -622,6 +627,16 @@ void TypedUrlModelAssociator::WriteToTypedUrlSpecifics(
typed_url->add_visit_transitions(visit->transition);
}
DCHECK_EQ(skip_count, 0);
+
+ if (typed_url->visits_size() == 0) {
+ // If we get here, it's because we don't actually have any TYPED visits
+ // even though the visit's typed_count > 0 (corrupted typed_count). So
+ // let's go ahead and add a RELOAD visit at the most recent visit since
+ // it's not legal to have an empty visit array (yet another workaround
+ // for http://crbug.com/84258).
+ typed_url->add_visits(url.last_visit().ToInternalValue());
+ typed_url->add_visit_transitions(PageTransition::RELOAD);
+ }
CHECK_GT(typed_url->visits_size(), 0);
CHECK_LE(typed_url->visits_size(), kMaxTypedUrlVisits);
CHECK_EQ(typed_url->visits_size(), typed_url->visit_transitions_size());
« no previous file with comments | « no previous file | chrome/browser/sync/glue/typed_url_model_associator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698