<!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>[178815] branches/safari-600.1.4.15-branch/Source/WebKit2</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/178815">178815</a></dd>
<dt>Author</dt> <dd>bshafiei@apple.com</dd>
<dt>Date</dt> <dd>2015-01-21 00:15:02 -0800 (Wed, 21 Jan 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Merged <a href="http://trac.webkit.org/projects/webkit/changeset/175698">r175698</a>.  rdar://problem/19419806</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#branchessafari6001415branchSourceWebKit2ChangeLog">branches/safari-600.1.4.15-branch/Source/WebKit2/ChangeLog</a></li>
<li><a href="#branchessafari6001415branchSourceWebKit2UIProcessWebProcessProxycpp">branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/WebProcessProxy.cpp</a></li>
<li><a href="#branchessafari6001415branchSourceWebKit2UIProcessWebProcessProxyh">branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/WebProcessProxy.h</a></li>
<li><a href="#branchessafari6001415branchSourceWebKit2UIProcessWebProcessProxymessagesin">branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/WebProcessProxy.messages.in</a></li>
<li><a href="#branchessafari6001415branchSourceWebKit2WebKit2xcodeprojprojectpbxproj">branches/safari-600.1.4.15-branch/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj</a></li>
<li><a href="#branchessafari6001415branchSourceWebKit2WebProcessWebProcesscpp">branches/safari-600.1.4.15-branch/Source/WebKit2/WebProcess/WebProcess.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#branchessafari6001415branchSourceWebKit2WebProcessWebCoreSupportWebSQLiteDatabaseTrackercpp">branches/safari-600.1.4.15-branch/Source/WebKit2/WebProcess/WebCoreSupport/WebSQLiteDatabaseTracker.cpp</a></li>
<li><a href="#branchessafari6001415branchSourceWebKit2WebProcessWebCoreSupportWebSQLiteDatabaseTrackerh">branches/safari-600.1.4.15-branch/Source/WebKit2/WebProcess/WebCoreSupport/WebSQLiteDatabaseTracker.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="branchessafari6001415branchSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/ChangeLog (178814 => 178815)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebKit2/ChangeLog        2015-01-21 08:13:04 UTC (rev 178814)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/ChangeLog        2015-01-21 08:15:02 UTC (rev 178815)
</span><span class="lines">@@ -1,5 +1,56 @@
</span><span class="cx"> 2015-01-21  Babak Shafiei  &lt;bshafiei@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Merge r175698.
+
+    2014-11-06  Daniel Bates  &lt;dabates@apple.com&gt;
+
+            [iOS] WebProcess needs to take a background task assertion to prevent being killed
+            for &quot;suspended with locked system files&quot;
+            https://bugs.webkit.org/show_bug.cgi?id=138155
+            &lt;rdar://problem/17939303&gt;
+
+            Reviewed by Anders Carlsson.
+
+            Mitigates an issue where the WebProcess may be killed when suspended holding locked files
+            by allowing the WebProcess to notify the UIProcess when it is holding such files so that
+            both can continue to run for a period of time after the UIProcess transitions to the
+            background. In particular, the WebProcess notifies the UIProcess that it is holding- or
+            relinquished- a locked file when it begins and ends a sequence of SQLite transactions,
+            respectively.
+
+            * UIProcess/WebProcessProxy.cpp:
+            (WebKit::WebProcessProxy::disconnect): Relinquish an existing background task assertion
+            when the WebProcess disconnects. Among other situations, the WebProcess may disconnect as
+            a result of being suspended holding locked files even when the UIProcess requested a
+            background task assertion (i.e. it may have exceeded its background time limit).
+            (WebKit::WebProcessProxy::setIsHoldingLockedFiles): Added. Either acquires a new background
+            task assertion or relinquishes an existing one.
+            * UIProcess/WebProcessProxy.h:
+            * UIProcess/WebProcessProxy.messages.in: Added message SetIsHoldingLockedFiles(bool). The WebProcess
+            dispatches this message to inform the UIProcess that it is holding- or relinquished- a locked file.
+            * WebKit2.xcodeproj/project.pbxproj: Added files WebSQLiteDatabaseTracker.{cpp, h}.
+            * WebProcess/WebCoreSupport/WebSQLiteDatabaseTracker.cpp: Added.
+            (WebKit::WebSQLiteDatabaseTracker::supplementName): Added.
+            (WebKit::WebSQLiteDatabaseTracker::WebSQLiteDatabaseTracker): Added.
+            (WebKit::WebSQLiteDatabaseTracker::initialize): Register to receive SQLiteDatabaseTrackerClient callbacks.
+            (WebKit::WebSQLiteDatabaseTracker::willBeginFirstTransaction): Inform the HysteresisActivity object on
+            the main thread that we began a transaction so that it calls WebSQLiteDatabaseTracker::started().
+            (WebKit::WebSQLiteDatabaseTracker::didFinishLastTransaction): Inform the HysteresisActivity object on
+            the main thread that we finished a transaction so that it may eventually call WebSQLiteDatabaseTracker::stopped().
+            (WebKit::WebSQLiteDatabaseTracker::started): Notify the UIProcess that the WebProcess is holding
+            a locked file.
+            (WebKit::WebSQLiteDatabaseTracker::stopped): Notify the UIProcess that the WebProcess has
+            relinquished the locked file.
+            * WebProcess/WebCoreSupport/WebSQLiteDatabaseTracker.h: Added. We use a HysteresisActivity object
+            to coalesce SetIsHoldingLockedFiles(false) messages as an optimization to minimize the number of
+            messages exchanged between the UIProcess and WebProcess when a web page performs SQLite transactions
+            in batches.
+            * WebProcess/WebProcess.cpp:
+            (WebKit::WebProcess::WebProcess): Instantiate the supplement WebSQLiteDatabaseTracker when building
+            for iOS.
+
+2015-01-21  Babak Shafiei  &lt;bshafiei@apple.com&gt;
+
</ins><span class="cx">         Merge r175636.
</span><span class="cx"> 
</span><span class="cx">     2014-11-04  Jon Honeycutt  &lt;jhoneycutt@apple.com&gt;
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebKit2UIProcessWebProcessProxycpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/WebProcessProxy.cpp (178814 => 178815)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/WebProcessProxy.cpp        2015-01-21 08:13:04 UTC (rev 178814)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/WebProcessProxy.cpp        2015-01-21 08:15:02 UTC (rev 178815)
</span><span class="lines">@@ -151,6 +151,7 @@
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     m_responsivenessTimer.invalidate();
</span><ins>+    m_tokenForHoldingLockedFiles = nullptr;
</ins><span class="cx"> 
</span><span class="cx">     Vector&lt;RefPtr&lt;WebFrameProxy&gt;&gt; frames;
</span><span class="cx">     copyValuesToVector(m_frameMap, frames);
</span><span class="lines">@@ -753,4 +754,14 @@
</span><span class="cx">     m_throttler-&gt;didCancelProcessSuspension();
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void WebProcessProxy::setIsHoldingLockedFiles(bool isHoldingLockedFiles)
+{
+    if (!isHoldingLockedFiles) {
+        m_tokenForHoldingLockedFiles = nullptr;
+        return;
+    }
+    if (!m_tokenForHoldingLockedFiles)
+        m_tokenForHoldingLockedFiles = std::make_unique&lt;ProcessThrottler::BackgroundActivityToken&gt;(*m_throttler);
+}
+
</ins><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebKit2UIProcessWebProcessProxyh"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/WebProcessProxy.h (178814 => 178815)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/WebProcessProxy.h        2015-01-21 08:13:04 UTC (rev 178814)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/WebProcessProxy.h        2015-01-21 08:15:02 UTC (rev 178815)
</span><span class="lines">@@ -139,7 +139,9 @@
</span><span class="cx">     void processReadyToSuspend();
</span><span class="cx">     void sendCancelProcessWillSuspend();
</span><span class="cx">     void didCancelProcessSuspension();
</span><del>-    
</del><ins>+
+    void setIsHoldingLockedFiles(bool);
+
</ins><span class="cx">     ProcessThrottler&amp; throttler() { return *m_throttler; }
</span><span class="cx">     
</span><span class="cx"> private:
</span><span class="lines">@@ -227,6 +229,7 @@
</span><span class="cx"> 
</span><span class="cx">     int m_numberOfTimesSuddenTerminationWasDisabled;
</span><span class="cx">     std::unique_ptr&lt;ProcessThrottler&gt; m_throttler;
</span><ins>+    std::unique_ptr&lt;ProcessThrottler::BackgroundActivityToken&gt; m_tokenForHoldingLockedFiles;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebKit
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebKit2UIProcessWebProcessProxymessagesin"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/WebProcessProxy.messages.in (178814 => 178815)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/WebProcessProxy.messages.in        2015-01-21 08:13:04 UTC (rev 178814)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/WebProcessProxy.messages.in        2015-01-21 08:15:02 UTC (rev 178815)
</span><span class="lines">@@ -49,4 +49,6 @@
</span><span class="cx"> #endif
</span><span class="cx">     ProcessReadyToSuspend()
</span><span class="cx">     DidCancelProcessSuspension()
</span><ins>+
+    SetIsHoldingLockedFiles(bool isHoldingLockedFiles)
</ins><span class="cx"> }
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebKit2WebKit2xcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (178814 => 178815)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2015-01-21 08:13:04 UTC (rev 178814)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj        2015-01-21 08:15:02 UTC (rev 178815)
</span><span class="lines">@@ -1595,6 +1595,8 @@
</span><span class="cx">                 CDCA85C9132ABA4E00E961DF /* WKFullScreenWindowController.h in Headers */ = {isa = PBXBuildFile; fileRef = CDCA85C7132ABA4E00E961DF /* WKFullScreenWindowController.h */; };
</span><span class="cx">                 CEDA12E2152CD1AE00D9E08D /* WebAlternativeTextClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CEDA12DF152CCAE800D9E08D /* WebAlternativeTextClient.cpp */; };
</span><span class="cx">                 CEDA12E3152CD1B300D9E08D /* WebAlternativeTextClient.h in Headers */ = {isa = PBXBuildFile; fileRef = CEDA12DE152CCAE800D9E08D /* WebAlternativeTextClient.h */; };
</span><ins>+                CEDBA84719FDA00A006866A5 /* WebSQLiteDatabaseTracker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CEDBA84519FDA00A006866A5 /* WebSQLiteDatabaseTracker.cpp */; };
+                CEDBA84819FDA00A006866A5 /* WebSQLiteDatabaseTracker.h in Headers */ = {isa = PBXBuildFile; fileRef = CEDBA84619FDA00A006866A5 /* WebSQLiteDatabaseTracker.h */; };
</ins><span class="cx">                 D3B9484611FF4B6500032B39 /* WebPopupMenu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D3B9484211FF4B6500032B39 /* WebPopupMenu.cpp */; };
</span><span class="cx">                 D3B9484711FF4B6500032B39 /* WebPopupMenu.h in Headers */ = {isa = PBXBuildFile; fileRef = D3B9484311FF4B6500032B39 /* WebPopupMenu.h */; };
</span><span class="cx">                 D3B9484811FF4B6500032B39 /* WebSearchPopupMenu.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D3B9484411FF4B6500032B39 /* WebSearchPopupMenu.cpp */; };
</span><span class="lines">@@ -3693,6 +3695,8 @@
</span><span class="cx">                 CDCA85D4132AC2B300E961DF /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = /System/Library/Frameworks/IOKit.framework; sourceTree = &quot;&lt;absolute&gt;&quot;; };
</span><span class="cx">                 CEDA12DE152CCAE800D9E08D /* WebAlternativeTextClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebAlternativeTextClient.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 CEDA12DF152CCAE800D9E08D /* WebAlternativeTextClient.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebAlternativeTextClient.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                CEDBA84519FDA00A006866A5 /* WebSQLiteDatabaseTracker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebSQLiteDatabaseTracker.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                CEDBA84619FDA00A006866A5 /* WebSQLiteDatabaseTracker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSQLiteDatabaseTracker.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 D3B9484211FF4B6500032B39 /* WebPopupMenu.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebPopupMenu.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 D3B9484311FF4B6500032B39 /* WebPopupMenu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebPopupMenu.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 D3B9484411FF4B6500032B39 /* WebSearchPopupMenu.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebSearchPopupMenu.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -5705,6 +5709,8 @@
</span><span class="cx">                                 1A1E093218861D3800D2DC49 /* WebProgressTrackerClient.h */,
</span><span class="cx">                                 D3B9484411FF4B6500032B39 /* WebSearchPopupMenu.cpp */,
</span><span class="cx">                                 D3B9484511FF4B6500032B39 /* WebSearchPopupMenu.h */,
</span><ins>+                                CEDBA84519FDA00A006866A5 /* WebSQLiteDatabaseTracker.cpp */,
+                                CEDBA84619FDA00A006866A5 /* WebSQLiteDatabaseTracker.h */,
</ins><span class="cx">                         );
</span><span class="cx">                         path = WebCoreSupport;
</span><span class="cx">                         sourceTree = &quot;&lt;group&gt;&quot;;
</span><span class="lines">@@ -7342,6 +7348,7 @@
</span><span class="cx">                                 1AAB037A185A7C6A00EDF501 /* MessageSender.h in Headers */,
</span><span class="cx">                                 1A6FB7AF11E64B6800DB1371 /* PluginView.h in Headers */,
</span><span class="cx">                                 1AFE436618B6C081009C7A48 /* UIDelegate.h in Headers */,
</span><ins>+                                CEDBA84819FDA00A006866A5 /* WebSQLiteDatabaseTracker.h in Headers */,
</ins><span class="cx">                                 E1CC1B9012D7EADF00625838 /* PrintInfo.h in Headers */,
</span><span class="cx">                                 BC1A7C581136E19C00FB7167 /* ProcessLauncher.h in Headers */,
</span><span class="cx">                                 BC597075116591D000551FCA /* ProcessModel.h in Headers */,
</span><span class="lines">@@ -8977,6 +8984,7 @@
</span><span class="cx">                                 371B32DD184D67490013E2B2 /* WKNSURLProtectionSpace.mm in Sources */,
</span><span class="cx">                                 BCC43ABA127B95DC00317F16 /* PlatformPopupMenuData.cpp in Sources */,
</span><span class="cx">                                 1A6FB7D211E651E200DB1371 /* Plugin.cpp in Sources */,
</span><ins>+                                CEDBA84719FDA00A006866A5 /* WebSQLiteDatabaseTracker.cpp in Sources */,
</ins><span class="cx">                                 31A67E0C165B2A99006CBA66 /* PlugInAutoStartProvider.cpp in Sources */,
</span><span class="cx">                                 1A8EF4CC1252403700F7067F /* PluginControllerProxy.cpp in Sources */,
</span><span class="cx">                                 1A2D91A61281D739001EB962 /* PluginControllerProxyMac.mm in Sources */,
</span></span></pre></div>
<a id="branchessafari6001415branchSourceWebKit2WebProcessWebCoreSupportWebSQLiteDatabaseTrackercppfromrev175698trunkSourceWebKit2WebProcessWebCoreSupportWebSQLiteDatabaseTrackercpp"></a>
<div class="copfile"><h4>Copied: branches/safari-600.1.4.15-branch/Source/WebKit2/WebProcess/WebCoreSupport/WebSQLiteDatabaseTracker.cpp (from rev 175698, trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebSQLiteDatabaseTracker.cpp) (0 => 178815)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebKit2/WebProcess/WebCoreSupport/WebSQLiteDatabaseTracker.cpp                                (rev 0)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/WebProcess/WebCoreSupport/WebSQLiteDatabaseTracker.cpp        2015-01-21 08:15:02 UTC (rev 178815)
</span><span class="lines">@@ -0,0 +1,82 @@
</span><ins>+/*
+ * Copyright (C) 2014 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * 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 INC. 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;WebSQLiteDatabaseTracker.h&quot;
+
+#if ENABLE(SQL_DATABASE)
+
+#include &quot;WebProcess.h&quot;
+#include &quot;WebProcessProxyMessages.h&quot;
+#include &lt;WebCore/SQLiteDatabaseTracker.h&gt;
+#include &lt;wtf/MainThread.h&gt;
+
+using namespace WebCore;
+
+namespace WebKit {
+
+const char* WebSQLiteDatabaseTracker::supplementName()
+{
+    return &quot;WebSQLiteDatabaseTracker&quot;;
+}
+
+WebSQLiteDatabaseTracker::WebSQLiteDatabaseTracker(WebProcess* process)
+    : m_process(process)
+    , m_hysteresis(*this)
+{
+}
+
+void WebSQLiteDatabaseTracker::initialize(const WebProcessCreationParameters&amp;)
+{
+    SQLiteDatabaseTracker::setClient(this);
+}
+
+void WebSQLiteDatabaseTracker::willBeginFirstTransaction()
+{
+    callOnMainThread([this] {
+        m_hysteresis.start();
+    });
+}
+
+void WebSQLiteDatabaseTracker::didFinishLastTransaction()
+{
+    callOnMainThread([this] {
+        m_hysteresis.stop();
+    });
+}
+
+void WebSQLiteDatabaseTracker::started()
+{
+    m_process-&gt;parentProcessConnection()-&gt;send(Messages::WebProcessProxy::SetIsHoldingLockedFiles(true), 0);
+}
+
+void WebSQLiteDatabaseTracker::stopped()
+{
+    m_process-&gt;parentProcessConnection()-&gt;send(Messages::WebProcessProxy::SetIsHoldingLockedFiles(false), 0);
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(SQL_DATABASE)
</ins></span></pre></div>
<a id="branchessafari6001415branchSourceWebKit2WebProcessWebCoreSupportWebSQLiteDatabaseTrackerhfromrev175698trunkSourceWebKit2WebProcessWebCoreSupportWebSQLiteDatabaseTrackerh"></a>
<div class="copfile"><h4>Copied: branches/safari-600.1.4.15-branch/Source/WebKit2/WebProcess/WebCoreSupport/WebSQLiteDatabaseTracker.h (from rev 175698, trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebSQLiteDatabaseTracker.h) (0 => 178815)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebKit2/WebProcess/WebCoreSupport/WebSQLiteDatabaseTracker.h                                (rev 0)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/WebProcess/WebCoreSupport/WebSQLiteDatabaseTracker.h        2015-01-21 08:15:02 UTC (rev 178815)
</span><span class="lines">@@ -0,0 +1,68 @@
</span><ins>+/*
+ * Copyright (C) 2014 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.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * 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 INC. 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.
+ */
+
+#ifndef WebSQLiteDatabaseTracker_h
+#define WebSQLiteDatabaseTracker_h
+
+#include &quot;WebProcessSupplement.h&quot;
+#include &lt;WebCore/HysteresisActivity.h&gt;
+#include &lt;WebCore/SQLiteDatabaseTrackerClient.h&gt;
+#include &lt;wtf/Noncopyable.h&gt;
+
+#if ENABLE(SQL_DATABASE)
+
+namespace WebKit {
+
+class WebProcess;
+
+class WebSQLiteDatabaseTracker : public WebCore::SQLiteDatabaseTrackerClient, public WebProcessSupplement {
+    WTF_MAKE_NONCOPYABLE(WebSQLiteDatabaseTracker);
+public:
+    explicit WebSQLiteDatabaseTracker(WebProcess*);
+
+    static const char* supplementName();
+
+    // WebSupplement
+    virtual void initialize(const WebProcessCreationParameters&amp;) override;
+
+    // WebCore::SQLiteDatabaseTrackerClient
+    virtual void willBeginFirstTransaction() override;
+    virtual void didFinishLastTransaction() override;
+
+private:
+    // WebCore::HysteresisActivity
+    friend class WebCore::HysteresisActivity&lt;WebSQLiteDatabaseTracker&gt;;
+    void started();
+    void stopped();
+
+    WebProcess* m_process;
+    WebCore::HysteresisActivity&lt;WebSQLiteDatabaseTracker&gt; m_hysteresis;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(SQL_DATABASE)
+
+#endif // WebSQLiteDatabaseTracker_h
</ins></span></pre></div>
<a id="branchessafari6001415branchSourceWebKit2WebProcessWebProcesscpp"></a>
<div class="modfile"><h4>Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/WebProcess/WebProcess.cpp (178814 => 178815)</h4>
<pre class="diff"><span>
<span class="info">--- branches/safari-600.1.4.15-branch/Source/WebKit2/WebProcess/WebProcess.cpp        2015-01-21 08:13:04 UTC (rev 178814)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/WebProcess/WebProcess.cpp        2015-01-21 08:15:02 UTC (rev 178815)
</span><span class="lines">@@ -113,7 +113,10 @@
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(SQL_DATABASE)
</span><span class="cx"> #include &quot;WebDatabaseManager.h&quot;
</span><ins>+#if PLATFORM(IOS)
+#include &quot;WebSQLiteDatabaseTracker.h&quot;
</ins><span class="cx"> #endif
</span><ins>+#endif
</ins><span class="cx"> 
</span><span class="cx"> #if ENABLE(BATTERY_STATUS)
</span><span class="cx"> #include &quot;WebBatteryManager.h&quot;
</span><span class="lines">@@ -192,7 +195,11 @@
</span><span class="cx">     
</span><span class="cx"> #if ENABLE(SQL_DATABASE)
</span><span class="cx">     addSupplement&lt;WebDatabaseManager&gt;();
</span><ins>+#if PLATFORM(IOS)
+    addSupplement&lt;WebSQLiteDatabaseTracker&gt;();
</ins><span class="cx"> #endif
</span><ins>+#endif
+
</ins><span class="cx"> #if ENABLE(NOTIFICATIONS) || ENABLE(LEGACY_NOTIFICATIONS)
</span><span class="cx">     addSupplement&lt;WebNotificationManager&gt;();
</span><span class="cx"> #endif
</span></span></pre>
</div>
</div>

</body>
</html>