Bug 972306 - Rename HomePanels:Refresh to HomePanels:Update (r=margaret)
authorLucas Rocha <lucasr@mozilla.com>
Fri, 21 Feb 2014 10:33:59 +0000
changeset 170373 94f30bed3a45e085331600e16940654d181fa3f4
parent 170372 c1020c48b5b257ab4f9ea632f6db21726e5d4590
child 170374 a59fedc3791f9a707548d1d555128745e16245c8
push id270
push userpvanderbeken@mozilla.com
push dateThu, 06 Mar 2014 09:24:21 +0000
reviewersmargaret
bugs972306
milestone30.0a1
Bug 972306 - Rename HomePanels:Refresh to HomePanels:Update (r=margaret)
mobile/android/base/home/HomeConfigInvalidator.java
--- a/mobile/android/base/home/HomeConfigInvalidator.java
+++ b/mobile/android/base/home/HomeConfigInvalidator.java
@@ -34,25 +34,25 @@ public class HomeConfigInvalidator imple
 
     private static final HomeConfigInvalidator sInstance = new HomeConfigInvalidator();
 
     private static final int INVALIDATION_DELAY_MSEC = 500;
     private static final int PANEL_INFO_TIMEOUT_MSEC = 1000;
 
     private static final String EVENT_HOMEPANELS_INSTALL = "HomePanels:Install";
     private static final String EVENT_HOMEPANELS_UNINSTALL = "HomePanels:Uninstall";
-    private static final String EVENT_HOMEPANELS_REFRESH = "HomePanels:Refresh";
+    private static final String EVENT_HOMEPANELS_UPDATE = "HomePanels:Update";
 
     private static final String JSON_KEY_PANEL = "panel";
     private static final String JSON_KEY_PANEL_ID = "id";
 
     private enum ChangeType {
         UNINSTALL,
         INSTALL,
-        REFRESH
+        UPDATE
     }
 
     private static class ConfigChange {
         private final ChangeType type;
         private final Object target;
 
         public ConfigChange(ChangeType type, Object target) {
             this.type = type;
@@ -71,36 +71,36 @@ public class HomeConfigInvalidator imple
     }
 
     public void init(Context context) {
         mContext = context;
         mHomeConfig = HomeConfig.getDefault(context);
 
         GeckoAppShell.getEventDispatcher().registerEventListener(EVENT_HOMEPANELS_INSTALL, this);
         GeckoAppShell.getEventDispatcher().registerEventListener(EVENT_HOMEPANELS_UNINSTALL, this);
-        GeckoAppShell.getEventDispatcher().registerEventListener(EVENT_HOMEPANELS_REFRESH, this);
+        GeckoAppShell.getEventDispatcher().registerEventListener(EVENT_HOMEPANELS_UPDATE, this);
     }
 
     public void refreshAll() {
-        handlePanelRefresh(null);
+        handlePanelUpdate(null);
     }
 
     @Override
     public void handleMessage(String event, JSONObject message) {
         try {
             if (event.equals(EVENT_HOMEPANELS_INSTALL)) {
                 Log.d(LOGTAG, EVENT_HOMEPANELS_INSTALL);
                 handlePanelInstall(createPanelConfigFromMessage(message));
             } else if (event.equals(EVENT_HOMEPANELS_UNINSTALL)) {
                 Log.d(LOGTAG, EVENT_HOMEPANELS_UNINSTALL);
                 final String panelId = message.getString(JSON_KEY_PANEL_ID);
                 handlePanelUninstall(panelId);
-            } else if (event.equals(EVENT_HOMEPANELS_REFRESH)) {
-                Log.d(LOGTAG, EVENT_HOMEPANELS_REFRESH);
-                handlePanelRefresh(createPanelConfigFromMessage(message));
+            } else if (event.equals(EVENT_HOMEPANELS_UPDATE)) {
+                Log.d(LOGTAG, EVENT_HOMEPANELS_UPDATE);
+                handlePanelUpdate(createPanelConfigFromMessage(message));
             }
         } catch (Exception e) {
             Log.e(LOGTAG, "Failed to handle event " + event, e);
         }
     }
 
     private PanelConfig createPanelConfigFromMessage(JSONObject message) throws JSONException {
         final JSONObject json = message.getJSONObject(JSON_KEY_PANEL);
@@ -123,24 +123,24 @@ public class HomeConfigInvalidator imple
     private void handlePanelUninstall(String panelId) {
         mPendingChanges.offer(new ConfigChange(ChangeType.UNINSTALL, panelId));
         Log.d(LOGTAG, "handlePanelUninstall: " + mPendingChanges.size());
 
         scheduleInvalidation();
     }
 
     /**
-     * Schedules a panel refresh in HomeConfig. Runs in the gecko thread.
+     * Schedules a panel update in HomeConfig. Runs in the gecko thread.
      *
      * @param panelConfig the target PanelConfig instance or NULL to refresh
      *                    all HomeConfig entries.
      */
-    private void handlePanelRefresh(PanelConfig panelConfig) {
-        mPendingChanges.offer(new ConfigChange(ChangeType.REFRESH, panelConfig));
-        Log.d(LOGTAG, "handlePanelRefresh: " + mPendingChanges.size());
+    private void handlePanelUpdate(PanelConfig panelConfig) {
+        mPendingChanges.offer(new ConfigChange(ChangeType.UPDATE, panelConfig));
+        Log.d(LOGTAG, "handlePanelUpdate: " + mPendingChanges.size());
 
         scheduleInvalidation();
     }
 
     /**
      * Runs in the gecko or main thread.
      */
     private void scheduleInvalidation() {
@@ -201,21 +201,21 @@ public class HomeConfigInvalidator imple
                     final PanelConfig panelConfig = (PanelConfig) pendingChange.target;
                     if (!replacePanelConfig(panelConfigs, panelConfig)) {
                         panelConfigs.add(panelConfig);
                         Log.d(LOGTAG, "executePendingChanges: added panel " + panelConfig.getId());
                     }
                     break;
                 }
 
-                case REFRESH: {
+                case UPDATE: {
                     final PanelConfig panelConfig = (PanelConfig) pendingChange.target;
                     if (panelConfig != null) {
                         if (!replacePanelConfig(panelConfigs, panelConfig)) {
-                            Log.w(LOGTAG, "Tried to refresh non-existing panel " + panelConfig.getId());
+                            Log.w(LOGTAG, "Tried to update non-existing panel " + panelConfig.getId());
                         }
                     } else {
                         shouldRefreshAll = true;
                     }
                     break;
                 }
             }
         }