appcache: add token expires to chrome://appcache-internals

As of this CL, the ui shows the group and entry expiration date.
There is also a token_expires stored for cache and namespaces (both
fallback and intercept), but there's not a space for that on the UI.

Bug: 582750
Change-Id: Iaa63e80aa2f00d93c4da61f5d03e58d832208857
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2132592
Commit-Queue: Victor Costan <pwnall@chromium.org>
Reviewed-by: Victor Costan <pwnall@chromium.org>
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#755671}
diff --git a/content/browser/appcache/appcache.cc b/content/browser/appcache/appcache.cc
index f823298..52f9bcd1 100644
--- a/content/browser/appcache/appcache.cc
+++ b/content/browser/appcache/appcache.cc
@@ -341,6 +341,7 @@
     info.response_size = pair.second.response_size();
     info.padding_size = pair.second.padding_size();
     info.response_id = pair.second.response_id();
+    info.token_expires = pair.second.token_expires();
   }
 }
 
diff --git a/content/browser/appcache/appcache_internals_ui.cc b/content/browser/appcache/appcache_internals_ui.cc
index 0d23b0a..7e9f65c 100644
--- a/content/browser/appcache/appcache_internals_ui.cc
+++ b/content/browser/appcache/appcache_internals_ui.cc
@@ -82,6 +82,7 @@
                         appcache_info.last_update_time.ToJsTime());
   dict_value->SetDouble("lastAccessTime",
                         appcache_info.last_access_time.ToJsTime());
+  dict_value->SetDouble("tokenExpires", appcache_info.token_expires.ToJsTime());
   dict_value->SetString("responseSizes",
                         base::UTF16ToUTF8(base::FormatBytesUnlocalized(
                             appcache_info.response_sizes)));
@@ -145,6 +146,7 @@
   dict->SetBoolean("isFallback", resource_info.is_fallback);
   dict->SetBoolean("isIntercept", resource_info.is_intercept);
   dict->SetBoolean("isForeign", resource_info.is_foreign);
+  dict->SetDouble("tokenExpires", resource_info.token_expires.ToJsTime());
 
   return dict;
 }
diff --git a/content/browser/appcache/appcache_storage_impl.cc b/content/browser/appcache/appcache_storage_impl.cc
index 78bbc3c..566e151 100644
--- a/content/browser/appcache/appcache_storage_impl.cc
+++ b/content/browser/appcache/appcache_storage_impl.cc
@@ -365,6 +365,8 @@
       info.padding_sizes = cache_record.padding_size;
       info.last_access_time = group.last_access_time;
       info.last_update_time = cache_record.update_time;
+      // TODO(enne): should this be cache? group? both??
+      info.token_expires = group.token_expires;
       info.cache_id = cache_record.cache_id;
       info.group_id = group.group_id;
       info.is_complete = true;
diff --git a/content/browser/resources/appcache/appcache_internals.css b/content/browser/resources/appcache/appcache_internals.css
index b2fe53f3..eb3908a 100644
--- a/content/browser/resources/appcache/appcache_internals.css
+++ b/content/browser/resources/appcache/appcache_internals.css
@@ -79,6 +79,14 @@
   text-align: start;
 }
 
+.appcache-details th {
+  text-align: start;
+}
+
 .appcache-details td {
   width: 80px;
 }
+
+.appcache-details td.token-expires {
+  width: 500px;
+}
diff --git a/content/browser/resources/appcache/appcache_internals.html b/content/browser/resources/appcache/appcache_internals.html
index aed90a7..951164f 100644
--- a/content/browser/resources/appcache/appcache_internals.html
+++ b/content/browser/resources/appcache/appcache_internals.html
@@ -67,6 +67,12 @@
                     <span> Last Update Time: </span>
                     <span jscontent="new Date(lastUpdateTime)"></span>
                   </li>
+                  <li>
+                    <span> Token Expires: </span>
+                    <span jscontent=
+                      "tokenExpires ? new Date(tokenExpires) : '(unset)'">
+                    </span>
+                  </li>
                 </ul>
               </div>
               <div class="appcache-manifest-commands"
@@ -91,13 +97,14 @@
       </div>
 
       <table id="appcache-info-template">
-        <thead>
+        <thead class="appcache-details-header">
           <tr>
             <th>File URL</th>
             <th>Total Size</th>
             <th>Response</th>
             <th>Padding</th>
             <th>Properties</th>
+            <th>Token Expires</th>
           </tr>
         </thead>
         <tbody class="appcache-details"
@@ -112,6 +119,9 @@
             <td jscontent="responseSize"></td>
             <td jscontent="paddingSize"></td>
             <td jscontent="properties"></td>
+            <td class="token-expires" jscontent=
+              "tokenExpires ? new Date(tokenExpires) : '(unset)'">
+            </td>
           </tr>
         </tbody>
       </table>
diff --git a/content/browser/resources/appcache/appcache_internals.js b/content/browser/resources/appcache/appcache_internals.js
index 4933f5b..12eccae9 100644
--- a/content/browser/resources/appcache/appcache_internals.js
+++ b/content/browser/resources/appcache/appcache_internals.js
@@ -173,7 +173,8 @@
         totalSize: details.totalSize,
         properties: properties,
         fileUrl: details.url,
-        responseId: details.responseId
+        responseId: details.responseId,
+        tokenExpires: details.tokenExpires,
       });
     }
     return simpleVector;
diff --git a/third_party/blink/public/mojom/appcache/appcache.mojom b/third_party/blink/public/mojom/appcache/appcache.mojom
index b1419ac..f3ea903 100644
--- a/third_party/blink/public/mojom/appcache/appcache.mojom
+++ b/third_party/blink/public/mojom/appcache/appcache.mojom
@@ -4,6 +4,7 @@
 
 module blink.mojom;
 
+import "mojo/public/mojom/base/time.mojom";
 import "mojo/public/mojom/base/unguessable_token.mojom";
 import "services/network/public/mojom/url_loader_factory.mojom";
 import "third_party/blink/public/mojom/appcache/appcache_info.mojom";
@@ -48,6 +49,7 @@
   bool is_foreign;
   bool is_explicit;
   int64 response_id;
+  mojo_base.mojom.Time token_expires;
 };
 
 struct AppCacheErrorDetails {
diff --git a/third_party/blink/public/mojom/appcache/appcache_info.mojom b/third_party/blink/public/mojom/appcache/appcache_info.mojom
index f3084e6..eeb1b043 100644
--- a/third_party/blink/public/mojom/appcache/appcache_info.mojom
+++ b/third_party/blink/public/mojom/appcache/appcache_info.mojom
@@ -27,6 +27,7 @@
   mojo_base.mojom.Time creation_time;
   mojo_base.mojom.Time last_update_time;
   mojo_base.mojom.Time last_access_time;
+  mojo_base.mojom.Time token_expires;
   int64 cache_id;
   int64 group_id;
   AppCacheStatus status;