author | Jim Chen <nchen@mozilla.com> |
Thu, 04 Aug 2016 09:17:54 -0400 | |
changeset 308206 | 79374eef5dcee186392595e1de8a4eea1c69ce67 |
parent 308205 | 40578d56c4ff22bb260209ee626372edd758de00 |
child 308207 | d327a34d94d723c5af2fdedb56bab22e6b7bc463 |
push id | 31092 |
push user | cbook@mozilla.com |
push date | Fri, 05 Aug 2016 10:16:59 +0000 |
treeherder | autoland@b97dd7dd3cb9 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | kitcambridge, snorp |
bugs | 1288821 |
milestone | 51.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
|
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/GeckoAppShell.java @@ -1058,22 +1058,16 @@ public class GeckoAppShell ALERT_COOKIES.put(aAlertName, aAlertCookie); callObserver(aAlertName, "alertshow", aAlertCookie); notificationClient.add(notificationID, aImageUrl, aHost, aAlertTitle, aAlertText, contentIntent, null); } @WrapForJNI - public static void alertsProgressListener_OnProgress(String aAlertName, long aProgress, long aProgressMax, String aAlertText) { - int notificationID = aAlertName.hashCode(); - notificationClient.update(notificationID, aProgress, aProgressMax, aAlertText); - } - - @WrapForJNI public static void closeNotification(String aAlertName) { String alertCookie = ALERT_COOKIES.get(aAlertName); if (alertCookie != null) { callObserver(aAlertName, "alertfinished", alertCookie); ALERT_COOKIES.remove(aAlertName); } removeObserver(aAlertName);
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/notifications/NotificationClient.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/notifications/NotificationClient.java @@ -17,62 +17,16 @@ import java.util.concurrent.ConcurrentHa * Client for posting notifications through a NotificationHandler. */ public abstract class NotificationClient { private static final String LOGTAG = "GeckoNotificationClient"; private volatile NotificationHandler mHandler; private boolean mReady; private final LinkedList<Runnable> mTaskQueue = new LinkedList<Runnable>(); - private final ConcurrentHashMap<Integer, UpdateRunnable> mUpdatesMap = - new ConcurrentHashMap<Integer, UpdateRunnable>(); - - /** - * Runnable that is reused between update notifications. - * - * Updates happen frequently, so reusing Runnables prevents frequent dynamic allocation. - */ - private class UpdateRunnable implements Runnable { - private long mProgress; - private long mProgressMax; - private String mAlertText; - final private int mNotificationID; - - public UpdateRunnable(int notificationID) { - mNotificationID = notificationID; - } - - public synchronized boolean updateProgress(long progress, long progressMax, String alertText) { - if (progress == mProgress - && mProgressMax == progressMax - && TextUtils.equals(mAlertText, alertText)) { - return false; - } - - mProgress = progress; - mProgressMax = progressMax; - mAlertText = alertText; - return true; - } - - @Override - public void run() { - long progress; - long progressMax; - String alertText; - - synchronized (this) { - progress = mProgress; - progressMax = mProgressMax; - alertText = mAlertText; - } - - mHandler.update(mNotificationID, progress, progressMax, alertText); - } - } /** * Adds a notification. * * @see NotificationHandler#add(int, String, String, String, String, PendingIntent, PendingIntent) */ public synchronized void add(final int notificationID, final String aImageUrl, final String aHost, final String aAlertTitle, final String aAlertText, @@ -105,54 +59,25 @@ public abstract class NotificationClient notify(); if (!mReady) { bind(); } } /** - * Updates a notification. - * - * @see NotificationHandler#update(int, long, long, String) - */ - public void update(final int notificationID, final long aProgress, final long aProgressMax, - final String aAlertText) { - UpdateRunnable runnable = mUpdatesMap.get(notificationID); - - if (runnable == null) { - runnable = new UpdateRunnable(notificationID); - mUpdatesMap.put(notificationID, runnable); - } - - // If we've already posted an update with these values, there's no - // need to do it again. - if (!runnable.updateProgress(aProgress, aProgressMax, aAlertText)) { - return; - } - - synchronized (this) { - if (mReady) { - mTaskQueue.add(runnable); - notify(); - } - } - } - - /** * Removes a notification. * * @see NotificationHandler#remove(int) */ public synchronized void remove(final int notificationID) { mTaskQueue.add(new Runnable() { @Override public void run() { mHandler.remove(notificationID); - mUpdatesMap.remove(notificationID); } }); // If mReady == false, we haven't added any notifications yet. That can happen if Fennec is being // started in response to clicking a notification. Call bind() to ensure the task we posted above is run. if (!mReady) { bind(); } @@ -171,17 +96,16 @@ public abstract class NotificationClient } protected void bind() { mReady = true; } protected void unbind() { mReady = false; - mUpdatesMap.clear(); } protected void connectHandler(NotificationHandler handler) { mHandler = handler; new Thread(new NotificationRunnable()).start(); } private class NotificationRunnable implements Runnable {
--- a/toolkit/components/alerts/nsAlertsService.cpp +++ b/toolkit/components/alerts/nsAlertsService.cpp @@ -137,17 +137,17 @@ ShowWithBackend(nsIAlertsService* aBacke // alert without one. return aBackend->ShowAlert(aAlert, aAlertListener); } #endif // MOZ_WIDGET_ANDROID } // anonymous namespace -NS_IMPL_ISUPPORTS(nsAlertsService, nsIAlertsService, nsIAlertsDoNotDisturb, nsIAlertsProgressListener) +NS_IMPL_ISUPPORTS(nsAlertsService, nsIAlertsService, nsIAlertsDoNotDisturb) nsAlertsService::nsAlertsService() : mBackend(nullptr) { #ifndef MOZ_WIDGET_ANDROID mBackend = do_GetService(NS_SYSTEMALERTSERVICE_CONTRACTID); #endif // MOZ_WIDGET_ANDROID } @@ -343,40 +343,16 @@ NS_IMETHODIMP nsAlertsService::SetManual nsresult rv = alertsDND->SetManualDoNotDisturb(aDoNotDisturb); if (NS_SUCCEEDED(rv)) { Telemetry::Accumulate(Telemetry::ALERTS_SERVICE_DND_ENABLED, 1); } return rv; #endif } -NS_IMETHODIMP nsAlertsService::OnProgress(const nsAString & aAlertName, - int64_t aProgress, - int64_t aProgressMax, - const nsAString & aAlertText) -{ -#ifdef MOZ_WIDGET_ANDROID - java::GeckoAppShell::AlertsProgressListener_OnProgress( - aAlertName, aProgress, aProgressMax, aAlertText); - return NS_OK; -#else - return NS_ERROR_NOT_IMPLEMENTED; -#endif // !MOZ_WIDGET_ANDROID -} - -NS_IMETHODIMP nsAlertsService::OnCancel(const nsAString & aAlertName) -{ -#ifdef MOZ_WIDGET_ANDROID - java::GeckoAppShell::CloseNotification(aAlertName); - return NS_OK; -#else - return NS_ERROR_NOT_IMPLEMENTED; -#endif // !MOZ_WIDGET_ANDROID -} - already_AddRefed<nsIAlertsDoNotDisturb> nsAlertsService::GetDNDBackend() { // Try the system notification service. nsCOMPtr<nsIAlertsService> backend = mBackend; if (!backend) { backend = nsXULAlerts::GetInstance(); }
--- a/toolkit/components/alerts/nsAlertsService.h +++ b/toolkit/components/alerts/nsAlertsService.h @@ -23,21 +23,19 @@ typedef enum tagMOZ_QUERY_USER_NOTIFICAT extern "C" { // This function is Windows Vista or later typedef HRESULT (__stdcall *SHQueryUserNotificationStatePtr)(MOZ_QUERY_USER_NOTIFICATION_STATE *pquns); } #endif // defined(XP_WIN) class nsAlertsService : public nsIAlertsService, - public nsIAlertsDoNotDisturb, - public nsIAlertsProgressListener + public nsIAlertsDoNotDisturb { public: - NS_DECL_NSIALERTSPROGRESSLISTENER NS_DECL_NSIALERTSDONOTDISTURB NS_DECL_NSIALERTSSERVICE NS_DECL_ISUPPORTS nsAlertsService(); protected: virtual ~nsAlertsService();
--- a/toolkit/components/alerts/nsIAlertsService.idl +++ b/toolkit/components/alerts/nsIAlertsService.idl @@ -217,46 +217,16 @@ interface nsIAlertsDoNotDisturb : nsISup * displaying them at all. If a system backend already supports a similar * feature controlled by the user, enabling this may not have any impact on * code to show an alert. e.g. on OS X, the system will take care not * disrupting a user if we simply create a notification like usual. */ attribute bool manualDoNotDisturb; }; -[scriptable, uuid(df1bd4b0-3a8c-40e6-806a-203f38b0bd9f)] -interface nsIAlertsProgressListener : nsISupports -{ - /** - * Called to notify the alert service that progress has occurred for the - * given notification previously displayed with showAlertNotification(). - * - * @param aName The name of the notification displaying the - * progress. On Android the name is hashed and used - * as a notification ID. - * @param aProgress Numeric value in the range 0 to progressMax - * indicating the current progress. - * @param aProgressMax Numeric value indicating the maximum progress. - * @param aText The contents of the alert. If not provided, - * the percentage will be displayed. - */ - void onProgress(in AString aName, - in long long aProgress, - in long long aProgressMax, - [optional] in AString aText); - - /** - * Called to cancel and hide the given notification previously displayed - * with showAlertNotification(). - * - * @param aName The name of the notification. - */ - void onCancel(in AString aName); -}; - [scriptable, uuid(fc6d7f0a-0cf6-4268-8c71-ab640842b9b1)] interface nsIAlertsIconData : nsISupports { /** * Shows an alert with an icon. Web notifications use the favicon of the * page that created the alert. If the favicon is not in the Places database, * |aIconSize| will be zero. */