<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[211472] trunk/Source</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/211472">211472</a></dd>
<dt>Author</dt> <dd>antti@apple.com</dd>
<dt>Date</dt> <dd>2017-01-31 23:55:44 -0800 (Tue, 31 Jan 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>Teach cache coders to encode time_points
https://bugs.webkit.org/show_bug.cgi?id=167670

Reviewed by Andreas Kling.

Source/WebKit2:

Encode time_point instead of duration.

* NetworkProcess/cache/NetworkCacheStorage.cpp:
(WebKit::NetworkCache::decodeRecordMetaData):
(WebKit::NetworkCache::Storage::readRecord):
(WebKit::NetworkCache::encodeRecordMetaData):
(WebKit::NetworkCache::Storage::encodeRecord):
(WebKit::NetworkCache::Storage::traverse):

Source/WTF:

* wtf/persistence/Coders.h:
(WTF::Persistence::Coder&lt;std::chrono::system_clock::time_point&gt;::encode):
(WTF::Persistence::Coder&lt;std::chrono::system_clock::time_point&gt;::decode):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWTFChangeLog">trunk/Source/WTF/ChangeLog</a></li>
<li><a href="#trunkSourceWTFwtfpersistenceCodersh">trunk/Source/WTF/wtf/persistence/Coders.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcesscacheNetworkCacheStoragecpp">trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWTFChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/ChangeLog (211471 => 211472)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/ChangeLog        2017-02-01 07:46:31 UTC (rev 211471)
+++ trunk/Source/WTF/ChangeLog        2017-02-01 07:55:44 UTC (rev 211472)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2017-01-31  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        Teach cache coders to encode time_points
+        https://bugs.webkit.org/show_bug.cgi?id=167670
+
+        Reviewed by Andreas Kling.
+
+        * wtf/persistence/Coders.h:
+        (WTF::Persistence::Coder&lt;std::chrono::system_clock::time_point&gt;::encode):
+        (WTF::Persistence::Coder&lt;std::chrono::system_clock::time_point&gt;::decode):
+
</ins><span class="cx"> 2017-01-31  Joseph Pecoraro  &lt;pecoraro@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Removed unused m_nestedCount from RunLoop
</span></span></pre></div>
<a id="trunkSourceWTFwtfpersistenceCodersh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WTF/wtf/persistence/Coders.h (211471 => 211472)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WTF/wtf/persistence/Coders.h        2017-02-01 07:46:31 UTC (rev 211471)
+++ trunk/Source/WTF/wtf/persistence/Coders.h        2017-02-01 07:55:44 UTC (rev 211472)
</span><span class="lines">@@ -261,6 +261,23 @@
</span><span class="cx">     }
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+template&lt;&gt; struct Coder&lt;std::chrono::system_clock::time_point&gt; {
+    static void encode(Encoder&amp; encoder, const std::chrono::system_clock::time_point&amp; timePoint)
+    {
+        encoder &lt;&lt; static_cast&lt;int64_t&gt;(timePoint.time_since_epoch().count());
+    }
+    
+    static bool decode(Decoder&amp; decoder, std::chrono::system_clock::time_point&amp; result)
+    {
+        int64_t time;
+        if (!decoder.decode(time))
+            return false;
+
+        result = std::chrono::system_clock::time_point(std::chrono::system_clock::duration(static_cast&lt;std::chrono::system_clock::rep&gt;(time)));
+        return true;
+    }
+};
+
</ins><span class="cx"> template&lt;&gt; struct Coder&lt;AtomicString&gt; {
</span><span class="cx">     WTF_EXPORT_PRIVATE static void encode(Encoder&amp;, const AtomicString&amp;);
</span><span class="cx">     WTF_EXPORT_PRIVATE static bool decode(Decoder&amp;, AtomicString&amp;);
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (211471 => 211472)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2017-02-01 07:46:31 UTC (rev 211471)
+++ trunk/Source/WebKit2/ChangeLog        2017-02-01 07:55:44 UTC (rev 211472)
</span><span class="lines">@@ -1,3 +1,19 @@
</span><ins>+2017-01-31  Antti Koivisto  &lt;antti@apple.com&gt;
+
+        Teach cache coders to encode time_points
+        https://bugs.webkit.org/show_bug.cgi?id=167670
+
+        Reviewed by Andreas Kling.
+
+        Encode time_point instead of duration.
+
+        * NetworkProcess/cache/NetworkCacheStorage.cpp:
+        (WebKit::NetworkCache::decodeRecordMetaData):
+        (WebKit::NetworkCache::Storage::readRecord):
+        (WebKit::NetworkCache::encodeRecordMetaData):
+        (WebKit::NetworkCache::Storage::encodeRecord):
+        (WebKit::NetworkCache::Storage::traverse):
+
</ins><span class="cx"> 2017-01-31  Brent Fulgham  &lt;bfulgham@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [WebRTC][WebKit2] Support expanding the sandbox to allow microphone access at process launch
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcesscacheNetworkCacheStoragecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp (211471 => 211472)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp        2017-02-01 07:46:31 UTC (rev 211471)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp        2017-02-01 07:55:44 UTC (rev 211472)
</span><span class="lines">@@ -364,8 +364,7 @@
</span><span class="cx"> 
</span><span class="cx">     unsigned cacheStorageVersion;
</span><span class="cx">     Key key;
</span><del>-    // FIXME: Add encoder/decoder for time_point.
-    std::chrono::milliseconds epochRelativeTimeStamp;
</del><ins>+    std::chrono::system_clock::time_point timeStamp;
</ins><span class="cx">     SHA1::Digest headerHash;
</span><span class="cx">     uint64_t headerSize;
</span><span class="cx">     SHA1::Digest bodyHash;
</span><span class="lines">@@ -385,7 +384,7 @@
</span><span class="cx">             return false;
</span><span class="cx">         if (!decoder.decode(metaData.key))
</span><span class="cx">             return false;
</span><del>-        if (!decoder.decode(metaData.epochRelativeTimeStamp))
</del><ins>+        if (!decoder.decode(metaData.timeStamp))
</ins><span class="cx">             return false;
</span><span class="cx">         if (!decoder.decode(metaData.headerHash))
</span><span class="cx">             return false;
</span><span class="lines">@@ -439,8 +438,7 @@
</span><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     // Sanity check against time stamps in future.
</span><del>-    auto timeStamp = std::chrono::system_clock::time_point(metaData.epochRelativeTimeStamp);
-    if (timeStamp &gt; std::chrono::system_clock::now())
</del><ins>+    if (metaData.timeStamp &gt; std::chrono::system_clock::now())
</ins><span class="cx">         return;
</span><span class="cx"> 
</span><span class="cx">     Data bodyData;
</span><span class="lines">@@ -456,7 +454,7 @@
</span><span class="cx">     readOperation.expectedBodyHash = metaData.bodyHash;
</span><span class="cx">     readOperation.resultRecord = std::make_unique&lt;Storage::Record&gt;(Storage::Record {
</span><span class="cx">         metaData.key,
</span><del>-        timeStamp,
</del><ins>+        metaData.timeStamp,
</ins><span class="cx">         headerData,
</span><span class="cx">         bodyData,
</span><span class="cx">         metaData.bodyHash
</span><span class="lines">@@ -469,7 +467,7 @@
</span><span class="cx"> 
</span><span class="cx">     encoder &lt;&lt; metaData.cacheStorageVersion;
</span><span class="cx">     encoder &lt;&lt; metaData.key;
</span><del>-    encoder &lt;&lt; metaData.epochRelativeTimeStamp;
</del><ins>+    encoder &lt;&lt; metaData.timeStamp;
</ins><span class="cx">     encoder &lt;&lt; metaData.headerHash;
</span><span class="cx">     encoder &lt;&lt; metaData.headerSize;
</span><span class="cx">     encoder &lt;&lt; metaData.bodyHash;
</span><span class="lines">@@ -511,7 +509,7 @@
</span><span class="cx">     ASSERT(!blob || bytesEqual(blob.value().data, record.body));
</span><span class="cx"> 
</span><span class="cx">     RecordMetaData metaData(record.key);
</span><del>-    metaData.epochRelativeTimeStamp = std::chrono::duration_cast&lt;std::chrono::milliseconds&gt;(record.timeStamp.time_since_epoch());
</del><ins>+    metaData.timeStamp = record.timeStamp;
</ins><span class="cx">     metaData.headerHash = computeSHA1(record.header, m_salt);
</span><span class="cx">     metaData.headerSize = record.header.size();
</span><span class="cx">     metaData.bodyHash = blob ? blob.value().hash : computeSHA1(record.body, m_salt);
</span><span class="lines">@@ -836,7 +834,7 @@
</span><span class="cx">                 if (decodeRecordHeader(fileData, metaData, headerData, m_salt)) {
</span><span class="cx">                     Record record {
</span><span class="cx">                         metaData.key,
</span><del>-                        std::chrono::system_clock::time_point(metaData.epochRelativeTimeStamp),
</del><ins>+                        metaData.timeStamp,
</ins><span class="cx">                         headerData,
</span><span class="cx">                         { },
</span><span class="cx">                         metaData.bodyHash
</span></span></pre>
</div>
</div>

</body>
</html>