Some <chrono> and ProgressTracker cleanup
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 May 2017 16:54:18 +0000 (16:54 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 May 2017 16:54:18 +0000 (16:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=172582

Reviewed by Sam Weinig.

Remove some unnecessary <chrono> includes.
Convert some std::chrono to use MonotonicTime/Seconds.
Clean up ProgressTracker.
Some #pragma once.

* dom/Document.h:
* loader/ProgressTracker.cpp:
(WebCore::ProgressTracker::ProgressTracker):
(WebCore::ProgressTracker::reset):
(WebCore::ProgressTracker::progressStarted):
(WebCore::ProgressTracker::finalProgressComplete):
(WebCore::ProgressTracker::incrementProgress):
* loader/ProgressTracker.h:
* page/Settings.h:
* platform/SearchPopupMenu.h:
* platform/Timer.h:
* platform/graphics/cg/IOSurfacePool.cpp:
(WebCore::IOSurfacePool::markOlderSurfacesPurgeable):
* platform/graphics/cg/IOSurfacePool.h:
(WebCore::IOSurfacePool::CachedSurfaceDetails::resetLastUseTime):
* platform/network/PlatformCookieJar.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@217427 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/dom/Document.h
Source/WebCore/loader/ProgressTracker.cpp
Source/WebCore/loader/ProgressTracker.h
Source/WebCore/page/Settings.h
Source/WebCore/platform/SearchPopupMenu.h
Source/WebCore/platform/Timer.h
Source/WebCore/platform/graphics/cg/IOSurfacePool.cpp
Source/WebCore/platform/graphics/cg/IOSurfacePool.h
Source/WebCore/platform/network/PlatformCookieJar.h

index eea321a..fa8ad7b 100644 (file)
@@ -1,3 +1,32 @@
+2017-05-25  Simon Fraser  <simon.fraser@apple.com>
+
+        Some <chrono> and ProgressTracker cleanup
+        https://bugs.webkit.org/show_bug.cgi?id=172582
+
+        Reviewed by Sam Weinig.
+
+        Remove some unnecessary <chrono> includes.
+        Convert some std::chrono to use MonotonicTime/Seconds.
+        Clean up ProgressTracker.
+        Some #pragma once.
+
+        * dom/Document.h:
+        * loader/ProgressTracker.cpp:
+        (WebCore::ProgressTracker::ProgressTracker):
+        (WebCore::ProgressTracker::reset):
+        (WebCore::ProgressTracker::progressStarted):
+        (WebCore::ProgressTracker::finalProgressComplete):
+        (WebCore::ProgressTracker::incrementProgress):
+        * loader/ProgressTracker.h:
+        * page/Settings.h:
+        * platform/SearchPopupMenu.h:
+        * platform/Timer.h:
+        * platform/graphics/cg/IOSurfacePool.cpp:
+        (WebCore::IOSurfacePool::markOlderSurfacesPurgeable):
+        * platform/graphics/cg/IOSurfacePool.h:
+        (WebCore::IOSurfacePool::CachedSurfaceDetails::resetLastUseTime):
+        * platform/network/PlatformCookieJar.h:
+
 2017-05-25  Joanmarie Diggs  <jdiggs@igalia.com>
 
         [ATK] Expose doc-footnote ARIA role with ATK_ROLE_FOOTNOTE
index f8363bc..987aa42 100644 (file)
@@ -52,7 +52,6 @@
 #include "TreeScope.h"
 #include "UserActionElementSet.h"
 #include "ViewportArguments.h"
-#include <chrono>
 #include <memory>
 #include <wtf/Deque.h>
 #include <wtf/HashCountedSet.h>
index b196a59..5a297ed 100644 (file)
@@ -60,7 +60,7 @@ static const unsigned loadStalledHeartbeatCount = 4;
 // How many bytes are required between heartbeats to consider it progress.
 static const unsigned minumumBytesPerHeartbeatForProgress = 1024;
 
-static const auto progressNotificationTimeInterval = 200ms;
+static const Seconds progressNotificationTimeInterval { 200_ms };
 
 struct ProgressItem {
     WTF_MAKE_NONCOPYABLE(ProgressItem); WTF_MAKE_FAST_ALLOCATED;
@@ -79,16 +79,7 @@ unsigned long ProgressTracker::s_uniqueIdentifier = 0;
 
 ProgressTracker::ProgressTracker(ProgressTrackerClient& client)
     : m_client(client)
-    , m_totalPageAndResourceBytesToLoad(0)
-    , m_totalBytesReceived(0)
-    , m_lastNotifiedProgressValue(0)
-    , m_finalProgressChangedSent(false)
-    , m_progressValue(0)
-    , m_numProgressTrackedFrames(0)
     , m_progressHeartbeatTimer(*this, &ProgressTracker::progressHeartbeatTimerFired)
-    , m_heartbeatsWithNoProgress(0)
-    , m_totalBytesReceivedBeforePreviousHeartbeat(0)
-    , m_isMainLoad(false)
 {
 }
 
@@ -108,15 +99,17 @@ void ProgressTracker::reset()
 
     m_totalPageAndResourceBytesToLoad = 0;
     m_totalBytesReceived = 0;
-    m_progressValue = 0;
+    m_totalBytesReceivedBeforePreviousHeartbeat = 0;
+
     m_lastNotifiedProgressValue = 0;
-    m_lastNotifiedProgressTime = std::chrono::steady_clock::time_point();
+    m_progressValue = 0;
+
+    m_lastNotifiedProgressTime = MonotonicTime();
     m_finalProgressChangedSent = false;
     m_numProgressTrackedFrames = 0;
     m_originatingProgressFrame = nullptr;
 
     m_heartbeatsWithNoProgress = 0;
-    m_totalBytesReceivedBeforePreviousHeartbeat = 0;
     m_progressHeartbeatTimer.stop();
 }
 
@@ -135,9 +128,9 @@ void ProgressTracker::progressStarted(Frame& frame)
         m_originatingProgressFrame->loader().loadProgressingStatusChanged();
 
         bool isMainFrame = !m_originatingProgressFrame->tree().parent();
-        auto elapsedTimeSinceMainLoadComplete = std::chrono::steady_clock::now() - m_mainLoadCompletionTime;
+        auto elapsedTimeSinceMainLoadComplete = MonotonicTime::now() - m_mainLoadCompletionTime;
 
-        static const auto subframePartOfMainLoadThreshold = 1s;
+        static const auto subframePartOfMainLoadThreshold = 1_s;
         m_isMainLoad = isMainFrame || elapsedTimeSinceMainLoadComplete < subframePartOfMainLoadThreshold;
 
         m_client.progressStarted(*m_originatingProgressFrame);
@@ -180,7 +173,7 @@ void ProgressTracker::finalProgressComplete()
     reset();
 
     if (m_isMainLoad)
-        m_mainLoadCompletionTime = std::chrono::steady_clock::now();
+        m_mainLoadCompletionTime = MonotonicTime::now();
 
     frame->loader().client().setMainFrameDocumentReady(true);
     m_client.progressFinished(*frame);
@@ -253,7 +246,7 @@ void ProgressTracker::incrementProgress(unsigned long identifier, unsigned bytes
     
     m_totalBytesReceived += bytesReceived;
     
-    auto now = std::chrono::steady_clock::now();
+    auto now = MonotonicTime::now();
     auto notifiedProgressTimeDelta = now - m_lastNotifiedProgressTime;
     
     LOG(Progress, "Progress incremented (%p) - value %f, tracked frames %d", this, m_progressValue, m_numProgressTrackedFrames);
index 71739ae..1aa2dba 100644 (file)
@@ -26,7 +26,6 @@
 #pragma once
 
 #include "Timer.h"
-#include <chrono>
 #include <wtf/Forward.h>
 #include <wtf/HashMap.h>
 #include <wtf/Noncopyable.h>
@@ -70,22 +69,25 @@ private:
     static unsigned long s_uniqueIdentifier;
     
     ProgressTrackerClient& m_client;
-    long long m_totalPageAndResourceBytesToLoad;
-    long long m_totalBytesReceived;
-    double m_lastNotifiedProgressValue;
-    std::chrono::steady_clock::time_point m_lastNotifiedProgressTime;
-    bool m_finalProgressChangedSent;    
-    double m_progressValue;
     RefPtr<Frame> m_originatingProgressFrame;
-    
-    int m_numProgressTrackedFrames;
     HashMap<unsigned long, std::unique_ptr<ProgressItem>> m_progressItems;
-
     Timer m_progressHeartbeatTimer;
-    unsigned m_heartbeatsWithNoProgress;
-    long long m_totalBytesReceivedBeforePreviousHeartbeat;
-    std::chrono::steady_clock::time_point m_mainLoadCompletionTime;
-    bool m_isMainLoad;
+
+    long long m_totalPageAndResourceBytesToLoad { 0 };
+    long long m_totalBytesReceived { 0 };
+    long long m_totalBytesReceivedBeforePreviousHeartbeat { 0 };
+
+    double m_lastNotifiedProgressValue { 0 };
+    double m_progressValue { 0 };
+
+    MonotonicTime m_mainLoadCompletionTime;
+    MonotonicTime m_lastNotifiedProgressTime;
+
+    int m_numProgressTrackedFrames { 0 };
+    unsigned m_heartbeatsWithNoProgress { 0 };
+
+    bool m_finalProgressChangedSent { false };
+    bool m_isMainLoad { false };
 };
     
 } // namespace WebCore
index d196dc2..d95b6ae 100644 (file)
@@ -35,7 +35,6 @@
 #include "Timer.h"
 #include "URL.h"
 #include "WritingMode.h"
-#include <chrono>
 #include <runtime/RuntimeFlags.h>
 #include <unicode/uscript.h>
 #include <wtf/HashMap.h>
index 551a81c..3e955e5 100644 (file)
@@ -18,8 +18,7 @@
  *
  */
 
-#ifndef SearchPopupMenu_h
-#define SearchPopupMenu_h
+#pragma once
 
 #include <chrono>
 #include <wtf/Forward.h>
@@ -45,5 +44,3 @@ public:
 };
 
 }
-
-#endif // SearchPopupMenu_h
index 52deba8..4c774a4 100644 (file)
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef Timer_h
-#define Timer_h
+#pragma once
 
-#include <chrono>
 #include <functional>
 #include <wtf/MonotonicTime.h>
 #include <wtf/Noncopyable.h>
@@ -203,5 +201,3 @@ private:
 };
 
 }
-
-#endif
index 85c0b4d..e3f073e 100644 (file)
 
 #include "GraphicsContextCG.h"
 #include <CoreGraphics/CoreGraphics.h>
-#include <chrono>
 #include <wtf/NeverDestroyed.h>
 
 static const Seconds collectionInterval { 500_ms };
-const std::chrono::seconds surfaceAgeBeforeMarkingPurgeable = 2s;
+static const Seconds surfaceAgeBeforeMarkingPurgeable { 2_s };
 const size_t defaultMaximumBytesCached = 1024 * 1024 * 64;
 
 // We'll never allow more than 1/2 of the cache to be filled with in-use surfaces, because
@@ -288,7 +287,7 @@ void IOSurfacePool::collectInUseSurfaces()
 bool IOSurfacePool::markOlderSurfacesPurgeable()
 {
     bool markedAllSurfaces = true;
-    auto markTime = std::chrono::steady_clock::now();
+    auto markTime = MonotonicTime::now();
 
     for (auto& surfaceAndDetails : m_surfaceDetails) {
         if (surfaceAndDetails.value.hasMarkedPurgeable)
index 0ae320d..df4bec7 100644 (file)
@@ -23,8 +23,7 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef IOSurfacePool_h
-#define IOSurfacePool_h
+#pragma once
 
 #if USE(IOSURFACE)
 
@@ -61,9 +60,9 @@ private:
             : hasMarkedPurgeable(false)
         { }
 
-        void resetLastUseTime() { lastUseTime = std::chrono::steady_clock::now(); }
+        void resetLastUseTime() { lastUseTime = MonotonicTime::now(); }
 
-        std::chrono::steady_clock::time_point lastUseTime;
+        MonotonicTime lastUseTime;
         bool hasMarkedPurgeable;
     };
 
@@ -105,5 +104,3 @@ private:
 
 }
 #endif // USE(IOSURFACE)
-
-#endif // IOSurfacePool_h
index d082c8b..02d9831 100644 (file)
@@ -23,8 +23,7 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef PlatformCookieJar_h
-#define PlatformCookieJar_h
+#pragma once
 
 #include <chrono>
 #include <wtf/Forward.h>
@@ -52,5 +51,3 @@ WEBCORE_EXPORT void deleteAllCookies(const NetworkStorageSession&);
 WEBCORE_EXPORT void deleteAllCookiesModifiedSince(const NetworkStorageSession&, std::chrono::system_clock::time_point);
 
 }
-
-#endif