Bug 1301717 - Dispatch an event informing listeners that uri has been stored in history table r=sebastian
authorGrisha Kruglov <gkruglov@mozilla.com>
Thu, 27 Oct 2016 15:44:51 -0700
changeset 321099 03343ba4f57317cc78de05d7908a907b0dbfac9d
parent 321098 ee201a2c701f866de58d4b7bdcf5a2e116b847df
child 321100 5063c78131ec53ec5b272d4ee73de7e49b6ef08c
push id30919
push userphilringnalda@gmail.com
push dateSat, 05 Nov 2016 20:28:20 +0000
treeherdermozilla-central@572249b2ffb6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian
bugs1301717
milestone52.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1301717 - Dispatch an event informing listeners that uri has been stored in history table r=sebastian MozReview-Commit-ID: JHv6BO1rJsL
mobile/android/base/java/org/mozilla/gecko/GlobalHistory.java
--- a/mobile/android/base/java/org/mozilla/gecko/GlobalHistory.java
+++ b/mobile/android/base/java/org/mozilla/gecko/GlobalHistory.java
@@ -13,23 +13,27 @@ import java.util.Set;
 
 import org.mozilla.gecko.db.BrowserDB;
 import org.mozilla.gecko.reader.ReaderModeUtils;
 import org.mozilla.gecko.util.ThreadUtils;
 
 import android.content.ContentResolver;
 import android.content.Context;
 import android.database.Cursor;
+import android.os.Bundle;
 import android.os.Handler;
 import android.os.SystemClock;
 import android.util.Log;
 
 class GlobalHistory {
     private static final String LOGTAG = "GeckoGlobalHistory";
 
+    public static final String EVENT_URI_AVAILABLE_IN_HISTORY = "URI_INSERTED_TO_HISTORY";
+    public static final String EVENT_PARAM_URI = "uri";
+
     private static final String TELEMETRY_HISTOGRAM_ADD = "FENNEC_GLOBALHISTORY_ADD_MS";
     private static final String TELEMETRY_HISTOGRAM_UPDATE = "FENNEC_GLOBALHISTORY_UPDATE_MS";
     private static final String TELEMETRY_HISTOGRAM_BUILD_VISITED_LINK = "FENNEC_GLOBALHISTORY_VISITED_BUILD_MS";
 
     private static final GlobalHistory sInstance = new GlobalHistory();
 
     static GlobalHistory getInstance() {
         return sInstance;
@@ -123,16 +127,17 @@ class GlobalHistory {
         final String uriToStore = ReaderModeUtils.stripAboutReaderUrl(uri);
 
         db.updateVisitedHistory(context.getContentResolver(), uriToStore);
 
         final long end = SystemClock.uptimeMillis();
         final long took = end - start;
         Telemetry.addToHistogram(TELEMETRY_HISTOGRAM_ADD, (int) Math.min(took, Integer.MAX_VALUE));
         addToGeckoOnly(uriToStore);
+        dispatchUriAvailableMessage(uri);
     }
 
     @SuppressWarnings("static-method")
     public void update(final ContentResolver cr, final BrowserDB db, String uri, String title) {
         ThreadUtils.assertOnBackgroundThread();
         final long start = SystemClock.uptimeMillis();
 
         final String uriToStore = ReaderModeUtils.stripAboutReaderUrl(uri);
@@ -159,9 +164,15 @@ class GlobalHistory {
                     // no need to post another
                     return;
                 }
                 mProcessing = true;
                 mHandler.postDelayed(runnable, BATCHING_DELAY_MS);
             }
         });
     }
+
+    private void dispatchUriAvailableMessage(String uri) {
+        final Bundle message = new Bundle();
+        message.putString(EVENT_PARAM_URI, uri);
+        EventDispatcher.getInstance().dispatch(EVENT_URI_AVAILABLE_IN_HISTORY, message);
+    }
 }