<!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>[206370] trunk/Source/WebCore</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/206370">206370</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-09-26 04:46:52 -0700 (Mon, 26 Sep 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>ASSERTION FAILED: m_origin || m_type == CachedResource::MainResource
https://bugs.webkit.org/show_bug.cgi?id=162472
&lt;rdar://problem/28431522&gt;

Patch by Youenn Fablet &lt;youenn@apple.com&gt; on 2016-09-26
Reviewed by Darin Adler.

No change of behavior.

Introducing a new CachedResource constructor for already loaded resources.
Sharing code with the other constructor in the init method.
The main difference with this new constructor is that the resource has no specified origin.
The response tainting remains Basic.

Making some additional code clean-up.

* loader/cache/CachedImage.cpp:
(WebCore::CachedImage::CachedImage): Making use of the new constructor.
* loader/cache/CachedResource.cpp:
(WebCore::CachedResource::CachedResource):
(WebCore::CachedResource::finishRequestInitialization):
* loader/cache/CachedResource.h:
(WebCore::CachedResource::type):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedImagecpp">trunk/Source/WebCore/loader/cache/CachedImage.cpp</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedResourcecpp">trunk/Source/WebCore/loader/cache/CachedResource.cpp</a></li>
<li><a href="#trunkSourceWebCoreloadercacheCachedResourceh">trunk/Source/WebCore/loader/cache/CachedResource.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (206369 => 206370)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-09-26 10:20:48 UTC (rev 206369)
+++ trunk/Source/WebCore/ChangeLog        2016-09-26 11:46:52 UTC (rev 206370)
</span><span class="lines">@@ -1,3 +1,28 @@
</span><ins>+2016-09-26  Youenn Fablet  &lt;youenn@apple.com&gt;
+
+        ASSERTION FAILED: m_origin || m_type == CachedResource::MainResource
+        https://bugs.webkit.org/show_bug.cgi?id=162472
+        &lt;rdar://problem/28431522&gt;
+
+        Reviewed by Darin Adler.
+
+        No change of behavior.
+
+        Introducing a new CachedResource constructor for already loaded resources.
+        Sharing code with the other constructor in the init method.
+        The main difference with this new constructor is that the resource has no specified origin.
+        The response tainting remains Basic.
+
+        Making some additional code clean-up.
+
+        * loader/cache/CachedImage.cpp:
+        (WebCore::CachedImage::CachedImage): Making use of the new constructor.
+        * loader/cache/CachedResource.cpp:
+        (WebCore::CachedResource::CachedResource):
+        (WebCore::CachedResource::finishRequestInitialization):
+        * loader/cache/CachedResource.h:
+        (WebCore::CachedResource::type):
+
</ins><span class="cx"> 2016-09-26  Olivier Blin  &lt;olivier.blin@softathome.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [GStreamer] Support flipY for GPU-to-GPU copy of video textures to WebGL
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedImagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedImage.cpp (206369 => 206370)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedImage.cpp        2016-09-26 10:20:48 UTC (rev 206369)
+++ trunk/Source/WebCore/loader/cache/CachedImage.cpp        2016-09-26 11:46:52 UTC (rev 206370)
</span><span class="lines">@@ -66,23 +66,19 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> CachedImage::CachedImage(Image* image, SessionID sessionID)
</span><del>-    : CachedResource(CachedResourceRequest(ResourceRequest()), ImageResource, sessionID)
</del><ins>+    : CachedResource(URL(), ImageResource, sessionID)
</ins><span class="cx">     , m_image(image)
</span><span class="cx">     , m_isManuallyCached(false)
</span><span class="cx">     , m_shouldPaintBrokenImage(true)
</span><span class="cx"> {
</span><del>-    setStatus(Cached);
-    setLoading(false);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> CachedImage::CachedImage(const URL&amp; url, Image* image, SessionID sessionID)
</span><del>-    : CachedResource(CachedResourceRequest(ResourceRequest(url)), ImageResource, sessionID)
</del><ins>+    : CachedResource(url, ImageResource, sessionID)
</ins><span class="cx">     , m_image(image)
</span><span class="cx">     , m_isManuallyCached(false)
</span><span class="cx">     , m_shouldPaintBrokenImage(true)
</span><span class="cx"> {
</span><del>-    setStatus(Cached);
-    setLoading(false);
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> CachedImage::CachedImage(const URL&amp; url, Image* image, CachedImage::CacheBehaviorType type, SessionID sessionID)
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedResourcecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedResource.cpp (206369 => 206370)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedResource.cpp        2016-09-26 10:20:48 UTC (rev 206369)
+++ trunk/Source/WebCore/loader/cache/CachedResource.cpp        2016-09-26 11:46:52 UTC (rev 206370)
</span><span class="lines">@@ -122,33 +122,11 @@
</span><span class="cx">     , m_loadPriority(defaultPriorityForResourceType(type))
</span><span class="cx">     , m_responseTimestamp(std::chrono::system_clock::now())
</span><span class="cx">     , m_origin(request.releaseOrigin())
</span><del>-    , m_lastDecodedAccessTime(0)
-    , m_loadFinishTime(0)
-    , m_encodedSize(0)
-    , m_decodedSize(0)
-    , m_accessCount(0)
-    , m_handleCount(0)
-    , m_preloadCount(0)
-    , m_preloadResult(PreloadNotReferenced)
-    , m_requestedFromNetworkingLayer(false)
-    , m_inCache(false)
-    , m_loading(false)
-    , m_switchingClientsToRevalidatedResource(false)
</del><span class="cx">     , m_type(type)
</span><del>-    , m_status(Pending)
-#ifndef NDEBUG
-    , m_deleted(false)
-    , m_lruIndex(0)
-#endif
-    , m_owningCachedResourceLoader(nullptr)
-    , m_resourceToRevalidate(nullptr)
-    , m_proxyResource(nullptr)
</del><span class="cx"> {
</span><del>-    ASSERT(m_type == unsigned(type)); // m_type is a bitfield, so this tests careless updates of the enum.
</del><span class="cx">     ASSERT(sessionID.isValid());
</span><del>-#ifndef NDEBUG
-    cachedResourceLeakCounter.increment();
-#endif
</del><ins>+    finishRequestInitialization();
+
</ins><span class="cx">     // FIXME: We should have a better way of checking for Navigation loads, maybe FetchMode::Options::Navigate.
</span><span class="cx">     ASSERT(m_origin || m_type == CachedResource::MainResource);
</span><span class="cx"> 
</span><span class="lines">@@ -156,7 +134,26 @@
</span><span class="cx">         &amp;&amp; !(m_resourceRequest.url().protocolIsData() &amp;&amp; m_options.sameOriginDataURLFlag == SameOriginDataURLFlag::Set)
</span><span class="cx">         &amp;&amp; !m_origin-&gt;canRequest(m_resourceRequest.url()))
</span><span class="cx">         setCrossOrigin();
</span><ins>+}
</ins><span class="cx"> 
</span><ins>+CachedResource::CachedResource(const URL&amp; url, Type type, SessionID sessionID)
+    : m_resourceRequest(url)
+    , m_decodedDataDeletionTimer(*this, &amp;CachedResource::destroyDecodedData, deadDecodedDataDeletionIntervalForResourceType(type))
+    , m_sessionID(sessionID)
+    , m_responseTimestamp(std::chrono::system_clock::now())
+    , m_type(type)
+    , m_status(Cached)
+{
+    ASSERT(sessionID.isValid());
+    finishRequestInitialization();
+}
+
+void CachedResource::finishRequestInitialization()
+{
+#ifndef NDEBUG
+    cachedResourceLeakCounter.increment();
+#endif
+
</ins><span class="cx">     if (!m_resourceRequest.url().hasFragmentIdentifier())
</span><span class="cx">         return;
</span><span class="cx">     URL urlForCache = MemoryCache::removeFragmentIdentifierIfNeeded(m_resourceRequest.url());
</span></span></pre></div>
<a id="trunkSourceWebCoreloadercacheCachedResourceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/cache/CachedResource.h (206369 => 206370)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/cache/CachedResource.h        2016-09-26 10:20:48 UTC (rev 206369)
+++ trunk/Source/WebCore/loader/cache/CachedResource.h        2016-09-26 11:46:52 UTC (rev 206370)
</span><span class="lines">@@ -119,8 +119,8 @@
</span><span class="cx">     const String&amp; cachePartition() const { return m_resourceRequest.cachePartition(); }
</span><span class="cx"> #endif
</span><span class="cx">     SessionID sessionID() const { return m_sessionID; }
</span><del>-    Type type() const { return static_cast&lt;Type&gt;(m_type); }
-    
</del><ins>+    Type type() const { return m_type; }
+
</ins><span class="cx">     ResourceLoadPriority loadPriority() const { return m_loadPriority; }
</span><span class="cx">     void setLoadPriority(const Optional&lt;ResourceLoadPriority&gt;&amp;);
</span><span class="cx"> 
</span><span class="lines">@@ -278,6 +278,9 @@
</span><span class="cx">     static ResourceLoadPriority defaultPriorityForResourceType(Type);
</span><span class="cx"> 
</span><span class="cx"> protected:
</span><ins>+    // CachedResource constructor that may be used when the CachedResource can already be filled with response data.
+    CachedResource(const URL&amp;, Type, SessionID);
+
</ins><span class="cx">     void setEncodedSize(unsigned);
</span><span class="cx">     void setDecodedSize(unsigned);
</span><span class="cx">     void didAccessDecodedData(double timeStamp);
</span><span class="lines">@@ -298,6 +301,8 @@
</span><span class="cx"> private:
</span><span class="cx">     class Callback;
</span><span class="cx"> 
</span><ins>+    void finishRequestInitialization();
+
</ins><span class="cx">     bool addClientToSet(CachedResourceClient*);
</span><span class="cx"> 
</span><span class="cx">     void decodedDataDeletionTimerFired();
</span><span class="lines">@@ -321,42 +326,42 @@
</span><span class="cx">     ResourceError m_error;
</span><span class="cx">     RefPtr&lt;SecurityOrigin&gt; m_origin;
</span><span class="cx"> 
</span><del>-    double m_lastDecodedAccessTime; // Used as a &quot;thrash guard&quot; in the cache
-    double m_loadFinishTime;
</del><ins>+    double m_lastDecodedAccessTime { 0 }; // Used as a &quot;thrash guard&quot; in the cache
+    double m_loadFinishTime { 0 };
</ins><span class="cx"> 
</span><del>-    unsigned m_encodedSize;
-    unsigned m_decodedSize;
-    unsigned m_accessCount;
-    unsigned m_handleCount;
-    unsigned m_preloadCount;
</del><ins>+    unsigned m_encodedSize { 0 };
+    unsigned m_decodedSize { 0 };
+    unsigned m_accessCount { 0 };
+    unsigned m_handleCount { 0 };
+    unsigned m_preloadCount { 0 };
</ins><span class="cx"> 
</span><del>-    unsigned m_preloadResult : 2; // PreloadResult
</del><ins>+    unsigned m_preloadResult { PreloadNotReferenced };
</ins><span class="cx"> 
</span><del>-    bool m_requestedFromNetworkingLayer : 1;
</del><ins>+    bool m_requestedFromNetworkingLayer { false };
</ins><span class="cx"> 
</span><del>-    bool m_inCache : 1;
-    bool m_loading : 1;
</del><ins>+    bool m_inCache { false };
+    bool m_loading { false };
</ins><span class="cx"> 
</span><del>-    bool m_switchingClientsToRevalidatedResource : 1;
</del><ins>+    bool m_switchingClientsToRevalidatedResource { false };
</ins><span class="cx"> 
</span><del>-    unsigned m_type : 4; // Type
-    unsigned m_status : 3; // Status
</del><ins>+    Type m_type; // Type
+    unsigned m_status { Pending }; // Status
</ins><span class="cx"> 
</span><span class="cx"> #ifndef NDEBUG
</span><del>-    bool m_deleted;
-    unsigned m_lruIndex;
</del><ins>+    bool m_deleted { false };
+    unsigned m_lruIndex { 0 };
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    CachedResourceLoader* m_owningCachedResourceLoader; // only non-null for resources that are not in the cache
</del><ins>+    CachedResourceLoader* m_owningCachedResourceLoader { nullptr }; // only non-null for resources that are not in the cache
</ins><span class="cx">     
</span><span class="cx">     // If this field is non-null we are using the resource as a proxy for checking whether an existing resource is still up to date
</span><span class="cx">     // using HTTP If-Modified-Since/If-None-Match headers. If the response is 304 all clients of this resource are moved
</span><span class="cx">     // to to be clients of m_resourceToRevalidate and the resource is deleted. If not, the field is zeroed and this
</span><span class="cx">     // resources becomes normal resource load.
</span><del>-    CachedResource* m_resourceToRevalidate;
</del><ins>+    CachedResource* m_resourceToRevalidate { nullptr };
</ins><span class="cx"> 
</span><span class="cx">     // If this field is non-null, the resource has a proxy for checking whether it is still up to date (see m_resourceToRevalidate).
</span><del>-    CachedResource* m_proxyResource;
</del><ins>+    CachedResource* m_proxyResource { nullptr };
</ins><span class="cx"> 
</span><span class="cx">     // These handles will need to be updated to point to the m_resourceToRevalidate in case we get 304 response.
</span><span class="cx">     HashSet&lt;CachedResourceHandleBase*&gt; m_handlesToRevalidate;
</span></span></pre>
</div>
</div>

</body>
</html>