<!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>[191673] 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/191673">191673</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2015-10-28 10:35:10 -0700 (Wed, 28 Oct 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Use RunLoopTimer in DataURLDecoder to avoid issues related to runloops
https://bugs.webkit.org/show_bug.cgi?id=150609
&lt;rdar://problem/22702894&gt;

Reviewed by Antti Koivisto.

Source/WebCore:

Use RunLoopTimer in DataURLDecoder to avoid issues related to RunLoops.
In particular, the callOnMainThread() call could fail to dispatch the
decoding result to the main thread if the client-side would spin its own
RunLoop.

This is similar to the approach used in DocumentLoader for
DocumentLoaderTimer.

No new tests, verified through manual testing.

* WebCore.xcodeproj/project.pbxproj:
* loader/ResourceLoader.cpp:
(WebCore::ResourceLoader::loadDataURL):
* page/Page.cpp:
(WebCore::Page::Page):
* page/Page.h:
* page/mac/PageMac.mm: Renamed from Source/WebCore/page/mac/PageMac.cpp.
(WebCore::Page::platformInitialize):
(WebCore::Page::addSchedulePair):
(WebCore::Page::removeSchedulePair):
* platform/network/DataURLDecoder.cpp:
(WebCore::DataURLDecoder::DecodingResultDispatcher::dispatch):
(WebCore::DataURLDecoder::DecodingResultDispatcher::DecodingResultDispatcher):
(WebCore::DataURLDecoder::DecodingResultDispatcher::startTimer):
(WebCore::DataURLDecoder::DecodingResultDispatcher::timerFired):
(WebCore::DataURLDecoder::createDecodeTask):
(WebCore::DataURLDecoder::decode):
* platform/network/DataURLDecoder.h:

Source/WebKit2:

Move addSchedulePair() call to Page::platformInitialize() so that
RunLoopTimer can be used by any Page, even those that don't have
a WebPage wrapper.

* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::platformInitialize): Deleted.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoreWebCorexcodeprojprojectpbxproj">trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj</a></li>
<li><a href="#trunkSourceWebCoreloaderResourceLoadercpp">trunk/Source/WebCore/loader/ResourceLoader.cpp</a></li>
<li><a href="#trunkSourceWebCorepagePagecpp">trunk/Source/WebCore/page/Page.cpp</a></li>
<li><a href="#trunkSourceWebCorepagePageh">trunk/Source/WebCore/page/Page.h</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkDataURLDecodercpp">trunk/Source/WebCore/platform/network/DataURLDecoder.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformnetworkDataURLDecoderh">trunk/Source/WebCore/platform/network/DataURLDecoder.h</a></li>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2WebProcessWebPagemacWebPageMacmm">trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCorepagemacPageMacmm">trunk/Source/WebCore/page/mac/PageMac.mm</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li><a href="#trunkSourceWebCorepagemacPageMaccpp">trunk/Source/WebCore/page/mac/PageMac.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (191672 => 191673)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-10-28 17:29:41 UTC (rev 191672)
+++ trunk/Source/WebCore/ChangeLog        2015-10-28 17:35:10 UTC (rev 191673)
</span><span class="lines">@@ -1,3 +1,40 @@
</span><ins>+2015-10-28  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        Use RunLoopTimer in DataURLDecoder to avoid issues related to runloops
+        https://bugs.webkit.org/show_bug.cgi?id=150609
+        &lt;rdar://problem/22702894&gt;
+
+        Reviewed by Antti Koivisto.
+
+        Use RunLoopTimer in DataURLDecoder to avoid issues related to RunLoops.
+        In particular, the callOnMainThread() call could fail to dispatch the
+        decoding result to the main thread if the client-side would spin its own
+        RunLoop.
+
+        This is similar to the approach used in DocumentLoader for
+        DocumentLoaderTimer.
+
+        No new tests, verified through manual testing.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * loader/ResourceLoader.cpp:
+        (WebCore::ResourceLoader::loadDataURL):
+        * page/Page.cpp:
+        (WebCore::Page::Page):
+        * page/Page.h:
+        * page/mac/PageMac.mm: Renamed from Source/WebCore/page/mac/PageMac.cpp.
+        (WebCore::Page::platformInitialize):
+        (WebCore::Page::addSchedulePair):
+        (WebCore::Page::removeSchedulePair):
+        * platform/network/DataURLDecoder.cpp:
+        (WebCore::DataURLDecoder::DecodingResultDispatcher::dispatch):
+        (WebCore::DataURLDecoder::DecodingResultDispatcher::DecodingResultDispatcher):
+        (WebCore::DataURLDecoder::DecodingResultDispatcher::startTimer):
+        (WebCore::DataURLDecoder::DecodingResultDispatcher::timerFired):
+        (WebCore::DataURLDecoder::createDecodeTask):
+        (WebCore::DataURLDecoder::decode):
+        * platform/network/DataURLDecoder.h:
+
</ins><span class="cx"> 2015-10-28  Brady Eidson  &lt;beidson@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Modern IDB: Implement most readonly attributes of IDBObjectStore.
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (191672 => 191673)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-10-28 17:29:41 UTC (rev 191672)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2015-10-28 17:35:10 UTC (rev 191673)
</span><span class="lines">@@ -962,7 +962,6 @@
</span><span class="cx">                 1C21E57D183ED1FF001C289D /* IOSurfacePool.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C21E57B183ED1FF001C289D /* IOSurfacePool.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 1C2417BA1992C04100EF9938 /* SpellingDot@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1C2417B91992C04100EF9938 /* SpellingDot@3x.png */; };
</span><span class="cx">                 1C26497A0D7E248A00BD10F2 /* DocumentLoaderMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C2649790D7E248A00BD10F2 /* DocumentLoaderMac.cpp */; };
</span><del>-                1C26497C0D7E24EC00BD10F2 /* PageMac.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C26497B0D7E24EC00BD10F2 /* PageMac.cpp */; };
</del><span class="cx">                 1C3969D01B74211E002BCFA7 /* FontCacheCoreText.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C3969CF1B74211E002BCFA7 /* FontCacheCoreText.cpp */; };
</span><span class="cx">                 1C6466251A12C38E0094603C /* CoreTextSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C5E980F1A02CEFA002DB55F /* CoreTextSPI.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 1C6466281A12C4200094603C /* NSFontSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = 1C6466271A12C3F90094603C /* NSFontSPI.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="lines">@@ -2789,6 +2788,7 @@
</span><span class="cx">                 832B843619D8E57400B26055 /* SVGAnimateElementBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 832B843519D8E57400B26055 /* SVGAnimateElementBase.cpp */; };
</span><span class="cx">                 8348BFAB1B85729800912F36 /* ClassCollection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8348BFA91B85729500912F36 /* ClassCollection.cpp */; };
</span><span class="cx">                 8348BFAC1B85729800912F36 /* ClassCollection.h in Headers */ = {isa = PBXBuildFile; fileRef = 8348BFAA1B85729500912F36 /* ClassCollection.h */; };
</span><ins>+                834DD4F41BE08989002C9C3E /* PageMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 834DD4F31BE08989002C9C3E /* PageMac.mm */; };
</ins><span class="cx">                 83520C7E1A71BFCC006BD2AA /* CSSFontFamily.h in Headers */ = {isa = PBXBuildFile; fileRef = 83520C7D1A71BFCC006BD2AA /* CSSFontFamily.h */; };
</span><span class="cx">                 835D363719FF6193004C93AB /* StyleBuilderCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = 835D363619FF6193004C93AB /* StyleBuilderCustom.h */; };
</span><span class="cx">                 836BAD211BD1CA670037356A /* HTMLTableHeaderCellElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 836BAD1F1BD1CA670037356A /* HTMLTableHeaderCellElement.h */; };
</span><span class="lines">@@ -8260,7 +8260,6 @@
</span><span class="cx">                 1C21E57B183ED1FF001C289D /* IOSurfacePool.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IOSurfacePool.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1C2417B91992C04100EF9938 /* SpellingDot@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = &quot;SpellingDot@3x.png&quot;; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1C2649790D7E248A00BD10F2 /* DocumentLoaderMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentLoaderMac.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><del>-                1C26497B0D7E24EC00BD10F2 /* PageMac.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PageMac.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</del><span class="cx">                 1C3969CF1B74211E002BCFA7 /* FontCacheCoreText.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontCacheCoreText.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1C5E980F1A02CEFA002DB55F /* CoreTextSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CoreTextSPI.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 1C6466271A12C3F90094603C /* NSFontSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NSFontSPI.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -10271,6 +10270,7 @@
</span><span class="cx">                 832B843519D8E57400B26055 /* SVGAnimateElementBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimateElementBase.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 8348BFA91B85729500912F36 /* ClassCollection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ClassCollection.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 8348BFAA1B85729500912F36 /* ClassCollection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClassCollection.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                834DD4F31BE08989002C9C3E /* PageMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PageMac.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 83520C7D1A71BFCC006BD2AA /* CSSFontFamily.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSFontFamily.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 835D363619FF6193004C93AB /* StyleBuilderCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleBuilderCustom.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 8369E58F1AFDD0300087DF68 /* NonDocumentTypeChildNode.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = NonDocumentTypeChildNode.idl; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -18610,7 +18610,7 @@
</span><span class="cx">                                 ABAF22070C03B1C700B0BCF0 /* ChromeMac.mm */,
</span><span class="cx">                                 A718788F0B2D04AC00A16ECE /* DragControllerMac.mm */,
</span><span class="cx">                                 93C09A7E0B064EEF005ABD4D /* EventHandlerMac.mm */,
</span><del>-                                1C26497B0D7E24EC00BD10F2 /* PageMac.cpp */,
</del><ins>+                                834DD4F31BE08989002C9C3E /* PageMac.mm */,
</ins><span class="cx">                                 2D93AEE119DF5641002A86C3 /* ServicesOverlayController.h */,
</span><span class="cx">                                 2D93AEE219DF5641002A86C3 /* ServicesOverlayController.mm */,
</span><span class="cx">                                 E1C2F2481533A2120083F974 /* SettingsMac.mm */,
</span><span class="lines">@@ -30413,7 +30413,6 @@
</span><span class="cx">                                 F34742DC134362F000531BC2 /* PageDebuggerAgent.cpp in Sources */,
</span><span class="cx">                                 9302B0BD0D79F82900C7EE83 /* PageGroup.cpp in Sources */,
</span><span class="cx">                                 7A674BDB0F9EBF4E006CF099 /* PageGroupLoadDeferrer.cpp in Sources */,
</span><del>-                                1C26497C0D7E24EC00BD10F2 /* PageMac.cpp in Sources */,
</del><span class="cx">                                 2D5C9CFF19C7B52E00B3C5C1 /* PageOverlay.cpp in Sources */,
</span><span class="cx">                                 2D5C9D0119C7B52E00B3C5C1 /* PageOverlayController.cpp in Sources */,
</span><span class="cx">                                 FBDB619D16D6034600BB3394 /* PageRuleCollector.cpp in Sources */,
</span><span class="lines">@@ -30556,6 +30555,7 @@
</span><span class="cx">                                 BCEA4879097D93020094C9E4 /* RenderLayer.cpp in Sources */,
</span><span class="cx">                                 0F580D000F12DE9B0051D689 /* RenderLayerBacking.cpp in Sources */,
</span><span class="cx">                                 0F580CFE0F12DE9B0051D689 /* RenderLayerCompositor.cpp in Sources */,
</span><ins>+                                834DD4F41BE08989002C9C3E /* PageMac.mm in Sources */,
</ins><span class="cx">                                 50D10D991545F5760096D288 /* RenderLayerFilterInfo.cpp in Sources */,
</span><span class="cx">                                 3C244FEBA375AC633F88BE6F /* RenderLayerModelObject.cpp in Sources */,
</span><span class="cx">                                 BC33FB1B0F30EE85002CDD7C /* RenderLineBoxList.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderResourceLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/ResourceLoader.cpp (191672 => 191673)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/ResourceLoader.cpp        2015-10-28 17:29:41 UTC (rev 191672)
+++ trunk/Source/WebCore/loader/ResourceLoader.cpp        2015-10-28 17:35:10 UTC (rev 191673)
</span><span class="lines">@@ -249,7 +249,12 @@
</span><span class="cx">     ASSERT(url.protocolIsData());
</span><span class="cx"> 
</span><span class="cx">     RefPtr&lt;ResourceLoader&gt; loader(this);
</span><del>-    DataURLDecoder::decode(url, [loader, url] (Optional&lt;DataURLDecoder::Result&gt; decodeResult) {
</del><ins>+    DataURLDecoder::ScheduleContext scheduleContext;
+#if HAVE(RUNLOOP_TIMER)
+    if (auto* scheduledPairs = m_frame-&gt;page()-&gt;scheduledRunLoopPairs())
+        scheduleContext.scheduledPairs = *scheduledPairs;
+#endif
+    DataURLDecoder::decode(url, scheduleContext, [loader, url] (Optional&lt;DataURLDecoder::Result&gt; decodeResult) {
</ins><span class="cx">         if (loader-&gt;reachedTerminalState())
</span><span class="cx">             return;
</span><span class="cx">         if (!decodeResult) {
</span></span></pre></div>
<a id="trunkSourceWebCorepagePagecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Page.cpp (191672 => 191673)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Page.cpp        2015-10-28 17:29:41 UTC (rev 191672)
+++ trunk/Source/WebCore/page/Page.cpp        2015-10-28 17:35:10 UTC (rev 191673)
</span><span class="lines">@@ -248,6 +248,10 @@
</span><span class="cx"> #if ENABLE(REMOTE_INSPECTOR)
</span><span class="cx">     m_inspectorDebuggable-&gt;init();
</span><span class="cx"> #endif
</span><ins>+
+#if PLATFORM(COCOA)
+    platformInitialize();
+#endif
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> Page::~Page()
</span></span></pre></div>
<a id="trunkSourceWebCorepagePageh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/Page.h (191672 => 191673)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/Page.h        2015-10-28 17:29:41 UTC (rev 191672)
+++ trunk/Source/WebCore/page/Page.h        2015-10-28 17:35:10 UTC (rev 191673)
</span><span class="lines">@@ -244,6 +244,7 @@
</span><span class="cx">     enum { NoMatchAfterUserSelection = -1 };
</span><span class="cx">     WEBCORE_EXPORT void findStringMatchingRanges(const String&amp;, FindOptions, int maxCount, Vector&lt;RefPtr&lt;Range&gt;&gt;&amp;, int&amp; indexForSelection);
</span><span class="cx"> #if PLATFORM(COCOA)
</span><ins>+    void platformInitialize();
</ins><span class="cx">     WEBCORE_EXPORT void addSchedulePair(Ref&lt;SchedulePair&gt;&amp;&amp;);
</span><span class="cx">     WEBCORE_EXPORT void removeSchedulePair(Ref&lt;SchedulePair&gt;&amp;&amp;);
</span><span class="cx">     SchedulePairHashSet* scheduledRunLoopPairs() { return m_scheduledRunLoopPairs.get(); }
</span></span></pre></div>
<a id="trunkSourceWebCorepagemacPageMaccpp"></a>
<div class="delfile"><h4>Deleted: trunk/Source/WebCore/page/mac/PageMac.cpp (191672 => 191673)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/mac/PageMac.cpp        2015-10-28 17:29:41 UTC (rev 191672)
+++ trunk/Source/WebCore/page/mac/PageMac.cpp        2015-10-28 17:35:10 UTC (rev 191673)
</span><span class="lines">@@ -1,75 +0,0 @@
</span><del>-/*
- * Copyright (C) 2008 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * 1.  Redistributions of source code must retain the above copyright
- *     notice, this list of conditions and the following disclaimer.
- * 2.  Redistributions in binary form must reproduce the above copyright
- *     notice, this list of conditions and the following disclaimer in the
- *     documentation and/or other materials provided with the distribution.
- * 3.  Neither the name of Apple Inc. (&quot;Apple&quot;) nor the names of
- *     its contributors may be used to endorse or promote products derived
- *     from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS &quot;AS IS&quot; AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include &quot;config.h&quot;
-#include &quot;Page.h&quot;
-
-#include &quot;DocumentLoader.h&quot;
-#include &quot;FrameLoader.h&quot;
-#include &quot;FrameTree.h&quot;
-#include &quot;MainFrame.h&quot;
-
-namespace WebCore {
-
-void Page::addSchedulePair(Ref&lt;SchedulePair&gt;&amp;&amp; pair)
-{
-    if (!m_scheduledRunLoopPairs)
-        m_scheduledRunLoopPairs = std::make_unique&lt;SchedulePairHashSet&gt;();
-    m_scheduledRunLoopPairs-&gt;add(pair.ptr());
-
-#if !PLATFORM(IOS)
-    for (Frame* frame = m_mainFrame.get(); frame; frame = frame-&gt;tree().traverseNext()) {
-        if (DocumentLoader* documentLoader = frame-&gt;loader().documentLoader())
-            documentLoader-&gt;schedule(pair);
-        if (DocumentLoader* documentLoader = frame-&gt;loader().provisionalDocumentLoader())
-            documentLoader-&gt;schedule(pair);
-    }
-#endif
-
-    // FIXME: make SharedTimerMac use these SchedulePairs.
-}
-
-void Page::removeSchedulePair(Ref&lt;SchedulePair&gt;&amp;&amp; pair)
-{
-    ASSERT(m_scheduledRunLoopPairs);
-    if (!m_scheduledRunLoopPairs)
-        return;
-
-    m_scheduledRunLoopPairs-&gt;remove(pair.ptr());
-
-#if !PLATFORM(IOS)
-    for (Frame* frame = m_mainFrame.get(); frame; frame = frame-&gt;tree().traverseNext()) {
-        if (DocumentLoader* documentLoader = frame-&gt;loader().documentLoader())
-            documentLoader-&gt;unschedule(pair);
-        if (DocumentLoader* documentLoader = frame-&gt;loader().provisionalDocumentLoader())
-            documentLoader-&gt;unschedule(pair);
-    }
-#endif
-}
-
-} // namespace
</del></span></pre></div>
<a id="trunkSourceWebCorepagemacPageMacmmfromrev191672trunkSourceWebCorepagemacPageMaccpp"></a>
<div class="copfile"><h4>Copied: trunk/Source/WebCore/page/mac/PageMac.mm (from rev 191672, trunk/Source/WebCore/page/mac/PageMac.cpp) (0 => 191673)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/mac/PageMac.mm                                (rev 0)
+++ trunk/Source/WebCore/page/mac/PageMac.mm        2015-10-28 17:35:10 UTC (rev 191673)
</span><span class="lines">@@ -0,0 +1,84 @@
</span><ins>+/*
+ * Copyright (C) 2008 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer.
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution.
+ * 3.  Neither the name of Apple Inc. (&quot;Apple&quot;) nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS &quot;AS IS&quot; AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import &quot;config.h&quot;
+#import &quot;Page.h&quot;
+
+#import &quot;DocumentLoader.h&quot;
+#import &quot;FrameLoader.h&quot;
+#import &quot;FrameTree.h&quot;
+#import &quot;MainFrame.h&quot;
+
+namespace WebCore {
+
+void Page::platformInitialize()
+{
+#if USE(CFNETWORK)
+    addSchedulePair(SchedulePair::create([[NSRunLoop currentRunLoop] getCFRunLoop], kCFRunLoopCommonModes));
+#else
+    addSchedulePair(SchedulePair::create([NSRunLoop currentRunLoop], kCFRunLoopCommonModes));
+#endif
+}
+
+void Page::addSchedulePair(Ref&lt;SchedulePair&gt;&amp;&amp; pair)
+{
+    if (!m_scheduledRunLoopPairs)
+        m_scheduledRunLoopPairs = std::make_unique&lt;SchedulePairHashSet&gt;();
+    m_scheduledRunLoopPairs-&gt;add(pair.ptr());
+
+#if !PLATFORM(IOS)
+    for (Frame* frame = m_mainFrame.get(); frame; frame = frame-&gt;tree().traverseNext()) {
+        if (DocumentLoader* documentLoader = frame-&gt;loader().documentLoader())
+            documentLoader-&gt;schedule(pair);
+        if (DocumentLoader* documentLoader = frame-&gt;loader().provisionalDocumentLoader())
+            documentLoader-&gt;schedule(pair);
+    }
+#endif
+
+    // FIXME: make SharedTimerMac use these SchedulePairs.
+}
+
+void Page::removeSchedulePair(Ref&lt;SchedulePair&gt;&amp;&amp; pair)
+{
+    ASSERT(m_scheduledRunLoopPairs);
+    if (!m_scheduledRunLoopPairs)
+        return;
+
+    m_scheduledRunLoopPairs-&gt;remove(pair.ptr());
+
+#if !PLATFORM(IOS)
+    for (Frame* frame = m_mainFrame.get(); frame; frame = frame-&gt;tree().traverseNext()) {
+        if (DocumentLoader* documentLoader = frame-&gt;loader().documentLoader())
+            documentLoader-&gt;unschedule(pair);
+        if (DocumentLoader* documentLoader = frame-&gt;loader().provisionalDocumentLoader())
+            documentLoader-&gt;unschedule(pair);
+    }
+#endif
+}
+
+} // namespace
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkDataURLDecodercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/DataURLDecoder.cpp (191672 => 191673)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/DataURLDecoder.cpp        2015-10-28 17:29:41 UTC (rev 191672)
+++ trunk/Source/WebCore/platform/network/DataURLDecoder.cpp        2015-10-28 17:35:10 UTC (rev 191673)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> #include &quot;DecodeEscapeSequences.h&quot;
</span><span class="cx"> #include &quot;HTTPParsers.h&quot;
</span><span class="cx"> #include &quot;SharedBuffer.h&quot;
</span><ins>+#include &quot;Timer.h&quot;
</ins><span class="cx"> #include &quot;URL.h&quot;
</span><span class="cx"> #include &lt;wtf/MainThread.h&gt;
</span><span class="cx"> #include &lt;wtf/RunLoop.h&gt;
</span><span class="lines">@@ -48,11 +49,54 @@
</span><span class="cx">     const String urlString;
</span><span class="cx">     const StringView encodedData;
</span><span class="cx">     const bool isBase64;
</span><ins>+    const ScheduleContext scheduleContext;
</ins><span class="cx">     const DecodeCompletionHandler completionHandler;
</span><span class="cx"> 
</span><span class="cx">     Result result;
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+class DecodingResultDispatcher {
+public:
+    static void dispatch(std::unique_ptr&lt;DecodeTask&gt; decodeTask)
+    {
+        auto&amp; dispatcher = *new DecodingResultDispatcher(WTF::move(decodeTask));
+        dispatcher.startTimer();
+    }
+
+private:
+    DecodingResultDispatcher(std::unique_ptr&lt;DecodeTask&gt; decodeTask)
+        : m_timer(*this, &amp;DecodingResultDispatcher::timerFired)
+        , m_decodeTask(WTF::move(decodeTask))
+    {
+    }
+
+    void startTimer()
+    {
+        m_timer.startOneShot(0);
+#if HAVE(RUNLOOP_TIMER)
+        m_timer.schedule(m_decodeTask-&gt;scheduleContext.scheduledPairs);
+#endif
+    }
+
+    void timerFired()
+    {
+        if (m_decodeTask-&gt;result.data)
+            m_decodeTask-&gt;completionHandler(WTF::move(m_decodeTask-&gt;result));
+        else
+            m_decodeTask-&gt;completionHandler({ });
+
+        delete this;
+    }
+
+#if HAVE(RUNLOOP_TIMER)
+    typedef RunLoopTimer&lt;DecodingResultDispatcher&gt; DecodingResultDispatcherTimer;
+#else
+    typedef Timer DecodingResultDispatcherTimer;
+#endif
+    DecodingResultDispatcherTimer m_timer;
+    std::unique_ptr&lt;DecodeTask&gt; m_decodeTask;
+};
+
</ins><span class="cx"> static Result parseMediaType(const String&amp; mediaType)
</span><span class="cx"> {
</span><span class="cx">     auto mimeType = extractMIMETypeFromMediaType(mediaType);
</span><span class="lines">@@ -69,7 +113,7 @@
</span><span class="cx">     return { mimeType, charset, nullptr };
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-static std::unique_ptr&lt;DecodeTask&gt; createDecodeTask(const URL&amp; url, DecodeCompletionHandler completionHandler)
</del><ins>+static std::unique_ptr&lt;DecodeTask&gt; createDecodeTask(const URL&amp; url, const ScheduleContext&amp; scheduleContext, DecodeCompletionHandler completionHandler)
</ins><span class="cx"> {
</span><span class="cx">     const char dataString[] = &quot;data:&quot;;
</span><span class="cx">     const char base64String[] = &quot;;base64&quot;;
</span><span class="lines">@@ -89,6 +133,7 @@
</span><span class="cx">         WTF::move(urlString),
</span><span class="cx">         WTF::move(encodedData),
</span><span class="cx">         isBase64,
</span><ins>+        scheduleContext,
</ins><span class="cx">         WTF::move(completionHandler),
</span><span class="cx">         parseMediaType(mediaType)
</span><span class="cx">     });
</span><span class="lines">@@ -118,12 +163,11 @@
</span><span class="cx">     task.result.data = SharedBuffer::adoptVector(buffer);
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-void decode(const URL&amp; url, DecodeCompletionHandler completionHandler)
</del><ins>+void decode(const URL&amp; url, const ScheduleContext&amp; scheduleContext, DecodeCompletionHandler completionHandler)
</ins><span class="cx"> {
</span><span class="cx">     ASSERT(url.protocolIsData());
</span><span class="cx"> 
</span><del>-    auto decodeTask = createDecodeTask(url, WTF::move(completionHandler));
-
</del><ins>+    auto decodeTask = createDecodeTask(url, scheduleContext, WTF::move(completionHandler));
</ins><span class="cx">     auto* decodeTaskPtr = decodeTask.release();
</span><span class="cx">     decodeQueue().dispatch([decodeTaskPtr] {
</span><span class="cx">         auto&amp; decodeTask = *decodeTaskPtr;
</span><span class="lines">@@ -133,14 +177,7 @@
</span><span class="cx">         else
</span><span class="cx">             decodeEscaped(decodeTask);
</span><span class="cx"> 
</span><del>-        callOnMainThread([decodeTaskPtr] {
-            std::unique_ptr&lt;DecodeTask&gt; decodeTask(decodeTaskPtr);
-            if (!decodeTask-&gt;result.data) {
-                decodeTask-&gt;completionHandler({ });
-                return;
-            }
-            decodeTask-&gt;completionHandler(WTF::move(decodeTask-&gt;result));
-        });
</del><ins>+        DecodingResultDispatcher::dispatch(std::unique_ptr&lt;DecodeTask&gt;(decodeTaskPtr));
</ins><span class="cx">     });
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformnetworkDataURLDecoderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/platform/network/DataURLDecoder.h (191672 => 191673)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/network/DataURLDecoder.h        2015-10-28 17:29:41 UTC (rev 191672)
+++ trunk/Source/WebCore/platform/network/DataURLDecoder.h        2015-10-28 17:35:10 UTC (rev 191673)
</span><span class="lines">@@ -31,6 +31,10 @@
</span><span class="cx"> #include &lt;wtf/Optional.h&gt;
</span><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><span class="cx"> 
</span><ins>+#if HAVE(RUNLOOP_TIMER)
+#include &lt;wtf/RunLoopTimer.h&gt;
+#endif
+
</ins><span class="cx"> namespace WebCore {
</span><span class="cx"> 
</span><span class="cx"> class SharedBuffer;
</span><span class="lines">@@ -45,8 +49,13 @@
</span><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> using DecodeCompletionHandler = std::function&lt;void (Optional&lt;Result&gt;)&gt;;
</span><ins>+struct ScheduleContext {
+#if HAVE(RUNLOOP_TIMER)
+    SchedulePairHashSet scheduledPairs;
+#endif
+};
</ins><span class="cx"> 
</span><del>-void decode(const URL&amp;, DecodeCompletionHandler);
</del><ins>+void decode(const URL&amp;, const ScheduleContext&amp;, DecodeCompletionHandler);
</ins><span class="cx"> 
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (191672 => 191673)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2015-10-28 17:29:41 UTC (rev 191672)
+++ trunk/Source/WebKit2/ChangeLog        2015-10-28 17:35:10 UTC (rev 191673)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2015-10-28  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        Use RunLoopTimer in DataURLDecoder to avoid issues related to runloops
+        https://bugs.webkit.org/show_bug.cgi?id=150609
+        &lt;rdar://problem/22702894&gt;
+
+        Reviewed by Antti Koivisto.
+
+        Move addSchedulePair() call to Page::platformInitialize() so that
+        RunLoopTimer can be used by any Page, even those that don't have
+        a WebPage wrapper.
+
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::platformInitialize): Deleted.
+
</ins><span class="cx"> 2015-10-27  Tim Horton  &lt;timothy_horton@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Fix the 32-bit build.
</span></span></pre></div>
<a id="trunkSourceWebKit2WebProcessWebPagemacWebPageMacmm"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm (191672 => 191673)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm        2015-10-28 17:29:41 UTC (rev 191672)
+++ trunk/Source/WebKit2/WebProcess/WebPage/mac/WebPageMac.mm        2015-10-28 17:35:10 UTC (rev 191673)
</span><span class="lines">@@ -98,12 +98,6 @@
</span><span class="cx"> 
</span><span class="cx"> void WebPage::platformInitialize()
</span><span class="cx"> {
</span><del>-#if USE(CFNETWORK)
-    m_page-&gt;addSchedulePair(SchedulePair::create([[NSRunLoop currentRunLoop] getCFRunLoop], kCFRunLoopCommonModes));
-#else
-    m_page-&gt;addSchedulePair(SchedulePair::create([NSRunLoop currentRunLoop], kCFRunLoopCommonModes));
-#endif
-
</del><span class="cx">     WKAccessibilityWebPageObject* mockAccessibilityElement = [[[WKAccessibilityWebPageObject alloc] init] autorelease];
</span><span class="cx"> 
</span><span class="cx">     // Get the pid for the starting process.
</span></span></pre>
</div>
</div>

</body>
</html>