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

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: Improved integration test to also test case of visiting url after sync. 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..1f483a2676fa7b3f58da874df2d6868263b872b3 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 have never been visited by chromium (i.e. all visits
tim (not reviewing) 2011/10/22 05:37:14 'all visits that were imported'?
Andrew T Wilson (Slow) 2011/10/22 06:48:22 Done.
+ // are imported).
+ 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