--- a/mobile/android/base/java/org/mozilla/gecko/db/BrowserProvider.java
+++ b/mobile/android/base/java/org/mozilla/gecko/db/BrowserProvider.java
@@ -176,17 +176,21 @@ public class BrowserProvider extends Sha
map = new HashMap<String, String>();
map.put(History._ID, History._ID);
map.put(History.TITLE, History.TITLE);
map.put(History.URL, History.URL);
map.put(History.FAVICON, History.FAVICON);
map.put(History.FAVICON_ID, History.FAVICON_ID);
map.put(History.FAVICON_URL, History.FAVICON_URL);
map.put(History.VISITS, History.VISITS);
+ map.put(History.LOCAL_VISITS, History.LOCAL_VISITS);
+ map.put(History.REMOTE_VISITS, History.REMOTE_VISITS);
map.put(History.DATE_LAST_VISITED, History.DATE_LAST_VISITED);
+ map.put(History.LOCAL_DATE_LAST_VISITED, History.LOCAL_DATE_LAST_VISITED);
+ map.put(History.REMOTE_DATE_LAST_VISITED, History.REMOTE_DATE_LAST_VISITED);
map.put(History.DATE_CREATED, History.DATE_CREATED);
map.put(History.DATE_MODIFIED, History.DATE_MODIFIED);
map.put(History.GUID, History.GUID);
map.put(History.IS_DELETED, History.IS_DELETED);
HISTORY_PROJECTION_MAP = Collections.unmodifiableMap(map);
// Visits
URI_MATCHER.addURI(BrowserContract.AUTHORITY, "visits", VISITS);
@@ -1382,19 +1386,25 @@ public class BrowserProvider extends Sha
private int updateOrInsertHistory(Uri uri, ContentValues values, String selection,
String[] selectionArgs) {
final int updated = updateHistory(uri, values, selection, selectionArgs);
if (updated > 0) {
return updated;
}
- // Insert a new entry if necessary
+ // Insert a new entry if necessary, setting visit and date aggregate values.
if (!values.containsKey(History.VISITS)) {
values.put(History.VISITS, 1);
+ values.put(History.LOCAL_VISITS, 1);
+ } else {
+ values.put(History.LOCAL_VISITS, values.getAsInteger(History.VISITS));
+ }
+ if (values.containsKey(History.DATE_LAST_VISITED)) {
+ values.put(History.LOCAL_DATE_LAST_VISITED, values.getAsLong(History.DATE_LAST_VISITED));
}
if (!values.containsKey(History.TITLE)) {
values.put(History.TITLE, values.getAsString(History.URL));
}
if (0 <= insertHistory(uri, values)) {
return 1;
}
@@ -1415,22 +1425,27 @@ public class BrowserProvider extends Sha
// Use the simple code path for easy updates.
if (!shouldIncrementVisits(uri)) {
trace("Updating history meta data only");
return db.update(TABLE_HISTORY, values, selection, selectionArgs);
}
trace("Updating history meta data and incrementing visits");
+ if (values.containsKey(History.DATE_LAST_VISITED)) {
+ values.put(History.LOCAL_DATE_LAST_VISITED, values.getAsLong(History.DATE_LAST_VISITED));
+ }
+
// Update data and increment visits by 1.
final long incVisits = 1;
// Create a separate set of values that will be updated as an expression.
final ContentValues visits = new ContentValues();
visits.put(History.VISITS, History.VISITS + " + " + incVisits);
+ visits.put(History.LOCAL_VISITS, History.LOCAL_VISITS + " + " + incVisits);
final ContentValues[] valuesAndVisits = { values, visits };
final UpdateOperation[] ops = { UpdateOperation.ASSIGN, UpdateOperation.EXPRESSION };
return DBUtils.updateArrays(db, TABLE_HISTORY, valuesAndVisits, ops, selection, selectionArgs);
}
private long insertVisitForHistory(Uri uri, ContentValues values, String selection, String[] selectionArgs) {