<!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>[212965] 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/212965">212965</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2017-02-24 11:51:17 -0800 (Fri, 24 Feb 2017)</dd>
</dl>

<h3>Log Message</h3>
<pre>[iOS][WK2] Disable network cache speculative revalidation / loading in low power mode
https://bugs.webkit.org/show_bug.cgi?id=168832
&lt;rdar://problem/30697911&gt;

Reviewed by Antti Koivisto.

Source/WebCore:

Add LowPowerModeNotifier class to monitor low power mode state on iOS.

* WebCore.xcodeproj/project.pbxproj:
* platform/LowPowerModeNotifier.cpp: Added.
(WebCore::LowPowerModeNotifier::LowPowerModeNotifier):
(WebCore::LowPowerModeNotifier::isLowPowerModeEnabled):
* platform/LowPowerModeNotifier.h: Added.
* platform/ios/LowPowerModeNotifierIOS.mm: Added.
(-[WebLowPowerModeObserver initWithNotifier:]):
(-[WebLowPowerModeObserver dealloc]):
(-[WebLowPowerModeObserver _didReceiveLowPowerModeChange]):
(WebCore::LowPowerModeNotifier::LowPowerModeNotifier):
(WebCore::LowPowerModeNotifier::isLowPowerModeEnabled):
(WebCore::LowPowerModeNotifier::notifyLowPowerModeChanged):
(WebCore::notifyLowPowerModeChanged):

Source/WebKit2:

Disable network cache speculative revalidation / loading in low power mode on iOS to
save battery.

* NetworkProcess/cache/NetworkCache.cpp:
(WebKit::NetworkCache::Cache::initialize):
* NetworkProcess/cache/NetworkCache.h:</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="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcesscacheNetworkCachecpp">trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp</a></li>
<li><a href="#trunkSourceWebKit2NetworkProcesscacheNetworkCacheh">trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.h</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreplatformLowPowerModeNotifiercpp">trunk/Source/WebCore/platform/LowPowerModeNotifier.cpp</a></li>
<li><a href="#trunkSourceWebCoreplatformLowPowerModeNotifierh">trunk/Source/WebCore/platform/LowPowerModeNotifier.h</a></li>
<li><a href="#trunkSourceWebCoreplatformiosLowPowerModeNotifierIOSmm">trunk/Source/WebCore/platform/ios/LowPowerModeNotifierIOS.mm</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (212964 => 212965)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2017-02-24 19:41:59 UTC (rev 212964)
+++ trunk/Source/WebCore/ChangeLog        2017-02-24 19:51:17 UTC (rev 212965)
</span><span class="lines">@@ -1,5 +1,29 @@
</span><span class="cx"> 2017-02-24  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        [iOS][WK2] Disable network cache speculative revalidation / loading in low power mode
+        https://bugs.webkit.org/show_bug.cgi?id=168832
+        &lt;rdar://problem/30697911&gt;
+
+        Reviewed by Antti Koivisto.
+
+        Add LowPowerModeNotifier class to monitor low power mode state on iOS.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * platform/LowPowerModeNotifier.cpp: Added.
+        (WebCore::LowPowerModeNotifier::LowPowerModeNotifier):
+        (WebCore::LowPowerModeNotifier::isLowPowerModeEnabled):
+        * platform/LowPowerModeNotifier.h: Added.
+        * platform/ios/LowPowerModeNotifierIOS.mm: Added.
+        (-[WebLowPowerModeObserver initWithNotifier:]):
+        (-[WebLowPowerModeObserver dealloc]):
+        (-[WebLowPowerModeObserver _didReceiveLowPowerModeChange]):
+        (WebCore::LowPowerModeNotifier::LowPowerModeNotifier):
+        (WebCore::LowPowerModeNotifier::isLowPowerModeEnabled):
+        (WebCore::LowPowerModeNotifier::notifyLowPowerModeChanged):
+        (WebCore::notifyLowPowerModeChanged):
+
+2017-02-24  Chris Dumez  &lt;cdumez@apple.com&gt;
+
</ins><span class="cx">         [Mac] Report domains using abnormally high memory usage via enhanced privacy logging
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=168797
</span><span class="cx">         &lt;rdar://problem/29964017&gt;
</span></span></pre></div>
<a id="trunkSourceWebCoreWebCorexcodeprojprojectpbxproj"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (212964 => 212965)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2017-02-24 19:41:59 UTC (rev 212964)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj        2017-02-24 19:51:17 UTC (rev 212965)
</span><span class="lines">@@ -1779,6 +1779,9 @@
</span><span class="cx">                 46DFF49B1DC2620B00B80B48 /* JSShadowRootMode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46DFF4991DC261F900B80B48 /* JSShadowRootMode.cpp */; };
</span><span class="cx">                 46DFF49C1DC2620B00B80B48 /* JSShadowRootMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 46DFF49A1DC261F900B80B48 /* JSShadowRootMode.h */; };
</span><span class="cx">                 46EBEA021B7D4D6500BE4941 /* CollectionTraversal.h in Headers */ = {isa = PBXBuildFile; fileRef = 46EBEA011B7D4D5D00BE4941 /* CollectionTraversal.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><ins>+                46EFAF0E1E5FB9CA00E7F34B /* LowPowerModeNotifierIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 46EFAF0D1E5FB9C200E7F34B /* LowPowerModeNotifierIOS.mm */; };
+                46EFAF111E5FB9F100E7F34B /* LowPowerModeNotifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 46EFAF0F1E5FB9E100E7F34B /* LowPowerModeNotifier.cpp */; };
+                46EFAF121E5FB9F100E7F34B /* LowPowerModeNotifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 46EFAF101E5FB9E100E7F34B /* LowPowerModeNotifier.h */; settings = {ATTRIBUTES = (Private, ); }; };
</ins><span class="cx">                 46FCB6181A70820E00C5A21E /* DiagnosticLoggingKeys.h in Headers */ = {isa = PBXBuildFile; fileRef = CD37B37515C1A7E1006DC898 /* DiagnosticLoggingKeys.h */; settings = {ATTRIBUTES = (Private, ); }; };
</span><span class="cx">                 490707E61219C04300D90E51 /* ANGLEWebKitBridge.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 490707E41219C04300D90E51 /* ANGLEWebKitBridge.cpp */; };
</span><span class="cx">                 490707E71219C04300D90E51 /* ANGLEWebKitBridge.h in Headers */ = {isa = PBXBuildFile; fileRef = 490707E51219C04300D90E51 /* ANGLEWebKitBridge.h */; };
</span><span class="lines">@@ -9096,6 +9099,9 @@
</span><span class="cx">                 46DFF4991DC261F900B80B48 /* JSShadowRootMode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSShadowRootMode.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 46DFF49A1DC261F900B80B48 /* JSShadowRootMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSShadowRootMode.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 46EBEA011B7D4D5D00BE4941 /* CollectionTraversal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CollectionTraversal.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><ins>+                46EFAF0D1E5FB9C200E7F34B /* LowPowerModeNotifierIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LowPowerModeNotifierIOS.mm; sourceTree = &quot;&lt;group&gt;&quot;; };
+                46EFAF0F1E5FB9E100E7F34B /* LowPowerModeNotifier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LowPowerModeNotifier.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
+                46EFAF101E5FB9E100E7F34B /* LowPowerModeNotifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LowPowerModeNotifier.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</ins><span class="cx">                 490707E41219C04300D90E51 /* ANGLEWebKitBridge.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ANGLEWebKitBridge.cpp; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 490707E51219C04300D90E51 /* ANGLEWebKitBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ANGLEWebKitBridge.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="cx">                 49291E4A134172C800E753DE /* ImageRenderingMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageRenderingMode.h; sourceTree = &quot;&lt;group&gt;&quot;; };
</span><span class="lines">@@ -20109,6 +20115,7 @@
</span><span class="cx">                                 E4B65A5D132FADB60070E7BE /* LegacyTileLayer.mm */,
</span><span class="cx">                                 E4E39AFA1330EFA8003AB274 /* LegacyTileLayerPool.h */,
</span><span class="cx">                                 E4E39AFC1330EFC5003AB274 /* LegacyTileLayerPool.mm */,
</span><ins>+                                46EFAF0D1E5FB9C200E7F34B /* LowPowerModeNotifierIOS.mm */,
</ins><span class="cx">                                 E45390190EAFCACA003695C8 /* PasteboardIOS.mm */,
</span><span class="cx">                                 26601EBD14B3B9AD0012C0FE /* PlatformEventFactoryIOS.h */,
</span><span class="cx">                                 26601EBE14B3B9AD0012C0FE /* PlatformEventFactoryIOS.mm */,
</span><span class="lines">@@ -22986,6 +22993,8 @@
</span><span class="cx">                                 A8239DFF09B3CF8A00B60641 /* Logging.h */,
</span><span class="cx">                                 0FDCD7F21D47E655009F08BC /* LogInitialization.h */,
</span><span class="cx">                                 0FDCD7F41D47E725009F08BC /* LogMacros.h */,
</span><ins>+                                46EFAF0F1E5FB9E100E7F34B /* LowPowerModeNotifier.cpp */,
+                                46EFAF101E5FB9E100E7F34B /* LowPowerModeNotifier.h */,
</ins><span class="cx">                                 7AE6C9391BE0C60100E19E03 /* MainThreadSharedTimer.cpp */,
</span><span class="cx">                                 7AE6C93A1BE0C60100E19E03 /* MainThreadSharedTimer.h */,
</span><span class="cx">                                 CDF2B003181F059C00F2B424 /* MediaDescription.h */,
</span><span class="lines">@@ -28087,6 +28096,7 @@
</span><span class="cx">                                 E4E9B11D1814569C003ACCDF /* SimpleLineLayoutFunctions.h in Headers */,
</span><span class="cx">                                 E4E9B1191810916F003ACCDF /* SimpleLineLayoutResolver.h in Headers */,
</span><span class="cx">                                 582CB0531A78A14B00AFFCC4 /* SimpleLineLayoutTextFragmentIterator.h in Headers */,
</span><ins>+                                46EFAF121E5FB9F100E7F34B /* LowPowerModeNotifier.h in Headers */,
</ins><span class="cx">                                 C5A1EA7D152BCF08004D00B6 /* SimplifyMarkupCommand.h in Headers */,
</span><span class="cx">                                 572A7F211C6E5719009C6149 /* SimulatedClick.h in Headers */,
</span><span class="cx">                                 31741AAD16636609008A5B7E /* SimulatedClickOptions.h in Headers */,
</span><span class="lines">@@ -31297,6 +31307,7 @@
</span><span class="cx">                                 A8C4A80009D563270003AC8D /* Node.cpp in Sources */,
</span><span class="cx">                                 854FE7320A2297BE0058D7AD /* NodeFilterCondition.cpp in Sources */,
</span><span class="cx">                                 854FE7340A2297BE0058D7AD /* NodeIterator.cpp in Sources */,
</span><ins>+                                46EFAF0E1E5FB9CA00E7F34B /* LowPowerModeNotifierIOS.mm in Sources */,
</ins><span class="cx">                                 4FFC022B1643B710004E1638 /* NodeRareData.cpp in Sources */,
</span><span class="cx">                                 E43105B816750F0C00DB2FB8 /* NodeTraversal.cpp in Sources */,
</span><span class="cx">                                 33503CC71017A1B1003B47E1 /* Notification.cpp in Sources */,
</span><span class="lines">@@ -32399,6 +32410,7 @@
</span><span class="cx">                                 00B9318913BA8DBC0035A948 /* XMLDocumentParserLibxml2.cpp in Sources */,
</span><span class="cx">                                 00B9318B13BA8DC90035A948 /* XMLDocumentParserScope.cpp in Sources */,
</span><span class="cx">                                 59C28045138DC2410079B7E2 /* XMLErrors.cpp in Sources */,
</span><ins>+                                46EFAF111E5FB9F100E7F34B /* LowPowerModeNotifier.cpp in Sources */,
</ins><span class="cx">                                 BC772C460C4EB2C60083285F /* XMLHttpRequest.cpp in Sources */,
</span><span class="cx">                                 A136A00C1134DBD200CC8D50 /* XMLHttpRequestProgressEventThrottle.cpp in Sources */,
</span><span class="cx">                                 BCDFD48F0E305290009D10AD /* XMLHttpRequestUpload.cpp in Sources */,
</span></span></pre></div>
<a id="trunkSourceWebCoreplatformLowPowerModeNotifiercpp"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/LowPowerModeNotifier.cpp (0 => 212965)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/LowPowerModeNotifier.cpp                                (rev 0)
+++ trunk/Source/WebCore/platform/LowPowerModeNotifier.cpp        2017-02-24 19:51:17 UTC (rev 212965)
</span><span class="lines">@@ -0,0 +1,44 @@
</span><ins>+/*
+ * Copyright (C) 2017 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;LowPowerModeNotifier.h&quot;
+
+namespace WebCore {
+
+#if !PLATFORM(IOS)
+
+LowPowerModeNotifier::LowPowerModeNotifier(LowPowerModeChangeCallback&amp;&amp;)
+{
+}
+
+bool LowPowerModeNotifier::isLowPowerModeEnabled() const
+{
+    return false;
+}
+
+#endif
+
+} // namespace WebCore
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformLowPowerModeNotifierh"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/LowPowerModeNotifier.h (0 => 212965)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/LowPowerModeNotifier.h                                (rev 0)
+++ trunk/Source/WebCore/platform/LowPowerModeNotifier.h        2017-02-24 19:51:17 UTC (rev 212965)
</span><span class="lines">@@ -0,0 +1,56 @@
</span><ins>+/*
+ * Copyright (C) 2017 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.
+ */
+
+#pragma once
+
+#include &lt;wtf/Function.h&gt;
+
+#if PLATFORM(IOS)
+
+#include &lt;wtf/RetainPtr.h&gt;
+OBJC_CLASS WebLowPowerModeObserver;
+
+#endif
+
+namespace WebCore {
+
+class LowPowerModeNotifier {
+public:
+    using LowPowerModeChangeCallback = WTF::Function&lt;void(bool isLowPowerModeEnabled)&gt;;
+    WEBCORE_EXPORT explicit LowPowerModeNotifier(LowPowerModeChangeCallback&amp;&amp;);
+
+    WEBCORE_EXPORT bool isLowPowerModeEnabled() const;
+
+private:
+#if PLATFORM(IOS)
+    void notifyLowPowerModeChanged(bool);
+    friend void notifyLowPowerModeChanged(LowPowerModeNotifier*, bool);
+
+    RetainPtr&lt;WebLowPowerModeObserver&gt; m_observer;
+    LowPowerModeChangeCallback m_callback;
+#endif
+};
+
+}
</ins></span></pre></div>
<a id="trunkSourceWebCoreplatformiosLowPowerModeNotifierIOSmm"></a>
<div class="addfile"><h4>Added: trunk/Source/WebCore/platform/ios/LowPowerModeNotifierIOS.mm (0 => 212965)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/platform/ios/LowPowerModeNotifierIOS.mm                                (rev 0)
+++ trunk/Source/WebCore/platform/ios/LowPowerModeNotifierIOS.mm        2017-02-24 19:51:17 UTC (rev 212965)
</span><span class="lines">@@ -0,0 +1,94 @@
</span><ins>+/*
+ * Copyright (C) 2017 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.
+ */
+
+#import &quot;config.h&quot;
+
+#if PLATFORM(IOS)
+#import &quot;LowPowerModeNotifier.h&quot;
+
+#import &quot;Logging.h&quot;
+#import &lt;Foundation/NSProcessInfo.h&gt;
+
+@interface WebLowPowerModeObserver : NSObject
+@property (nonatomic) WebCore::LowPowerModeNotifier* notifier;
+@property (nonatomic, readonly) BOOL isLowPowerModeEnabled;
+@end
+
+@implementation WebLowPowerModeObserver {
+}
+
+- (WebLowPowerModeObserver *)initWithNotifier:(WebCore::LowPowerModeNotifier *)notifier
+{
+    self = [super init];
+    if (!self)
+        return nil;
+
+    _notifier = notifier;
+    _isLowPowerModeEnabled = [NSProcessInfo processInfo].lowPowerModeEnabled;
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_didReceiveLowPowerModeChange) name:NSProcessInfoPowerStateDidChangeNotification object:nil];
+    return self;
+}
+
+- (void)dealloc
+{
+    [[NSNotificationCenter defaultCenter] removeObserver:self name:NSProcessInfoPowerStateDidChangeNotification object:nil];
+    [super dealloc];
+}
+
+- (void)_didReceiveLowPowerModeChange
+{
+    _isLowPowerModeEnabled = [NSProcessInfo processInfo].lowPowerModeEnabled;
+    notifyLowPowerModeChanged(_notifier, _isLowPowerModeEnabled);
+}
+
+@end
+
+namespace WebCore {
+
+LowPowerModeNotifier::LowPowerModeNotifier(LowPowerModeChangeCallback&amp;&amp; callback)
+    : m_observer(adoptNS([[WebLowPowerModeObserver alloc] initWithNotifier: this]))
+    , m_callback(WTFMove(callback))
+{
+}
+
+bool LowPowerModeNotifier::isLowPowerModeEnabled() const
+{
+    return m_observer.get().isLowPowerModeEnabled;
+}
+
+void LowPowerModeNotifier::notifyLowPowerModeChanged(bool enabled)
+{
+    m_callback(enabled);
+}
+
+void notifyLowPowerModeChanged(LowPowerModeNotifier* notifier, bool enabled)
+{
+    RELEASE_LOG(PerformanceLogging, &quot;Low power mode state has changed to %d&quot;, enabled);
+    notifier-&gt;notifyLowPowerModeChanged(enabled);
+}
+
+} // namespace WebCore
+
+#endif
</ins></span></pre></div>
<a id="trunkSourceWebKit2ChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/ChangeLog (212964 => 212965)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/ChangeLog        2017-02-24 19:41:59 UTC (rev 212964)
+++ trunk/Source/WebKit2/ChangeLog        2017-02-24 19:51:17 UTC (rev 212965)
</span><span class="lines">@@ -1,3 +1,18 @@
</span><ins>+2017-02-24  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        [iOS][WK2] Disable network cache speculative revalidation / loading in low power mode
+        https://bugs.webkit.org/show_bug.cgi?id=168832
+        &lt;rdar://problem/30697911&gt;
+
+        Reviewed by Antti Koivisto.
+
+        Disable network cache speculative revalidation / loading in low power mode on iOS to
+        save battery.
+
+        * NetworkProcess/cache/NetworkCache.cpp:
+        (WebKit::NetworkCache::Cache::initialize):
+        * NetworkProcess/cache/NetworkCache.h:
+
</ins><span class="cx"> 2017-02-24  John Wilander  &lt;wilander@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Resource Load Statistics: Add alternate classification method
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcesscacheNetworkCachecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp (212964 => 212965)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp        2017-02-24 19:41:59 UTC (rev 212964)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp        2017-02-24 19:51:17 UTC (rev 212965)
</span><span class="lines">@@ -35,6 +35,7 @@
</span><span class="cx"> #include &lt;WebCore/CacheValidation.h&gt;
</span><span class="cx"> #include &lt;WebCore/FileSystem.h&gt;
</span><span class="cx"> #include &lt;WebCore/HTTPHeaderNames.h&gt;
</span><ins>+#include &lt;WebCore/LowPowerModeNotifier.h&gt;
</ins><span class="cx"> #include &lt;WebCore/NetworkStorageSession.h&gt;
</span><span class="cx"> #include &lt;WebCore/PlatformCookieJar.h&gt;
</span><span class="cx"> #include &lt;WebCore/ResourceRequest.h&gt;
</span><span class="lines">@@ -77,8 +78,19 @@
</span><span class="cx">     m_storage = Storage::open(cachePath);
</span><span class="cx"> 
</span><span class="cx"> #if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION)
</span><del>-    if (parameters.enableNetworkCacheSpeculativeRevalidation)
-        m_speculativeLoadManager = std::make_unique&lt;SpeculativeLoadManager&gt;(*m_storage);
</del><ins>+    if (parameters.enableNetworkCacheSpeculativeRevalidation) {
+        m_lowPowerModeNotifier = std::make_unique&lt;WebCore::LowPowerModeNotifier&gt;([this](bool isLowPowerModeEnabled) {
+            ASSERT(WTF::isMainThread());
+            if (isLowPowerModeEnabled)
+                m_speculativeLoadManager = nullptr;
+            else {
+                ASSERT(!m_speculativeLoadManager);
+                m_speculativeLoadManager = std::make_unique&lt;SpeculativeLoadManager&gt;(*m_storage);
+            }
+        });
+        if (!m_lowPowerModeNotifier-&gt;isLowPowerModeEnabled())
+            m_speculativeLoadManager = std::make_unique&lt;SpeculativeLoadManager&gt;(*m_storage);
+    }
</ins><span class="cx"> #endif
</span><span class="cx"> 
</span><span class="cx">     if (parameters.enableEfficacyLogging)
</span></span></pre></div>
<a id="trunkSourceWebKit2NetworkProcesscacheNetworkCacheh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.h (212964 => 212965)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.h        2017-02-24 19:41:59 UTC (rev 212964)
+++ trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.h        2017-02-24 19:51:17 UTC (rev 212965)
</span><span class="lines">@@ -36,6 +36,7 @@
</span><span class="cx"> #include &lt;wtf/text/WTFString.h&gt;
</span><span class="cx"> 
</span><span class="cx"> namespace WebCore {
</span><ins>+class LowPowerModeNotifier;
</ins><span class="cx"> class ResourceRequest;
</span><span class="cx"> class SharedBuffer;
</span><span class="cx"> class URL;
</span><span class="lines">@@ -147,6 +148,7 @@
</span><span class="cx"> 
</span><span class="cx">     std::unique_ptr&lt;Storage&gt; m_storage;
</span><span class="cx"> #if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION)
</span><ins>+    std::unique_ptr&lt;WebCore::LowPowerModeNotifier&gt; m_lowPowerModeNotifier;
</ins><span class="cx">     std::unique_ptr&lt;SpeculativeLoadManager&gt; m_speculativeLoadManager;
</span><span class="cx"> #endif
</span><span class="cx">     std::unique_ptr&lt;Statistics&gt; m_statistics;
</span></span></pre>
</div>
</div>

</body>
</html>