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

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

Issue 8370011: Now does not sync URLs that only have imported visits. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review feedback Created 9 years, 2 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/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 f49711f101f79bcbdb2b6b3c9965cc72ccdfc183..ed471d8718958be97549997a785f45d72d8b0781 100644
--- a/chrome/browser/sync/glue/typed_url_model_associator.cc
+++ b/chrome/browser/sync/glue/typed_url_model_associator.cc
@@ -100,6 +100,27 @@ bool TypedUrlModelAssociator::FixupURLAndGetVisits(
return true;
}
+bool TypedUrlModelAssociator::ShouldIgnoreUrl(
+ const history::URLRow& url, const history::VisitVector& visits) {
+ // We ignore URLs that where imported, but have never been visited by
+ // chromium.
+ static const int kLastImportedSource = history::SOURCE_EXTENSION;
+ history::VisitSourceMap map;
+ if (!history_backend_->GetVisitsSource(visits, &map))
+ return false; // If we can't read the visit, assume it's not imported.
+
+ // Walk the list of visits and look for a non-imported item.
+ for (history::VisitVector::const_iterator it = visits.begin();
+ it != visits.end(); ++it) {
+ if (map.count(it->visit_id) == 0 ||
+ map[it->visit_id] <= kLastImportedSource) {
+ return false;
+ }
+ }
+ // We only saw imported visits, so tell the caller to ignore them.
+ return true;
+}
+
bool TypedUrlModelAssociator::AssociateModels(SyncError* error) {
VLOG(1) << "Associating TypedUrl Models";
DCHECK(expected_loop_ == MessageLoop::current());
@@ -116,7 +137,7 @@ bool TypedUrlModelAssociator::AssociateModels(SyncError* error) {
// Get all the visits.
std::map<history::URLID, history::VisitVector> visit_vectors;
for (std::vector<history::URLRow>::iterator ix = typed_urls.begin();
- ix != typed_urls.end(); ++ix) {
+ ix != typed_urls.end();) {
if (IsAbortPending())
return false;
if (!FixupURLAndGetVisits(
@@ -124,6 +145,11 @@ bool TypedUrlModelAssociator::AssociateModels(SyncError* error) {
error->Reset(FROM_HERE, "Could not get the url's visits.", model_type());
return false;
}
+
+ if (ShouldIgnoreUrl(*ix, visit_vectors[ix->id()]))
+ ix = typed_urls.erase(ix);
+ else
+ ++ix;
}
TypedUrlTitleVector titles;

Powered by Google App Engine
This is Rietveld 408576698