Source/WebCore/ChangeLog

 12017-09-27 Ross Kirsling <ross.kirsling@sony.com>
 2
 3 [PAL] Move HysteresisActivity into PAL
 4 https://bugs.webkit.org/show_bug.cgi?id=177516
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 No new tests (OOPS!).
 9
 10 * WebCore.xcodeproj/project.pbxproj:
 11 * platform/UserActivity.cpp:
 12 (WebCore::UserActivity::UserActivity):
 13 (WebCore::UserActivity::hysteresisUpdated):
 14 * platform/UserActivity.h:
 15 * platform/graphics/cairo/BackingStoreBackendCairoImpl.h:
 16 * platform/ios/WebSQLiteDatabaseTrackerClient.h:
 17
1182017-09-27 Don Olmstead <don.olmstead@sony.com>
219
320 Default to void* for platform widgets

Source/WebCore/PAL/ChangeLog

 12017-09-27 Ross Kirsling <ross.kirsling@sony.com>
 2
 3 [PAL] Move HysteresisActivity into PAL
 4 https://bugs.webkit.org/show_bug.cgi?id=177516
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * PAL.xcodeproj/project.pbxproj:
 9 * pal/HysteresisActivity.h: Renamed from Source/WebCore/platform/HysteresisActivity.h.
 10
1112017-09-26 Don Olmstead <don.olmstead@sony.com>
212
313 [PAL][CMake] Include ICU directories

Source/WebKit/ChangeLog

 12017-09-27 Ross Kirsling <ross.kirsling@sony.com>
 2
 3 [PAL] Move HysteresisActivity into PAL
 4 https://bugs.webkit.org/show_bug.cgi?id=177516
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp:
 9 (WebKit::NetworkCache::SpeculativeLoadManager::PendingFrameLoad::PendingFrameLoad):
 10 * Shared/WebSQLiteDatabaseTracker.cpp:
 11 (WebKit::WebSQLiteDatabaseTracker::WebSQLiteDatabaseTracker):
 12 (WebKit::WebSQLiteDatabaseTracker::hysteresisUpdated):
 13 * Shared/WebSQLiteDatabaseTracker.h:
 14 * WebProcess/WebPage/WebPage.cpp:
 15 (WebKit::m_pageScrolledHysteresis):
 16 (WebKit::m_userActivityHysteresis):
 17 (WebKit::WebPage::updateUserActivity):
 18 * WebProcess/WebPage/WebPage.h:
 19 * WebProcess/WebProcess.cpp:
 20 (WebKit::WebProcess::WebProcess):
 21 * WebProcess/WebProcess.h:
 22
1232017-09-26 Alex Christensen <achristensen@webkit.org>
224
325 Pass a completion handler instead of a WebFramePolicyListenerProxy during policy decisions

Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj

127127 A3788E981F05B6CE00679425 /* Sound.h in Headers */ = {isa = PBXBuildFile; fileRef = A3788E971F05B6CE00679425 /* Sound.h */; };
128128 A3788E9C1F05B78200679425 /* Sound.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A3788E9B1F05B78200679425 /* Sound.cpp */; };
129129 A3788E9E1F05B78E00679425 /* SoundMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = A3788E9D1F05B78E00679425 /* SoundMac.mm */; };
 130 A39DE74E1F7C443D007BCB00 /* HysteresisActivity.h in Headers */ = {isa = PBXBuildFile; fileRef = A39DE74D1F7C443C007BCB00 /* HysteresisActivity.h */; };
130131 A3AB6E521F3D1DC5009C14B1 /* SleepDisabler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A3AB6E511F3D1DC5009C14B1 /* SleepDisabler.cpp */; };
131132 A3AB6E561F3D1DDB009C14B1 /* SleepDisabler.h in Headers */ = {isa = PBXBuildFile; fileRef = A3AB6E531F3D1DDB009C14B1 /* SleepDisabler.h */; };
132133 A3AB6E571F3D1DDB009C14B1 /* SystemSleepListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A3AB6E541F3D1DDB009C14B1 /* SystemSleepListener.cpp */; };

262263 A3788E971F05B6CE00679425 /* Sound.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Sound.h; sourceTree = "<group>"; };
263264 A3788E9B1F05B78200679425 /* Sound.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Sound.cpp; sourceTree = "<group>"; };
264265 A3788E9D1F05B78E00679425 /* SoundMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SoundMac.mm; sourceTree = "<group>"; };
 266 A39DE74D1F7C443C007BCB00 /* HysteresisActivity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HysteresisActivity.h; sourceTree = "<group>"; };
265267 A3AB6E511F3D1DC5009C14B1 /* SleepDisabler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SleepDisabler.cpp; sourceTree = "<group>"; };
266268 A3AB6E531F3D1DDB009C14B1 /* SleepDisabler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SleepDisabler.h; sourceTree = "<group>"; };
267269 A3AB6E541F3D1DDB009C14B1 /* SystemSleepListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SystemSleepListener.cpp; sourceTree = "<group>"; };

429431 0CF99CA61F738436007EE793 /* CoreMediaSoftLink.cpp */,
430432 0CF99CA71F738437007EE793 /* CoreMediaSoftLink.h */,
431433 );
432  name = cf;
433  path = "New Group";
 434 path = cf;
434435 sourceTree = "<group>";
435436 };
436437 1C09D0341E31C32800725F18 = {

461462 A3788E9F1F05B7CE00679425 /* system */,
462463 A30D411D1F0DD0AC00B71954 /* text */,
463464 0C2D9E721EEF5AF600DBC317 /* ExportMacros.h */,
 465 A39DE74D1F7C443C007BCB00 /* HysteresisActivity.h */,
464466 0708AC321F4C874A001F788F /* Logger.h */,
465467 07377ADB1F5777D70027F16D /* LoggerHelper.h */,
466468 A3C66CDA1F462D6A009E6EE9 /* SessionID.cpp */,

593595 0C5AF91B1F43A4C7002EAC02 /* GraphicsServicesSPI.h in Headers */,
594596 A102658E1F567E9D00B4C844 /* HIServicesSPI.h in Headers */,
595597 A10265891F56747A00B4C844 /* HIToolboxSPI.h in Headers */,
 598 A39DE74E1F7C443D007BCB00 /* HysteresisActivity.h in Headers */,
596599 0C2DA11F1F3BE9E000DBC317 /* ImageIOSPI.h in Headers */,
597600 0C2DA1421F3BEB4900DBC317 /* IOPMLibSPI.h in Headers */,
598601 0C2DA1431F3BEB4900DBC317 /* IOPSLibSPI.h in Headers */,

Source/WebCore/PAL/pal/HysteresisActivity.h

 1/*
 2 * Copyright (C) 2014 Apple Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 * 1. Redistributions of source code must retain the above copyright
 8 * notice, this list of conditions and the following disclaimer.
 9 * 2. Redistributions in binary form must reproduce the above copyright
 10 * notice, this list of conditions and the following disclaimer in the
 11 * documentation and/or other materials provided with the distribution.
 12 *
 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 23 * THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#pragma once
 27
 28#include <wtf/RunLoop.h>
 29#include <wtf/Seconds.h>
 30
 31namespace PAL {
 32
 33static const Seconds defaultHysteresisDuration { 5_s };
 34
 35enum class HysteresisState {
 36 Started,
 37 Stopped
 38};
 39
 40class HysteresisActivity {
 41public:
 42 explicit HysteresisActivity(WTF::Function<void(HysteresisState)>&& callback = [](HysteresisState) { }, Seconds hysteresisSeconds = defaultHysteresisDuration)
 43 : m_callback(WTFMove(callback))
 44 , m_hysteresisSeconds(hysteresisSeconds)
 45 , m_active(false)
 46 , m_timer(RunLoop::main(), this, &HysteresisActivity::hysteresisTimerFired)
 47 {
 48 }
 49
 50 void start()
 51 {
 52 if (m_active)
 53 return;
 54 m_active = true;
 55
 56 if (m_timer.isActive())
 57 m_timer.stop();
 58 else
 59 m_callback(HysteresisState::Started);
 60 }
 61
 62 void stop()
 63 {
 64 if (!m_active)
 65 return;
 66 m_active = false;
 67
 68 m_timer.startOneShot(m_hysteresisSeconds);
 69 }
 70
 71 void impulse()
 72 {
 73 if (!m_active) {
 74 start();
 75 stop();
 76 }
 77 }
 78
 79 HysteresisState state() const
 80 {
 81 return m_active || m_timer.isActive() ? HysteresisState::Started : HysteresisState::Stopped;
 82 }
 83
 84private:
 85 void hysteresisTimerFired()
 86 {
 87 m_timer.stop();
 88 m_callback(HysteresisState::Stopped);
 89 }
 90
 91 WTF::Function<void(HysteresisState)> m_callback;
 92 Seconds m_hysteresisSeconds;
 93 bool m_active;
 94 RunLoop::Timer<HysteresisActivity> m_timer;
 95};
 96
 97} // namespace PAL

Source/WebCore/WebCore.xcodeproj/project.pbxproj

37283728 854FE7390A2297BE0058D7AD /* TreeWalker.h in Headers */ = {isa = PBXBuildFile; fileRef = 854FE72F0A2297BE0058D7AD /* TreeWalker.h */; settings = {ATTRIBUTES = (Private, ); }; };
37293729 861C2EA413FB4FDD00062ABB /* LoadTiming.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 861C2EA313FB4FDD00062ABB /* LoadTiming.cpp */; };
37303730 862F129E18C1576F005C54AF /* CountedUserActivity.h in Headers */ = {isa = PBXBuildFile; fileRef = 862F129D18C1572C005C54AF /* CountedUserActivity.h */; settings = {ATTRIBUTES = (Private, ); }; };
3731  862F12A018C1DD02005C54AF /* HysteresisActivity.h in Headers */ = {isa = PBXBuildFile; fileRef = 862F129F18C1DCE4005C54AF /* HysteresisActivity.h */; settings = {ATTRIBUTES = (Private, ); }; };
37323731 86512EDE154A2AEF00A90426 /* PerformanceResourceTiming.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 86512EDB154A2AEE00A90426 /* PerformanceResourceTiming.cpp */; };
37333732 86512EDF154A2AEF00A90426 /* PerformanceResourceTiming.h in Headers */ = {isa = PBXBuildFile; fileRef = 86512EDC154A2AEF00A90426 /* PerformanceResourceTiming.h */; };
37343733 868160D418766A0A0021E79D /* UserActivity.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 868160D1187669C40021E79D /* UserActivity.cpp */; };

1206412063 85DF2F920AA3C9B600AD64C5 /* HTMLOptionsCollection.idl */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = HTMLOptionsCollection.idl; sourceTree = "<group>"; };
1206512064 861C2EA313FB4FDD00062ABB /* LoadTiming.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadTiming.cpp; sourceTree = "<group>"; };
1206612065 862F129D18C1572C005C54AF /* CountedUserActivity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CountedUserActivity.h; sourceTree = "<group>"; };
12067  862F129F18C1DCE4005C54AF /* HysteresisActivity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HysteresisActivity.h; sourceTree = "<group>"; };
1206812066 86512EDB154A2AEE00A90426 /* PerformanceResourceTiming.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PerformanceResourceTiming.cpp; sourceTree = "<group>"; };
1206912067 86512EDC154A2AEF00A90426 /* PerformanceResourceTiming.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PerformanceResourceTiming.h; sourceTree = "<group>"; };
1207012068 86512EDD154A2AEF00A90426 /* PerformanceResourceTiming.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = PerformanceResourceTiming.idl; sourceTree = "<group>"; };

2460824606 CD62FB941AF018E70012ED7D /* GenericTaskQueue.h */,
2460924607 A8748BDF12CBF2DC001FBA41 /* HashTools.h */,
2461024608 BC3BC29B0E91AB0F00835588 /* HostWindow.h */,
24611  862F129F18C1DCE4005C54AF /* HysteresisActivity.h */,
2461224609 1AE00D57182DAC8D00087DD7 /* KeyedCoding.h */,
2461324610 E15FF7D418C9553800FE4C87 /* KeypressCommand.h */,
2461424611 A3D42A841F33BA3600A64B62 /* LayoutUnit.cpp */,

2589225889 BCEA4813097D93020094C9E4 /* RenderBlockLineLayout.cpp */,
2589325890 BCEA4822097D93020094C9E4 /* RenderBox.cpp */,
2589425891 BCEA4823097D93020094C9E4 /* RenderBox.h */,
 25892 BCEB179B143379F50052EAE9 /* RenderBoxFragmentInfo.h */,
2589525893 BC96DB450F3A882200573CB3 /* RenderBoxModelObject.cpp */,
2589625894 BC96DB420F3A880E00573CB3 /* RenderBoxModelObject.h */,
25897  BCEB179B143379F50052EAE9 /* RenderBoxFragmentInfo.h */,
2589825895 BCEA4826097D93020094C9E4 /* RenderButton.cpp */,
2589925896 BCEA4827097D93020094C9E4 /* RenderButton.h */,
2590025897 B56579B41824D12A00E79F23 /* RenderChildIterator.h */,

2591725914 53C8298C13D8D92700DE2DEB /* RenderFlexibleBox.h */,
2591825915 508CCA4E13CF106B003151F3 /* RenderFlowThread.cpp */,
2591925916 508CCA4D13CF106B003151F3 /* RenderFlowThread.h */,
 25917 D70AD65513E1342B005B50B4 /* RenderFragmentContainer.cpp */,
 25918 D70AD65613E1342B005B50B4 /* RenderFragmentContainer.h */,
 25919 BCE93F461517C6D5008CCF74 /* RenderFragmentContainerSet.cpp */,
 25920 BCE93F441517C567008CCF74 /* RenderFragmentContainerSet.h */,
2592025921 A871DECC0A1530C700B12A68 /* RenderFrame.cpp */,
2592125922 A871DECB0A1530C700B12A68 /* RenderFrame.h */,
2592225923 0FD3080C117CF7E700A791F7 /* RenderFrameBase.cpp */,

2598925990 ADE16736181050C300463A2E /* RenderPtr.h */,
2599025991 5A574F22131DB93900471B88 /* RenderQuote.cpp */,
2599125992 5A574F23131DB93900471B88 /* RenderQuote.h */,
25992  D70AD65513E1342B005B50B4 /* RenderFragmentContainer.cpp */,
25993  D70AD65613E1342B005B50B4 /* RenderFragmentContainer.h */,
25994  BCE93F461517C6D5008CCF74 /* RenderFragmentContainerSet.cpp */,
25995  BCE93F441517C567008CCF74 /* RenderFragmentContainerSet.h */,
2599625993 A871DFDE0A15376B00B12A68 /* RenderReplaced.cpp */,
2599725994 A871DFDF0A15376B00B12A68 /* RenderReplaced.h */,
2599825995 BCA846D40DC67A350026C309 /* RenderReplica.cpp */,

2781727814 84730D891248F0B300D3A9C9 /* FESpecularLighting.h in Headers */,
2781827815 4129C9971F59B963009D7403 /* FetchBodySource.h in Headers */,
2781927816 41D129DB1F3D143800D15E47 /* FetchHeaders.h in Headers */,
27820  416E6FE81BBD12DF000A6023 /* FetchInternalsBuiltins.h in Headers */,
2782127817 41AD753A1CEF6BD100A31486 /* FetchOptions.h in Headers */,
2782227818 7CE1914D1F2A9AFB00272F78 /* FetchReferrerPolicy.h in Headers */,
2782327819 7CE1915A1F2A9B3400272F78 /* FetchRequestCache.h in Headers */,

2813628132 41614A791DA64241004AD06F /* HTTPHeaderValues.h in Headers */,
2813728133 514C76730CE923A1007EF3CD /* HTTPParsers.h in Headers */,
2813828134 375CD232119D43C800A2A859 /* Hyphenation.h in Headers */,
28139  862F12A018C1DD02005C54AF /* HysteresisActivity.h in Headers */,
2814028135 5EBB89331C77782900C65D41 /* IceCandidate.h in Headers */,
2814128136 B275356E0B053814002CE64F /* Icon.h in Headers */,
2814228137 513F14540AB634C400094DDF /* IconLoader.h in Headers */,

2965829653 BCEA4860097D93020094C9E4 /* RenderBlock.h in Headers */,
2965929654 BC10D76817D8EE71005E2626 /* RenderBlockFlow.h in Headers */,
2966029655 BCEA4862097D93020094C9E4 /* RenderBox.h in Headers */,
29661  BC96DB430F3A880E00573CB3 /* RenderBoxModelObject.h in Headers */,
2966229656 BCEB179C143379F50052EAE9 /* RenderBoxFragmentInfo.h in Headers */,
 29657 BC96DB430F3A880E00573CB3 /* RenderBoxModelObject.h in Headers */,
2966329658 BCEA4866097D93020094C9E4 /* RenderButton.h in Headers */,
2966429659 B56579B51824D12A00E79F23 /* RenderChildIterator.h in Headers */,
2966529660 BCE4413412F748E2009B84B8 /* RenderCombineText.h in Headers */,

2967429669 066C77310AB603FD00238CC4 /* RenderFileUploadControl.h in Headers */,
2967529670 53C8298E13D8D92700DE2DEB /* RenderFlexibleBox.h in Headers */,
2967629671 508CCA4F13CF106B003151F3 /* RenderFlowThread.h in Headers */,
 29672 D70AD65813E1342B005B50B4 /* RenderFragmentContainer.h in Headers */,
 29673 BCE93F451517C567008CCF74 /* RenderFragmentContainerSet.h in Headers */,
2967729674 A871DED30A1530C700B12A68 /* RenderFrame.h in Headers */,
2967829675 0FD3080F117CF7E700A791F7 /* RenderFrameBase.h in Headers */,
2967929676 A871DED10A1530C700B12A68 /* RenderFrameSet.h in Headers */,

2972329720 A43BF59D1149292800C643CA /* RenderProgress.h in Headers */,
2972429721 B5B65874186FDE4C009C26E8 /* RenderPtr.h in Headers */,
2972529722 5A574F25131DB93900471B88 /* RenderQuote.h in Headers */,
29726  D70AD65813E1342B005B50B4 /* RenderFragmentContainer.h in Headers */,
29727  BCE93F451517C567008CCF74 /* RenderFragmentContainerSet.h in Headers */,
2972829723 A871DFE30A15376B00B12A68 /* RenderReplaced.h in Headers */,
2972929724 BCA846D70DC67A350026C309 /* RenderReplica.h in Headers */,
2973029725 1479FAEE109AE37500DED655 /* RenderRuby.h in Headers */,

3363533630 066C77300AB603FD00238CC4 /* RenderFileUploadControl.cpp in Sources */,
3363633631 53C8298D13D8D92700DE2DEB /* RenderFlexibleBox.cpp in Sources */,
3363733632 508CCA5013CF106B003151F3 /* RenderFlowThread.cpp in Sources */,
 33633 D70AD65713E1342B005B50B4 /* RenderFragmentContainer.cpp in Sources */,
 33634 BCE93F471517C6D5008CCF74 /* RenderFragmentContainerSet.cpp in Sources */,
3363833635 A871DED40A1530C700B12A68 /* RenderFrame.cpp in Sources */,
3363933636 0FD3080E117CF7E700A791F7 /* RenderFrameBase.cpp in Sources */,
3364033637 A871DED20A1530C700B12A68 /* RenderFrameSet.cpp in Sources */,

3368333680 BCEA487F097D93020094C9E4 /* RenderObject.cpp in Sources */,
3368433681 A43BF59C1149292800C643CA /* RenderProgress.cpp in Sources */,
3368533682 5A574F24131DB93900471B88 /* RenderQuote.cpp in Sources */,
33686  D70AD65713E1342B005B50B4 /* RenderFragmentContainer.cpp in Sources */,
33687  BCE93F471517C6D5008CCF74 /* RenderFragmentContainerSet.cpp in Sources */,
3368833683 A871DFE20A15376B00B12A68 /* RenderReplaced.cpp in Sources */,
3368933684 BCA846D60DC67A350026C309 /* RenderReplica.cpp in Sources */,
3369033685 1479FAED109AE37500DED655 /* RenderRuby.cpp in Sources */,

Source/WebCore/platform/HysteresisActivity.h

1 /*
2  * Copyright (C) 2014 Apple Inc. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23  * THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 
26 #ifndef HysteresisActivity_h
27 #define HysteresisActivity_h
28 
29 #include <wtf/RunLoop.h>
30 #include <wtf/Seconds.h>
31 
32 namespace WebCore {
33 
34 static const Seconds defaultHysteresisDuration { 5_s };
35 
36 enum class HysteresisState {
37  Started,
38  Stopped
39 };
40 
41 class HysteresisActivity {
42 public:
43  explicit HysteresisActivity(WTF::Function<void(HysteresisState)>&& callback = [](HysteresisState) { }, Seconds hysteresisSeconds = defaultHysteresisDuration)
44  : m_callback(WTFMove(callback))
45  , m_hysteresisSeconds(hysteresisSeconds)
46  , m_active(false)
47  , m_timer(RunLoop::main(), this, &HysteresisActivity::hysteresisTimerFired)
48  {
49  }
50 
51  void start()
52  {
53  if (m_active)
54  return;
55  m_active = true;
56 
57  if (m_timer.isActive())
58  m_timer.stop();
59  else
60  m_callback(HysteresisState::Started);
61  }
62 
63  void stop()
64  {
65  if (!m_active)
66  return;
67  m_active = false;
68 
69  m_timer.startOneShot(m_hysteresisSeconds);
70  }
71 
72  void impulse()
73  {
74  if (!m_active) {
75  start();
76  stop();
77  }
78  }
79 
80  HysteresisState state() const
81  {
82  return m_active || m_timer.isActive() ? HysteresisState::Started : HysteresisState::Stopped;
83  }
84 
85 private:
86  void hysteresisTimerFired()
87  {
88  m_timer.stop();
89  m_callback(HysteresisState::Stopped);
90  }
91 
92  WTF::Function<void(HysteresisState)> m_callback;
93  Seconds m_hysteresisSeconds;
94  bool m_active;
95  RunLoop::Timer<HysteresisActivity> m_timer;
96 };
97 
98 } // namespace WebCore
99 
100 #endif // HysteresisActivity_h

Source/WebCore/platform/UserActivity.cpp

@@void UserActivity::Impl::endActivity()
4545#endif
4646
4747UserActivity::UserActivity(const char* description)
48  : HysteresisActivity([this](HysteresisState state) { hysteresisUpdated(state); })
 48 : PAL::HysteresisActivity([this](PAL::HysteresisState state) { hysteresisUpdated(state); })
4949 , m_impl(description)
5050{
5151}
5252
53 void UserActivity::hysteresisUpdated(HysteresisState state)
 53void UserActivity::hysteresisUpdated(PAL::HysteresisState state)
5454{
55  if (state == HysteresisState::Started)
 55 if (state == PAL::HysteresisState::Started)
5656 m_impl.beginActivity();
5757 else
5858 m_impl.endActivity();

Source/WebCore/platform/UserActivity.h

2626#ifndef UserActivity_h
2727#define UserActivity_h
2828
29 #include "HysteresisActivity.h"
 29#include <pal/HysteresisActivity.h>
3030
3131#if HAVE(NS_ACTIVITY)
3232#include <objc/objc.h>

@@namespace WebCore {
4040// The UserActivity type is used to indicate to the operating system that
4141// a user initiated or visible action is taking place, and as such that
4242// resources should be allocated to the process accordingly.
43 class UserActivity : public HysteresisActivity {
 43class UserActivity : public PAL::HysteresisActivity {
4444public:
4545 class Impl {
4646 public:

@@public:
5959 WEBCORE_EXPORT explicit UserActivity(const char* description);
6060
6161private:
62  void hysteresisUpdated(HysteresisState);
 62 void hysteresisUpdated(PAL::HysteresisState);
6363
6464 Impl m_impl;
6565};

Source/WebCore/platform/graphics/cairo/BackingStoreBackendCairoImpl.h

2020
2121#if USE(CAIRO)
2222#include "BackingStoreBackendCairo.h"
23 #include <WebCore/HysteresisActivity.h>
 23#include <pal/HysteresisActivity.h>
2424
2525namespace WebCore {
2626

@@private:
3333 void scroll(const IntRect&, const IntSize&) override;
3434
3535 RefPtr<cairo_surface_t> m_scrollSurface;
36  WebCore::HysteresisActivity m_scrolledHysteresis;
 36 PAL::HysteresisActivity m_scrolledHysteresis;
3737};
3838
3939} // namespace WebCore

Source/WebCore/platform/ios/WebSQLiteDatabaseTrackerClient.h

2727
2828#if PLATFORM(IOS)
2929
30 #include "HysteresisActivity.h"
3130#include "SQLiteDatabaseTrackerClient.h"
 31#include <pal/HysteresisActivity.h>
3232#include <wtf/Forward.h>
3333#include <wtf/Noncopyable.h>
3434

@@private:
4949
5050 void hysteresisUpdated(HysteresisState);
5151
52  HysteresisActivity m_hysteresis;
 52 PAL::HysteresisActivity m_hysteresis;
5353};
5454
5555}

Source/WebKit/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp

3434#include "NetworkCacheSubresourcesEntry.h"
3535#include "NetworkProcess.h"
3636#include <WebCore/DiagnosticLoggingKeys.h>
37 #include <WebCore/HysteresisActivity.h>
 37#include <pal/HysteresisActivity.h>
3838#include <wtf/HashCountedSet.h>
3939#include <wtf/NeverDestroyed.h>
4040#include <wtf/RefCounted.h>

@@private:
207207 : m_storage(storage)
208208 , m_mainResourceKey(mainResourceKey)
209209 , m_loadCompletionHandler(WTFMove(loadCompletionHandler))
210  , m_loadHysteresisActivity([this](HysteresisState state) { if (state == HysteresisState::Stopped) markLoadAsCompleted(); })
 210 , m_loadHysteresisActivity([this](PAL::HysteresisState state) { if (state == PAL::HysteresisState::Stopped) markLoadAsCompleted(); })
211211 {
212212 m_loadHysteresisActivity.impulse();
213213 }

@@private:
239239 Key m_mainResourceKey;
240240 Vector<std::unique_ptr<SubresourceLoad>> m_subresourceLoads;
241241 WTF::Function<void()> m_loadCompletionHandler;
242  HysteresisActivity m_loadHysteresisActivity;
 242 PAL::HysteresisActivity m_loadHysteresisActivity;
243243 std::unique_ptr<SubresourcesEntry> m_existingEntry;
244244 bool m_didFinishLoad { false };
245245 bool m_didRetrieveExistingEntry { false };

Source/WebKit/Shared/WebSQLiteDatabaseTracker.cpp

@@namespace WebKit {
3939
4040WebSQLiteDatabaseTracker::WebSQLiteDatabaseTracker(NetworkProcess& process)
4141 : m_process(process)
42  , m_hysteresis([this](HysteresisState state) { hysteresisUpdated(state); })
 42 , m_hysteresis([this](PAL::HysteresisState state) { hysteresisUpdated(state); })
4343 , m_childProcessType(ChildProcessType::Network)
4444{
4545 SQLiteDatabaseTracker::setClient(this);

@@WebSQLiteDatabaseTracker::WebSQLiteDatabaseTracker(NetworkProcess& process)
4747
4848WebSQLiteDatabaseTracker::WebSQLiteDatabaseTracker(WebProcess& process)
4949 : m_process(process)
50  , m_hysteresis([this](HysteresisState state) { hysteresisUpdated(state); })
 50 , m_hysteresis([this](PAL::HysteresisState state) { hysteresisUpdated(state); })
5151 , m_childProcessType(ChildProcessType::WebContent)
5252{
5353 SQLiteDatabaseTracker::setClient(this);

@@void WebSQLiteDatabaseTracker::didFinishLastTransaction()
6767 });
6868}
6969
70 void WebSQLiteDatabaseTracker::hysteresisUpdated(HysteresisState state)
 70void WebSQLiteDatabaseTracker::hysteresisUpdated(PAL::HysteresisState state)
7171{
7272 switch (m_childProcessType) {
7373 case ChildProcessType::WebContent:
74  m_process.parentProcessConnection()->send(Messages::WebProcessProxy::SetIsHoldingLockedFiles(state == HysteresisState::Started), 0);
 74 m_process.parentProcessConnection()->send(Messages::WebProcessProxy::SetIsHoldingLockedFiles(state == PAL::HysteresisState::Started), 0);
7575 break;
7676 case ChildProcessType::Network:
77  m_process.parentProcessConnection()->send(Messages::NetworkProcessProxy::SetIsHoldingLockedFiles(state == HysteresisState::Started), 0);
 77 m_process.parentProcessConnection()->send(Messages::NetworkProcessProxy::SetIsHoldingLockedFiles(state == PAL::HysteresisState::Started), 0);
7878 break;
7979 }
8080}

Source/WebKit/Shared/WebSQLiteDatabaseTracker.h

2626#ifndef WebSQLiteDatabaseTracker_h
2727#define WebSQLiteDatabaseTracker_h
2828
29 #include <WebCore/HysteresisActivity.h>
3029#include <WebCore/SQLiteDatabaseTrackerClient.h>
 30#include <pal/HysteresisActivity.h>
3131#include <wtf/Noncopyable.h>
3232
3333namespace WebKit {

@@public:
4747 void didFinishLastTransaction() override;
4848
4949private:
50  void hysteresisUpdated(WebCore::HysteresisState);
 50 void hysteresisUpdated(PAL::HysteresisState);
5151
5252 ChildProcess& m_process;
53  WebCore::HysteresisActivity m_hysteresis;
 53 PAL::HysteresisActivity m_hysteresis;
5454 enum class ChildProcessType { Network, WebContent };
5555 ChildProcessType m_childProcessType;
5656};

Source/WebKit/WebProcess/WebPage/WebPage.cpp

@@WebPage::WebPage(uint64_t pageID, WebPageCreationParameters&& parameters)
339339#if ENABLE(MEDIA_STREAM)
340340 , m_userMediaPermissionRequestManager { std::make_unique<UserMediaPermissionRequestManager>(*this) }
341341#endif
342  , m_pageScrolledHysteresis([this](HysteresisState state) { if (state == HysteresisState::Stopped) pageStoppedScrolling(); }, pageScrollHysteresisDuration)
 342 , m_pageScrolledHysteresis([this](PAL::HysteresisState state) { if (state == PAL::HysteresisState::Stopped) pageStoppedScrolling(); }, pageScrollHysteresisDuration)
343343 , m_canRunBeforeUnloadConfirmPanel(parameters.canRunBeforeUnloadConfirmPanel)
344344 , m_canRunModal(parameters.canRunModal)
345345#if PLATFORM(IOS)

@@WebPage::WebPage(uint64_t pageID, WebPageCreationParameters&& parameters)
352352 , m_activityState(parameters.activityState)
353353 , m_processSuppressionEnabled(true)
354354 , m_userActivity("Process suppression disabled for page.")
355  , m_userActivityHysteresis([this](HysteresisState) { updateUserActivity(); })
 355 , m_userActivityHysteresis([this](PAL::HysteresisState) { updateUserActivity(); })
356356 , m_userInterfaceLayoutDirection(parameters.userInterfaceLayoutDirection)
357357 , m_overrideContentSecurityPolicy { parameters.overrideContentSecurityPolicy }
358358 , m_cpuLimit(parameters.cpuLimit)

@@void WebPage::updateThrottleState()
620620
621621void WebPage::updateUserActivity()
622622{
623  if (m_userActivityHysteresis.state() == HysteresisState::Started)
 623 if (m_userActivityHysteresis.state() == PAL::HysteresisState::Started)
624624 m_userActivity.start();
625625 else
626626 m_userActivity.stop();

Source/WebKit/WebProcess/WebPage/WebPage.h

4949#include <WebCore/ActivityState.h>
5050#include <WebCore/DictionaryPopupInfo.h>
5151#include <WebCore/FrameLoaderTypes.h>
52 #include <WebCore/HysteresisActivity.h>
5352#include <WebCore/IntRect.h>
5453#include <WebCore/IntSizeHash.h>
5554#include <WebCore/Page.h>

6160#include <WebCore/UserScriptTypes.h>
6261#include <WebCore/WebCoreKeyboardUIMode.h>
6362#include <memory>
 63#include <pal/HysteresisActivity.h>
6464#include <wtf/HashMap.h>
6565#include <wtf/MonotonicTime.h>
6666#include <wtf/RefPtr.h>

@@private:
14531453 RefPtr<SandboxExtension> m_pendingDropSandboxExtension;
14541454 Vector<RefPtr<SandboxExtension>> m_pendingDropExtensionsForFileUpload;
14551455
1456  WebCore::HysteresisActivity m_pageScrolledHysteresis;
 1456 PAL::HysteresisActivity m_pageScrolledHysteresis;
14571457
14581458 bool m_canRunBeforeUnloadConfirmPanel { false };
14591459

@@private:
15531553
15541554 bool m_processSuppressionEnabled;
15551555 UserActivity m_userActivity;
1556  WebCore::HysteresisActivity m_userActivityHysteresis;
 1556 PAL::HysteresisActivity m_userActivityHysteresis;
15571557
15581558 uint64_t m_pendingNavigationID { 0 };
15591559

Source/WebKit/WebProcess/WebProcess.cpp

@@WebProcess::WebProcess()
162162 , m_webInspectorInterruptDispatcher(WebInspectorInterruptDispatcher::create())
163163 , m_webLoaderStrategy(*new WebLoaderStrategy)
164164 , m_cacheStorageProvider(WebCacheStorageProvider::create())
165  , m_dnsPrefetchHystereris([this](HysteresisState state) { if (state == HysteresisState::Stopped) m_dnsPrefetchedHosts.clear(); })
 165 , m_dnsPrefetchHystereris([this](PAL::HysteresisState state) { if (state == PAL::HysteresisState::Stopped) m_dnsPrefetchedHosts.clear(); })
166166#if ENABLE(NETSCAPE_PLUGIN_API)
167167 , m_pluginProcessConnectionManager(PluginProcessConnectionManager::create())
168168#endif

Source/WebKit/WebProcess/WebProcess.h

3434#include "ViewUpdateDispatcher.h"
3535#include "WebInspectorInterruptDispatcher.h"
3636#include <WebCore/ActivityState.h>
37 #include <WebCore/HysteresisActivity.h>
3837#include <WebCore/Timer.h>
 38#include <pal/HysteresisActivity.h>
3939#include <pal/SessionID.h>
4040#include <wtf/Forward.h>
4141#include <wtf/HashMap.h>

@@private:
389389#endif
390390
391391 HashSet<String> m_dnsPrefetchedHosts;
392  WebCore::HysteresisActivity m_dnsPrefetchHystereris;
 392 PAL::HysteresisActivity m_dnsPrefetchHystereris;
393393
394394 std::unique_ptr<WebAutomationSessionProxy> m_automationSessionProxy;
395395