Get <chrono> out of StdLibExtras.h
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 31 May 2017 15:27:12 +0000 (15:27 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 31 May 2017 15:27:12 +0000 (15:27 +0000)
https://bugs.webkit.org/show_bug.cgi?id=172744

Reviewed by Saam Barati.

Source/WebCore:

Only bring in <chrono> and namespace std::literals::chrono_literals when necessary.

* fileapi/FileReader.cpp:
* inspector/InspectorOverlay.cpp:
* loader/CrossOriginPreflightResultCache.cpp:
* loader/cache/CachedResource.cpp:
(WebCore::CachedResource::freshnessLifetime):
* page/ResourceUsageThread.cpp:
(WebCore::ResourceUsageThread::threadBody):
* page/cocoa/MemoryReleaseCocoa.mm:
(WebCore::jettisonExpensiveObjectsOnTopLevelNavigation):
* platform/network/CacheValidation.cpp:
(WebCore::computeFreshnessLifetimeForHTTPFamily):
* platform/network/CacheValidation.h:

Source/WebKit2:

Only bring in <chrono> and namespace std::literals::chrono_literals when necessary.

* NetworkProcess/cache/NetworkCache.cpp:
* NetworkProcess/cache/NetworkCacheFileSystem.h:
* NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp:
* NetworkProcess/cache/NetworkCacheStorage.cpp:
(WebKit::NetworkCache::computeRecordWorth):
* Shared/mac/RemoteLayerBackingStoreCollection.mm:
* WebProcess/Cookies/WebCookieManager.h:

Source/WTF:

We hates std::chrono. Don't include it everywhere to discourage use.

* wtf/StdLibExtras.h:

Tools:

* TestWebKitAPI/Tests/WTF/WorkQueue.cpp:

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

20 files changed:
Source/WTF/ChangeLog
Source/WTF/wtf/StdLibExtras.h
Source/WebCore/ChangeLog
Source/WebCore/fileapi/FileReader.cpp
Source/WebCore/inspector/InspectorOverlay.cpp
Source/WebCore/loader/CrossOriginPreflightResultCache.cpp
Source/WebCore/loader/cache/CachedResource.cpp
Source/WebCore/page/ResourceUsageThread.cpp
Source/WebCore/page/cocoa/MemoryReleaseCocoa.mm
Source/WebCore/platform/network/CacheValidation.cpp
Source/WebCore/platform/network/CacheValidation.h
Source/WebKit2/ChangeLog
Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp
Source/WebKit2/NetworkProcess/cache/NetworkCacheFileSystem.h
Source/WebKit2/NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp
Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp
Source/WebKit2/Shared/mac/RemoteLayerBackingStoreCollection.mm
Source/WebKit2/WebProcess/Cookies/WebCookieManager.h
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WTF/WorkQueue.cpp

index aa7ee74..dc28125 100644 (file)
@@ -1,3 +1,14 @@
+2017-05-31  Simon Fraser  <simon.fraser@apple.com>
+
+        Get <chrono> out of StdLibExtras.h
+        https://bugs.webkit.org/show_bug.cgi?id=172744
+
+        Reviewed by Saam Barati.
+
+        We hates std::chrono. Don't include it everywhere to discourage use.
+
+        * wtf/StdLibExtras.h:
+
 2017-05-30  Ryosuke Niwa  <rniwa@webkit.org>
 
         Only include DataDetectorsUI headers in iOS
index 997cd35..1cb03e5 100644 (file)
@@ -27,7 +27,6 @@
 #ifndef WTF_StdLibExtras_h
 #define WTF_StdLibExtras_h
 
-#include <chrono>
 #include <cstring>
 #include <memory>
 #include <type_traits>
@@ -543,9 +542,4 @@ using WTF::roundUpToMultipleOf;
 using WTF::safeCast;
 using WTF::tryBinarySearch;
 
-#if !COMPILER(CLANG) || __cplusplus >= 201400L
-// We normally don't want to bring in entire std namespaces, but literals are an exception.
-using namespace std::literals::chrono_literals;
-#endif
-
 #endif // WTF_StdLibExtras_h
index d0c80a7..b375f60 100644 (file)
@@ -1,3 +1,25 @@
+2017-05-31  Simon Fraser  <simon.fraser@apple.com>
+
+        Get <chrono> out of StdLibExtras.h
+        https://bugs.webkit.org/show_bug.cgi?id=172744
+
+        Reviewed by Saam Barati.
+
+        Only bring in <chrono> and namespace std::literals::chrono_literals when necessary.
+
+        * fileapi/FileReader.cpp:
+        * inspector/InspectorOverlay.cpp:
+        * loader/CrossOriginPreflightResultCache.cpp:
+        * loader/cache/CachedResource.cpp:
+        (WebCore::CachedResource::freshnessLifetime):
+        * page/ResourceUsageThread.cpp:
+        (WebCore::ResourceUsageThread::threadBody):
+        * page/cocoa/MemoryReleaseCocoa.mm:
+        (WebCore::jettisonExpensiveObjectsOnTopLevelNavigation):
+        * platform/network/CacheValidation.cpp:
+        (WebCore::computeFreshnessLifetimeForHTTPFamily):
+        * platform/network/CacheValidation.h:
+
 2017-05-31  Emilio Cobos Ãlvarez  <ecobos@igalia.com>
 
         Use the rare data's RenderStyle for display: contents.
index ea46dd9..4d15be1 100644 (file)
@@ -43,6 +43,8 @@
 
 namespace WebCore {
 
+using namespace std::literals::chrono_literals;
+
 // Fire the progress event at least every 50ms.
 static const auto progressNotificationInterval = 50ms;
 
index ea6e784..66c7f08 100644 (file)
@@ -63,6 +63,7 @@
 #include <inspector/InspectorValues.h>
 
 using namespace Inspector;
+using namespace std::literals::chrono_literals;
 
 namespace WebCore {
 
index 47cf736..c7da85e 100644 (file)
 #include "ResourceResponse.h"
 #include <wtf/MainThread.h>
 #include <wtf/NeverDestroyed.h>
-#include <wtf/StdLibExtras.h>
 
 namespace WebCore {
 
+using namespace std::literals::chrono_literals;
+
 // These values are at the discretion of the user agent.
 static const auto defaultPreflightCacheTimeout = 5s;
 static const auto maxPreflightCacheTimeout = 600s; // Should be short enough to minimize the risk of using a poisoned cache after switching to a secure network.
index fa5d677..f163b81 100644 (file)
@@ -395,6 +395,8 @@ static inline bool shouldCacheSchemeIndefinitely(StringView scheme)
 
 std::chrono::microseconds CachedResource::freshnessLifetime(const ResourceResponse& response) const
 {
+    using namespace std::literals::chrono_literals;
+
     if (!response.url().protocolIsInHTTPFamily()) {
         StringView protocol = response.url().protocol();
         if (!shouldCacheSchemeIndefinitely(protocol)) {
index d9b6f72..e0b2784 100644 (file)
@@ -110,6 +110,8 @@ void ResourceUsageThread::threadCallback(void* resourceUsageThread)
 
 NO_RETURN void ResourceUsageThread::threadBody()
 {
+    using namespace std::literals::chrono_literals;
+
     while (true) {
         // Only do work if we have observers.
         waitUntilObservers();
index 495b811..d7932ee 100644 (file)
@@ -66,6 +66,8 @@ void platformReleaseMemory(Critical)
 void jettisonExpensiveObjectsOnTopLevelNavigation()
 {
 #if PLATFORM(IOS)
+    using namespace std::literals::chrono_literals;
+
     // Protect against doing excessive jettisoning during repeated navigations.
     const auto minimumTimeSinceNavigation = 2s;
 
index e177a91..2f74c91 100644 (file)
@@ -38,6 +38,8 @@
 
 namespace WebCore {
 
+using namespace std::literals::chrono_literals;
+
 // These response headers are not copied from a revalidated response to the
 // cached response headers. For compatibility, this list is based on Chromium's
 // net/http/http_response_headers.cc.
@@ -113,6 +115,7 @@ std::chrono::microseconds computeCurrentAge(const ResourceResponse& response, st
 std::chrono::microseconds computeFreshnessLifetimeForHTTPFamily(const ResourceResponse& response, std::chrono::system_clock::time_point responseTime)
 {
     using namespace std::chrono;
+
     ASSERT(response.url().protocolIsInHTTPFamily());
 
     // Freshness Lifetime:
index bd03c51..443b231 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef CacheValidation_h
-#define CacheValidation_h
+#pragma once
 
 #include "PlatformExportMacros.h"
 #include "SessionID.h"
+#include <chrono>
 #include <wtf/Optional.h>
 #include <wtf/Vector.h>
 #include <wtf/text/WTFString.h>
@@ -77,5 +77,3 @@ WEBCORE_EXPORT bool isStatusCodeCacheableByDefault(int statusCode);
 WEBCORE_EXPORT bool isStatusCodePotentiallyCacheable(int statusCode);
 
 }
-
-#endif
index 21ee553..b44d12e 100644 (file)
@@ -1,3 +1,20 @@
+2017-05-31  Simon Fraser  <simon.fraser@apple.com>
+
+        Get <chrono> out of StdLibExtras.h
+        https://bugs.webkit.org/show_bug.cgi?id=172744
+
+        Reviewed by Saam Barati.
+
+        Only bring in <chrono> and namespace std::literals::chrono_literals when necessary.
+
+        * NetworkProcess/cache/NetworkCache.cpp:
+        * NetworkProcess/cache/NetworkCacheFileSystem.h:
+        * NetworkProcess/cache/NetworkCacheSpeculativeLoadManager.cpp:
+        * NetworkProcess/cache/NetworkCacheStorage.cpp:
+        (WebKit::NetworkCache::computeRecordWorth):
+        * Shared/mac/RemoteLayerBackingStoreCollection.mm:
+        * WebProcess/Cookies/WebCookieManager.h:
+
 2017-05-31  Zan Dobersek  <zdobersek@igalia.com>
 
         CoordinatedLayerTreeHost: properly support async force repaints
index 97dc902..9f1cd0a 100644 (file)
@@ -50,6 +50,8 @@
 #include <notify.h>
 #endif
 
+using namespace std::literals::chrono_literals;
+
 namespace WebKit {
 namespace NetworkCache {
 
index 22e716f..f7bbe5b 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef NetworkCacheFileSystem_h
-#define NetworkCacheFileSystem_h
+#pragma once
 
 #if ENABLE(NETWORK_CACHE)
 
 #include <WebCore/FileSystem.h>
+#include <chrono>
 #include <functional>
 
 namespace WebKit {
@@ -52,6 +52,3 @@ bool canUseSharedMemoryForPath(const String& path);
 }
 
 #endif 
-
-#endif
-
index 4bf5557..9ba1de1 100644 (file)
@@ -46,6 +46,7 @@ namespace WebKit {
 namespace NetworkCache {
 
 using namespace WebCore;
+using namespace std::literals::chrono_literals;
 
 static const Seconds preloadedEntryLifetime { 10_s };
 
index cbb457b..e1c37ee 100644 (file)
@@ -934,6 +934,8 @@ void Storage::clear(const String& type, std::chrono::system_clock::time_point mo
 static double computeRecordWorth(FileTimes times)
 {
     using namespace std::chrono;
+    using namespace std::literals::chrono_literals;
+
     auto age = system_clock::now() - times.creation;
     // File modification time is updated manually on cache read. We don't use access time since OS may update it automatically.
     auto accessAge = times.modification - times.creation;
index 0f4dea2..654816f 100644 (file)
@@ -30,6 +30,8 @@
 #import "RemoteLayerBackingStore.h"
 #import "RemoteLayerTreeContext.h"
 
+using namespace std::literals::chrono_literals;
+
 const std::chrono::seconds volatileBackingStoreAgeThreshold = 1s;
 const std::chrono::milliseconds volatileSecondaryBackingStoreAgeThreshold = 200ms;
 const Seconds volatilityTimerInterval = 200_ms;
index 81875da..12ae591 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef WebCookieManager_h
-#define WebCookieManager_h
+#pragma once
 
 #include "HTTPCookieAcceptPolicy.h"
 #include "MessageReceiver.h"
 #include "NetworkProcessSupplement.h"
 #include "WebProcessSupplement.h"
 #include <WebCore/SessionID.h>
+#include <chrono>
 #include <stdint.h>
 #include <wtf/Forward.h>
 #include <wtf/Noncopyable.h>
@@ -91,5 +91,3 @@ private:
 };
 
 } // namespace WebKit
-
-#endif // WebCookieManager_h
index 9598966..9139f3c 100644 (file)
@@ -1,3 +1,12 @@
+2017-05-31  Simon Fraser  <simon.fraser@apple.com>
+
+        Get <chrono> out of StdLibExtras.h
+        https://bugs.webkit.org/show_bug.cgi?id=172744
+
+        Reviewed by Saam Barati.
+
+        * TestWebKitAPI/Tests/WTF/WorkQueue.cpp:
+
 2017-05-30  Tim Horton  <timothy_horton@apple.com>
 
         Keyboard autocorrections do not apply with an active selection (but keyboard acts like they did)
index c9a14ce..3158c36 100644 (file)
@@ -35,6 +35,8 @@
 
 namespace TestWebKitAPI {
 
+using namespace std::literals::chrono_literals;
+
 static const char* simpleTestLabel = "simpleTest";
 static const char* longTestLabel = "longTest";
 static const char* thirdTestLabel = "thirdTest";