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

Unified Diff: components/history/core/browser/typed_url_sync_bridge.h

Issue 2961723003: [USS] Implement ApplySyncChanges and OnURLVisited/Modified/Deleted. (Closed)
Patch Set: Created 3 years, 6 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: components/history/core/browser/typed_url_sync_bridge.h
diff --git a/components/history/core/browser/typed_url_sync_bridge.h b/components/history/core/browser/typed_url_sync_bridge.h
index 13a8bbd9bc542c06a0f4c68fa0f0dca6485f5844..2d836c87b114c091e8c07facce7c63534aa7416f 100644
--- a/components/history/core/browser/typed_url_sync_bridge.h
+++ b/components/history/core/browser/typed_url_sync_bridge.h
@@ -102,6 +102,16 @@ class TypedURLSyncBridge : public syncer::ModelTypeSyncBridge,
history::URLRow* new_url,
std::vector<history::VisitInfo>* new_visits);
+ // Diffs the set of visits between the history DB and the sync DB, using the
+ // sync DB as the canonical copy. Result is the set of |new_visits| and
+ // |removed_visits| that can be applied to the history DB to make it match
+ // the sync DB version. |removed_visits| can be null if the caller does not
+ // care about which visits to remove.
+ static void DiffVisits(const history::VisitVector& history_visits,
+ const sync_pb::TypedUrlSpecifics& sync_specifics,
+ std::vector<history::VisitInfo>* new_visits,
+ history::VisitVector* removed_visits);
+
// Fills |new_url| with formatted data from |typed_url|.
static void UpdateURLRowFromTypedUrlSpecifics(
const sync_pb::TypedUrlSpecifics& typed_url,
@@ -118,12 +128,31 @@ class TypedURLSyncBridge : public syncer::ModelTypeSyncBridge,
// Compares |server_typed_url| from the server against local history to decide
// how to merge any existing data, and updates appropriate data containers to
// write to server and backend.
- void UpdateUrlFromServer(const sync_pb::TypedUrlSpecifics& server_typed_url,
- TypedURLMap* local_typed_urls,
- URLVisitVectorMap* visit_vectors,
- history::URLRows* new_synced_urls,
- TypedURLVisitVector* new_synced_visits,
- history::URLRows* updated_synced_urls);
+ void MergeURLWithSync(const sync_pb::TypedUrlSpecifics& server_typed_url,
+ TypedURLMap* local_typed_urls,
+ URLVisitVectorMap* visit_vectors,
+ history::URLRows* new_synced_urls,
+ TypedURLVisitVector* new_synced_visits,
+ history::URLRows* updated_synced_urls);
+
+ // Given a typed URL in the sync DB, looks for an existing entry in the
+ // local history DB and generates a list of visits to add to the
+ // history DB to bring it up to date (avoiding duplicates).
+ // Updates the passed |visits_to_add| and |visits_to_remove| vectors with the
+ // visits to add to/remove from the history DB, and adds a new entry to either
+ // |updated_urls| or |new_urls| depending on whether the URL already existed
+ // in the history DB.
+ void UpdateFromSync(const sync_pb::TypedUrlSpecifics& typed_url,
+ TypedURLVisitVector* visits_to_add,
+ history::VisitVector* visits_to_remove,
+ history::URLRows* updated_urls,
+ history::URLRows* new_urls);
+
+ // Utility routine that either updates an existing sync node or creates a
+ // new one for the passed |typed_url| if one does not already exist. Returns
+ // false and sets an unrecoverable error if the operation failed.
pavely 2017/07/06 19:28:29 I don't think it sets unrecoverable error anymore.
Gang Wu 2017/07/10 19:53:25 Done.
+ bool UpdateSyncFromLocal(URLRow typed_url,
+ syncer::MetadataChangeList* metadata_change_list);
pavely 2017/07/06 19:28:29 I don't think callers check return value of this f
Gang Wu 2017/07/10 19:53:25 Done.
// Writes new typed url data from sync server to history backend.
base::Optional<syncer::ModelError> WriteToHistoryBackend(
@@ -147,6 +176,12 @@ class TypedURLSyncBridge : public syncer::ModelTypeSyncBridge,
// of sync, based on the visits the URL had.
bool ShouldIgnoreVisits(const history::VisitVector& visits);
+ // Returns true if the caller should sync as a result of the passed visit
+ // notification. We use this to throttle the number of sync changes we send
+ // to the server so we don't hit the server for every
+ // single typed URL visit.
+ bool ShouldSyncVisit(int typed_count, ui::PageTransition transition);
+
// Fetches visits from the history DB corresponding to the passed URL. This
// function compensates for the fact that the history DB has rather poor data
// integrity (duplicate visits, visit timestamps that don't match the

Powered by Google App Engine
This is Rietveld 408576698