[invalidations] Add the scaffolding for NetworkChannel logging

This patch adds the possibilty of retrieving and displaying internal
state from the  underlying NetworkChannel. This is done via asynchronous
calls from the UI to the IO and back, retrieving a DictionaryValue
composed of whatever is added to it in SyncEventListener, in order to
make it easily extensible for logging additional internal states.

So far, it only shows the underlying unacked invalidations map, but in
following patches, this will also contain internal network channel
implementation details (either XMPP or GCM).

BUG=263863

Review URL: https://codereview.chromium.org/182253006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@257555 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/resources/about_invalidations.js b/chrome/browser/resources/about_invalidations.js
index 65c406c..572c20bd 100644
--- a/chrome/browser/resources/about_invalidations.js
+++ b/chrome/browser/resources/about_invalidations.js
@@ -6,7 +6,8 @@
   /**
    * Local variable where we maintain a count of the invalidations received
    * and of every ObjectId that has ever been updated (note that this doesn't
-   * log any invalidations ocurred prior to opening the about:invalidation page)
+   * log any invalidations ocurred prior to opening the about:invalidation
+   * page).
    */
   var tableObjects = {};
 
@@ -42,10 +43,10 @@
   }
 
   /**
-   * Shows the current state of the InvalidatorService
+   * Shows the current state of the InvalidatorService.
    * @param {string} newState The string to be displayed and logged.
    */
-  function updateState(newState) {
+  function updateInvalidatorState(newState) {
     var logMessage = nowTimeString() +
       'Invalidations service state changed to ' + quote(newState);
 
@@ -162,19 +163,32 @@
   }
 
   /**
-   * Function that notifies the Invalidator Logger that the UI is
+   * Update the internal status display.
+   * @param {!Object} details The dictionary containing assorted debugging
+   *      details (e.g. Network Channel information).
+   */
+  function updateDetailedStatus(details) {
+    $('internal-display').value = JSON.stringify(details, null, 2);
+  }
+
+  /**
+   * Function that notifies the InvalidationsMessageHandler that the UI is
    * ready to receive real-time notifications.
    */
   function onLoadWork() {
+    $('request-detailed-status').onclick = function() {
+      chrome.send('requestDetailedStatus');
+    };
     chrome.send('doneLoading');
   }
 
   return {
     logInvalidations: logInvalidations,
     onLoadWork: onLoadWork,
+    updateDetailedStatus: updateDetailedStatus,
     updateHandlers: updateHandlers,
     updateIds: updateIds,
-    updateState: updateState,
+    updateInvalidatorState: updateInvalidatorState,
   };
 });