Bug 1046709 - Part 6: Remove remote visits when FxAccount is deleted r=nalexander,rnewman draft
authorGrigory Kruglov <gkruglov@mozilla.com>
Thu, 07 Apr 2016 19:04:22 -0400
changeset 348940 43d3d9d68053efbb2b6e7011be43cafed12614c1
parent 348939 29757bebea3bef54f77d7f84c457f7b8a36ed7e3
child 348941 6b5070ee8ae91a5c34d877f6c037bcf61799201d
push id14965
push usergkruglov@mozilla.com
push dateFri, 08 Apr 2016 14:53:11 +0000
reviewersnalexander, rnewman
bugs1046709
milestone48.0a1
Bug 1046709 - Part 6: Remove remote visits when FxAccount is deleted r=nalexander,rnewman MozReview-Commit-ID: GLq9qI1osPi
mobile/android/services/src/main/java/org/mozilla/gecko/fxa/receivers/FxAccountDeletedService.java
--- a/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/receivers/FxAccountDeletedService.java
+++ b/mobile/android/services/src/main/java/org/mozilla/gecko/fxa/receivers/FxAccountDeletedService.java
@@ -5,20 +5,20 @@
 package org.mozilla.gecko.fxa.receivers;
 
 import java.util.concurrent.Executor;
 
 import org.mozilla.gecko.background.common.log.Logger;
 import org.mozilla.gecko.background.fxa.oauth.FxAccountAbstractClient;
 import org.mozilla.gecko.background.fxa.oauth.FxAccountAbstractClientException.FxAccountAbstractClientRemoteException;
 import org.mozilla.gecko.background.fxa.oauth.FxAccountOAuthClient10;
+import org.mozilla.gecko.db.BrowserContract;
 import org.mozilla.gecko.fxa.FxAccountConstants;
 import org.mozilla.gecko.fxa.sync.FxAccountNotificationManager;
 import org.mozilla.gecko.fxa.sync.FxAccountSyncAdapter;
-import org.mozilla.gecko.sync.repositories.android.AndroidBrowserHistoryDataExtender;
 import org.mozilla.gecko.sync.repositories.android.ClientsDatabase;
 import org.mozilla.gecko.sync.repositories.android.FennecTabsRepository;
 
 import android.app.IntentService;
 import android.content.Context;
 import android.content.Intent;
 
 /**
@@ -82,31 +82,23 @@ public class FxAccountDeletedService ext
         if (db != null) {
           db.close();
         }
       }
     } catch (Exception e) {
       Logger.warn(LOG_TAG, "Got exception deleting the Firefox Sync clients database; ignoring.", e);
     }
 
-    // Clear Firefox Sync history data table.
-    try {
-      Logger.info(LOG_TAG, "Deleting the Firefox Sync extended history database.");
-      AndroidBrowserHistoryDataExtender historyDataExtender = null;
-      try {
-        historyDataExtender = new AndroidBrowserHistoryDataExtender(context);
-        historyDataExtender.wipe();
-      } finally {
-        if (historyDataExtender != null) {
-          historyDataExtender.close();
-        }
-      }
-    } catch (Exception e) {
-      Logger.warn(LOG_TAG, "Got exception deleting the Firefox Sync extended history database; ignoring.", e);
-    }
+    // Delete visits we have received from Sync (anything marked as "remote").
+    // Note that we do not adjust "visits" counter on history records themselves.
+    int visitsDeleted = context.getContentResolver().delete(
+            BrowserContract.Visits.CONTENT_URI,
+            BrowserContract.Visits.IS_LOCAL + " = 0", null
+    );
+    Logger.info(LOG_TAG, "Deleted " + visitsDeleted + " remote visits.");
 
     // Remove any displayed notifications.
     new FxAccountNotificationManager(FxAccountSyncAdapter.NOTIFICATION_ID).clear(context);
 
     // Bug 1147275: Delete cached oauth tokens. There's no way to query all
     // oauth tokens from Android, so this is tricky to do comprehensively. We
     // can query, individually, for specific oauth tokens to delete, however.
     final String oauthServerURI = intent.getStringExtra(FxAccountConstants.ACCOUNT_OAUTH_SERVICE_ENDPOINT_KEY);