Changeset 202198 in webkit


Ignore:
Timestamp:
Jun 18, 2016, 4:46:16 AM (9 years ago)
Author:
Antti Koivisto
Message:

Use time literals in WebCore
https://bugs.webkit.org/show_bug.cgi?id=158905

Reviewed by Andreas Kling.

std::chrono::milliseconds(1) -> 1ms etc.

  • dom/Document.cpp:

(WebCore::Document::minimumLayoutDelay):
(WebCore::Document::elapsedTime):

  • fileapi/FileReader.cpp:

(WebCore::FileReader::create):

  • inspector/InspectorOverlay.cpp:

(WebCore::InspectorOverlay::showPaintRect):

  • loader/CrossOriginPreflightResultCache.cpp:

(WebCore::CrossOriginPreflightResultCache::CrossOriginPreflightResultCache):

  • loader/ProgressTracker.cpp:

(WebCore::ProgressTracker::progressStarted):

  • loader/cache/CachedResource.cpp:

(WebCore::CachedResource::freshnessLifetime):

  • page/ChromeClient.h:
  • page/DOMTimer.cpp:

(WebCore::DOMTimer::intervalClampedToMinimum):
(WebCore::DOMTimer::alignedFireTime):

  • page/DOMTimer.h:
  • page/FrameView.cpp:

(WebCore::FrameView::scrollPositionChanged):

  • page/ResourceUsageThread.cpp:

(WebCore::ResourceUsageThread::threadBody):

  • page/Settings.cpp:

(WebCore::Settings::Settings):

  • page/mac/ServicesOverlayController.mm:

(WebCore::ServicesOverlayController::remainingTimeUntilHighlightShouldBeShown):

  • platform/graphics/FontCache.cpp:

(WebCore::FontCache::fontForFamily):

  • platform/network/CacheValidation.cpp:

(WebCore::computeCurrentAge):
(WebCore::computeFreshnessLifetimeForHTTPFamily):

Location:
trunk/Source/WebCore
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r202197 r202198  
     12016-06-18  Antti Koivisto  <antti@apple.com>
     2
     3        Use time literals in WebCore
     4        https://bugs.webkit.org/show_bug.cgi?id=158905
     5
     6        Reviewed by Andreas Kling.
     7
     8        std::chrono::milliseconds(1) -> 1ms etc.
     9
     10        * dom/Document.cpp:
     11        (WebCore::Document::minimumLayoutDelay):
     12        (WebCore::Document::elapsedTime):
     13        * fileapi/FileReader.cpp:
     14        (WebCore::FileReader::create):
     15        * inspector/InspectorOverlay.cpp:
     16        (WebCore::InspectorOverlay::showPaintRect):
     17        * loader/CrossOriginPreflightResultCache.cpp:
     18        (WebCore::CrossOriginPreflightResultCache::CrossOriginPreflightResultCache):
     19        * loader/ProgressTracker.cpp:
     20        (WebCore::ProgressTracker::progressStarted):
     21        * loader/cache/CachedResource.cpp:
     22        (WebCore::CachedResource::freshnessLifetime):
     23        * page/ChromeClient.h:
     24        * page/DOMTimer.cpp:
     25        (WebCore::DOMTimer::intervalClampedToMinimum):
     26        (WebCore::DOMTimer::alignedFireTime):
     27        * page/DOMTimer.h:
     28        * page/FrameView.cpp:
     29        (WebCore::FrameView::scrollPositionChanged):
     30        * page/ResourceUsageThread.cpp:
     31        (WebCore::ResourceUsageThread::threadBody):
     32        * page/Settings.cpp:
     33        (WebCore::Settings::Settings):
     34        * page/mac/ServicesOverlayController.mm:
     35        (WebCore::ServicesOverlayController::remainingTimeUntilHighlightShouldBeShown):
     36        * platform/graphics/FontCache.cpp:
     37        (WebCore::FontCache::fontForFamily):
     38        * platform/network/CacheValidation.cpp:
     39        (WebCore::computeCurrentAge):
     40        (WebCore::computeFreshnessLifetimeForHTTPFamily):
     41
    1422016-06-17  Benjamin Poulain  <benjamin@webkit.org>
    243
  • trunk/Source/WebCore/dom/Document.cpp

    r202183 r202198  
    28502850{
    28512851    if (m_overMinimumLayoutThreshold)
    2852         return std::chrono::milliseconds(0);
     2852        return 0ms;
    28532853   
    2854     std::chrono::milliseconds elapsed = elapsedTime();
     2854    auto elapsed = elapsedTime();
    28552855    m_overMinimumLayoutThreshold = elapsed > settings()->layoutInterval();
    28562856
    28572857    // We'll want to schedule the timer to fire at the minimum layout threshold.
    2858     return std::max(std::chrono::milliseconds(0), settings()->layoutInterval() - elapsed);
     2858    return std::max(0ms, settings()->layoutInterval() - elapsed);
    28592859}
    28602860
  • trunk/Source/WebCore/fileapi/FileReader.cpp

    r202105 r202198  
    4444namespace WebCore {
    4545
    46 static const auto progressNotificationInterval = std::chrono::milliseconds(50);
     46static const auto progressNotificationInterval = 50ms;
    4747
    4848Ref<FileReader> FileReader::create(ScriptExecutionContext& context)
  • trunk/Source/WebCore/inspector/InspectorOverlay.cpp

    r202005 r202198  
    506506    IntRect rootRect = m_page.mainFrame().view()->contentsToRootView(enclosingIntRect(rect));
    507507
    508     const std::chrono::milliseconds removeDelay = std::chrono::milliseconds(250);
     508    const auto removeDelay = 250ms;
    509509
    510510    std::chrono::steady_clock::time_point removeTime = std::chrono::steady_clock::now() + removeDelay;
  • trunk/Source/WebCore/loader/CrossOriginPreflightResultCache.cpp

    r194496 r202198  
    3838
    3939// These values are at the discretion of the user agent.
    40 static const auto defaultPreflightCacheTimeout = std::chrono::seconds(5);
    41 static const auto maxPreflightCacheTimeout = std::chrono::seconds(600); // Should be short enough to minimize the risk of using a poisoned cache after switching to a secure network.
     40static const auto defaultPreflightCacheTimeout = 5s;
     41static const auto maxPreflightCacheTimeout = 600s; // Should be short enough to minimize the risk of using a poisoned cache after switching to a secure network.
    4242
    4343CrossOriginPreflightResultCache::CrossOriginPreflightResultCache()
  • trunk/Source/WebCore/loader/ProgressTracker.cpp

    r186279 r202198  
    6161static const unsigned minumumBytesPerHeartbeatForProgress = 1024;
    6262
    63 static const std::chrono::milliseconds progressNotificationTimeInterval = std::chrono::milliseconds(200);
     63static const auto progressNotificationTimeInterval = 200ms;
    6464
    6565struct ProgressItem {
     
    138138        auto elapsedTimeSinceMainLoadComplete = std::chrono::steady_clock::now() - m_mainLoadCompletionTime;
    139139
    140         static const auto subframePartOfMainLoadThreshold = std::chrono::seconds(1);
     140        static const auto subframePartOfMainLoadThreshold = 1s;
    141141        m_isMainLoad = isMainFrame || elapsedTimeSinceMainLoadComplete < subframePartOfMainLoadThreshold;
    142142
  • trunk/Source/WebCore/loader/cache/CachedResource.cpp

    r202005 r202198  
    393393            // it caused performance and flakiness issues in our test infrastructure.
    394394            if (m_type == MainResource || SchemeRegistry::shouldAlwaysRevalidateURLScheme(protocol))
    395                 return std::chrono::microseconds::zero();
     395                return 0us;
    396396        }
    397397
  • trunk/Source/WebCore/page/ChromeClient.h

    r199593 r202198  
    240240#endif
    241241
    242     virtual std::chrono::milliseconds eventThrottlingDelay() { return std::chrono::milliseconds::zero(); };
     242    virtual std::chrono::milliseconds eventThrottlingDelay() { return 0ms; };
    243243
    244244#if PLATFORM(IOS)
  • trunk/Source/WebCore/page/DOMTimer.cpp

    r198079 r202198  
    5353namespace WebCore {
    5454
    55 static const std::chrono::milliseconds maxIntervalForUserGestureForwarding = std::chrono::milliseconds(1000); // One second matches Gecko.
    56 static const std::chrono::milliseconds minIntervalForNonUserObservableChangeTimers = std::chrono::milliseconds(1000); // Empirically determined to maximize battery life.
     55static const auto maxIntervalForUserGestureForwarding = 1000ms; // One second matches Gecko.
     56static const auto minIntervalForNonUserObservableChangeTimers = 1000ms; // Empirically determined to maximize battery life.
    5757static const int maxTimerNestingLevel = 5;
    5858
     
    407407    ASSERT(m_nestingLevel <= maxTimerNestingLevel);
    408408
    409     auto interval = std::max(std::chrono::milliseconds(1), m_originalInterval);
     409    auto interval = std::max(1ms, m_originalInterval);
    410410
    411411    // Only apply throttling to repeating timers.
     
    423423{
    424424    auto alignmentInterval = scriptExecutionContext()->timerAlignmentInterval(m_nestingLevel >= maxTimerNestingLevel);
    425     if (alignmentInterval == std::chrono::milliseconds::zero())
     425    if (alignmentInterval == 0ms)
    426426        return Nullopt;
    427427   
  • trunk/Source/WebCore/page/DOMTimer.h

    r197690 r202198  
    4747    virtual ~DOMTimer();
    4848
    49     static std::chrono::milliseconds defaultMinimumInterval() { return std::chrono::milliseconds(4); }
    50     static std::chrono::milliseconds defaultAlignmentInterval() { return std::chrono::milliseconds::zero(); }
    51     static std::chrono::milliseconds hiddenPageAlignmentInterval() { return std::chrono::milliseconds(1000); }
     49    static std::chrono::milliseconds defaultMinimumInterval() { return 4ms; }
     50    static std::chrono::milliseconds defaultAlignmentInterval() { return 0ms; }
     51    static std::chrono::milliseconds hiddenPageAlignmentInterval() { return 1000ms; }
    5252
    5353    // Creates a new timer owned by specified ScriptExecutionContext, starts it
  • trunk/Source/WebCore/page/FrameView.cpp

    r202105 r202198  
    22232223{
    22242224    Page* page = frame().page();
    2225     auto throttlingDelay = page ? page->chrome().client().eventThrottlingDelay() : std::chrono::milliseconds::zero();
    2226 
    2227     if (throttlingDelay == std::chrono::milliseconds::zero()) {
     2225    auto throttlingDelay = page ? page->chrome().client().eventThrottlingDelay() : 0ms;
     2226
     2227    if (throttlingDelay == 0ms) {
    22282228        m_delayedScrollEventTimer.stop();
    22292229        sendScrollEvent();
  • trunk/Source/WebCore/page/ResourceUsageThread.cpp

    r201482 r202198  
    120120        notifyObservers(WTFMove(data));
    121121
    122         auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - start);
    123         auto difference = std::chrono::milliseconds(500) - duration;
     122        auto duration = std::chrono::system_clock::now() - start;
     123        auto difference = 500ms - duration;
    124124        std::this_thread::sleep_for(difference);
    125125    }
  • trunk/Source/WebCore/page/Settings.cpp

    r202018 r202198  
    176176// FIXME: For faster machines this value can really be lowered to 200. 250 is adequate, but a little high
    177177// for dual G5s. :)
    178 static const auto layoutScheduleThreshold = std::chrono::milliseconds(250);
     178static const auto layoutScheduleThreshold = 250ms;
    179179
    180180Settings::Settings(Page* page)
  • trunk/Source/WebCore/page/mac/ServicesOverlayController.mm

    r201255 r202198  
    437437{
    438438    if (!highlight)
    439         return std::chrono::milliseconds::zero();
     439        return 0ms;
    440440
    441441    auto minimumTimeUntilHighlightShouldBeShown = 200ms;
  • trunk/Source/WebCore/platform/graphics/FontCache.cpp

    r201982 r202198  
    328328{
    329329    if (!m_purgeTimer.isActive())
    330         m_purgeTimer.startOneShot(std::chrono::milliseconds::zero());
     330        m_purgeTimer.startOneShot(0ms);
    331331
    332332    FontPlatformData* platformData = getCachedFontPlatformData(fontDescription, family, fontFaceFeatures, fontFaceVariantSettings, checkingAlternateName);
  • trunk/Source/WebCore/platform/network/CacheValidation.cpp

    r202188 r202198  
    104104    // No compensation for latency as that is not terribly important in practice.
    105105    auto dateValue = response.date();
    106     auto apparentAge = dateValue ? std::max(microseconds::zero(), duration_cast<microseconds>(responseTime - dateValue.value())) : microseconds::zero();
    107     auto ageValue = response.age().valueOr(microseconds::zero());
     106    auto apparentAge = dateValue ? std::max(0us, duration_cast<microseconds>(responseTime - *dateValue)) : 0us;
     107    auto ageValue = response.age().valueOr(0us);
    108108    auto correctedInitialAge = std::max(apparentAge, ageValue);
    109109    auto residentTime = duration_cast<microseconds>(system_clock::now() - responseTime);
     
    120120    auto maxAge = response.cacheControlMaxAge();
    121121    if (maxAge)
    122         return maxAge.value();
    123     auto expires = response.expires();
     122        return *maxAge;
     123
    124124    auto date = response.date();
    125     auto dateValue = date ? date.value() : responseTime;
    126     if (expires)
    127         return duration_cast<microseconds>(expires.value() - dateValue);
     125    auto effectiveDate = date.valueOr(responseTime);
     126    if (auto expires = response.expires())
     127        return duration_cast<microseconds>(*expires - effectiveDate);
    128128
    129129    // Implicit lifetime.
     
    132132    case 410: // Gone
    133133        // These are semantically permanent and so get long implicit lifetime.
    134         return hours(365 * 24);
     134        return 365 * 24h;
    135135    default:
    136136        // Heuristic Freshness:
    137137        // http://tools.ietf.org/html/rfc7234#section-4.2.2
    138         auto lastModified = response.lastModified();
    139         if (lastModified)
    140             return duration_cast<microseconds>((dateValue - lastModified.value()) * 0.1);
    141         return microseconds::zero();
     138        if (auto lastModified = response.lastModified())
     139            return duration_cast<microseconds>((effectiveDate - *lastModified) * 0.1);
     140        return 0us;
    142141    }
    143142}
Note: See TracChangeset for help on using the changeset viewer.