Changeset 215044 in webkit
- Timestamp:
- Apr 6, 2017 11:32:47 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r215043 r215044 1 2017-04-06 Antti Koivisto <antti@apple.com> 2 3 Implement testing mode for disk cache 4 https://bugs.webkit.org/show_bug.cgi?id=170547 5 6 Reviewed by Andreas Kling. 7 8 Enable a few disabled tests to see how it goes. 9 10 * platform/mac-wk2/TestExpectations: 11 1 12 2017-04-06 Romain Bellessort <romain.bellessort@crf.canon.fr> 2 13 -
trunk/LayoutTests/platform/mac-wk2/TestExpectations
r214913 r215044 309 309 webkit.org/b/151455 [ Release ] http/tests/xmlhttprequest/workers/methods-async.html [ Pass Timeout ] 310 310 311 webkit.org/b/162945 http/tests/cache/disk-cache/disk-cache-request-max-stale.html [ Pass Failure ]312 313 webkit.org/b/162946 http/tests/cache/disk-cache/disk-cache-media.html [ Pass Failure ]314 315 311 webkit.org/b/150542 fast/forms/state-restore-per-form.html [ Pass Timeout ] 316 312 -
trunk/Source/WebKit2/ChangeLog
r215040 r215044 1 2017-04-06 Antti Koivisto <antti@apple.com> 2 3 Implement testing mode for disk cache 4 https://bugs.webkit.org/show_bug.cgi?id=170547 5 6 Reviewed by Andreas Kling. 7 8 Disable read timeouts and cache shrinking in TestRunner to eliminate potential sources of randomness. 9 10 Cache directories are deleted by TestRunner so lack of shrinking does not consume the disk. 11 12 This is enabled by the existing WKContextUseTestingNetworkSession SPI. 13 14 * NetworkProcess/cache/NetworkCache.cpp: 15 (WebKit::NetworkCache::Cache::initialize): 16 * NetworkProcess/cache/NetworkCache.h: 17 * NetworkProcess/cache/NetworkCacheStorage.cpp: 18 (WebKit::NetworkCache::Storage::open): 19 (WebKit::NetworkCache::Storage::Storage): 20 (WebKit::NetworkCache::Storage::dispatchReadOperation): 21 (WebKit::NetworkCache::Storage::shrinkIfNeeded): 22 * NetworkProcess/cache/NetworkCacheStorage.h: 23 * NetworkProcess/cocoa/NetworkProcessCocoa.mm: 24 (WebKit::NetworkProcess::platformInitializeNetworkProcessCocoa): 25 1 26 2017-04-06 Chris Dumez <cdumez@apple.com> 2 27 -
trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.cpp
r212965 r215044 74 74 #endif 75 75 76 bool Cache::initialize(const String& cachePath, const Parameters& parameters)77 { 78 m_storage = Storage::open(cachePath );76 bool Cache::initialize(const String& cachePath, OptionSet<Option> options) 77 { 78 m_storage = Storage::open(cachePath, options.contains(Option::TestingMode) ? Storage::Mode::Testing : Storage::Mode::Normal); 79 79 80 80 #if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION) 81 if ( parameters.enableNetworkCacheSpeculativeRevalidation) {81 if (options.contains(Option::SpeculativeRevalidation)) { 82 82 m_lowPowerModeNotifier = std::make_unique<WebCore::LowPowerModeNotifier>([this](bool isLowPowerModeEnabled) { 83 83 ASSERT(WTF::isMainThread()); … … 94 94 #endif 95 95 96 if ( parameters.enableEfficacyLogging)96 if (options.contains(Option::EfficacyLogging)) 97 97 m_statistics = Statistics::open(cachePath); 98 98 -
trunk/Source/WebKit2/NetworkProcess/cache/NetworkCache.h
r212965 r215044 34 34 #include <WebCore/ResourceResponse.h> 35 35 #include <wtf/Function.h> 36 #include <wtf/OptionSet.h> 36 37 #include <wtf/text/WTFString.h> 37 38 … … 95 96 friend class WTF::NeverDestroyed<Cache>; 96 97 public: 97 struct Parameters { 98 bool enableEfficacyLogging; 98 enum class Option { 99 EfficacyLogging, 100 // In testing mode we try to eliminate sources of randomness. Cache does not shrink and there are no read timeouts. 101 TestingMode, 99 102 #if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION) 100 bool enableNetworkCacheSpeculativeRevalidation;103 SpeculativeRevalidation, 101 104 #endif 102 105 }; 103 bool initialize(const String& cachePath, const Parameters&);106 bool initialize(const String& cachePath, OptionSet<Option>); 104 107 void setCapacity(size_t); 105 108 -
trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.cpp
r214786 r215044 150 150 } 151 151 152 std::unique_ptr<Storage> Storage::open(const String& cachePath )152 std::unique_ptr<Storage> Storage::open(const String& cachePath, Mode mode) 153 153 { 154 154 ASSERT(RunLoop::isMain()); … … 159 159 if (!salt) 160 160 return nullptr; 161 return std::unique_ptr<Storage>(new Storage(cachePath, *salt));161 return std::unique_ptr<Storage>(new Storage(cachePath, mode, *salt)); 162 162 } 163 163 … … 208 208 } 209 209 210 Storage::Storage(const String& baseDirectoryPath, Salt salt)210 Storage::Storage(const String& baseDirectoryPath, Mode mode, Salt salt) 211 211 : m_basePath(baseDirectoryPath) 212 212 , m_recordsPath(makeRecordsDirectoryPath(baseDirectoryPath)) 213 , m_mode(mode) 213 214 , m_salt(salt) 214 215 , m_canUseSharedMemoryForBodyData(canUseSharedMemoryForPath(baseDirectoryPath)) … … 574 575 m_activeReadOperations.add(WTFMove(readOperationPtr)); 575 576 576 // I/O pressure may make disk operations slow. If they start taking very long time we rather go to network. 577 const auto readTimeout = 1500ms; 578 m_readOperationTimeoutTimer.startOneShot(readTimeout); 577 // Avoid randomness during testing. 578 if (m_mode != Mode::Testing) { 579 // I/O pressure may make disk operations slow. If they start taking very long time we rather go to network. 580 const auto readTimeout = 1500ms; 581 m_readOperationTimeoutTimer.startOneShot(readTimeout); 582 } 579 583 580 584 bool shouldGetBodyBlob = mayContainBlob(readOperation.key); … … 966 970 ASSERT(RunLoop::isMain()); 967 971 972 // Avoid randomness caused by cache shrinks. 973 if (m_mode == Mode::Testing) 974 return; 975 968 976 if (approximateSize() > m_capacity) 969 977 shrink(); -
trunk/Source/WebKit2/NetworkProcess/cache/NetworkCacheStorage.h
r214559 r215044 49 49 WTF_MAKE_NONCOPYABLE(Storage); 50 50 public: 51 static std::unique_ptr<Storage> open(const String& cachePath); 51 enum class Mode { Normal, Testing }; 52 static std::unique_ptr<Storage> open(const String& cachePath, Mode); 52 53 53 54 struct Record { … … 106 107 107 108 private: 108 Storage(const String& directoryPath, Salt);109 Storage(const String& directoryPath, Mode, Salt); 109 110 110 111 String recordDirectoryPathForKey(const Key&) const; … … 146 147 const String m_basePath; 147 148 const String m_recordsPath; 148 149 150 const Mode m_mode; 149 151 const Salt m_salt; 150 151 152 const bool m_canUseSharedMemoryForBodyData; 152 153 -
trunk/Source/WebKit2/NetworkProcess/cocoa/NetworkProcessCocoa.mm
r213747 r215044 113 113 #if ENABLE(NETWORK_CACHE) 114 114 if (parameters.shouldEnableNetworkCache) { 115 NetworkCache::Cache::Parameters cacheParameters = { 116 parameters.shouldEnableNetworkCacheEfficacyLogging 115 OptionSet<NetworkCache::Cache::Option> cacheOptions; 116 if (parameters.shouldEnableNetworkCacheEfficacyLogging) 117 cacheOptions |= NetworkCache::Cache::Option::EfficacyLogging; 118 if (parameters.shouldUseTestingNetworkSession) 119 cacheOptions |= NetworkCache::Cache::Option::TestingMode; 117 120 #if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION) 118 , parameters.shouldEnableNetworkCacheSpeculativeRevalidation119 #endif 120 }; 121 if (NetworkCache::singleton().initialize(m_diskCacheDirectory, cache Parameters)) {121 if (parameters.shouldEnableNetworkCacheSpeculativeRevalidation) 122 cacheOptions |= NetworkCache::Cache::Option::SpeculativeRevalidation; 123 #endif 124 if (NetworkCache::singleton().initialize(m_diskCacheDirectory, cacheOptions)) { 122 125 auto urlCache(adoptNS([[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil])); 123 126 [NSURLCache setSharedURLCache:urlCache.get()]; -
trunk/Source/WebKit2/NetworkProcess/soup/NetworkProcessSoup.cpp
r213877 r215044 113 113 SoupNetworkSession::clearOldSoupCache(WebCore::directoryName(m_diskCacheDirectory)); 114 114 115 NetworkCache::Cache::Parameters cacheParameters { 116 parameters.shouldEnableNetworkCacheEfficacyLogging 115 OptionSet<NetworkCache::Cache::Option> cacheOptions; 116 if (parameters.shouldEnableNetworkCacheEfficacyLogging) 117 cacheOptions |= NetworkCache::Cache::Option::EfficacyLogging; 117 118 #if ENABLE(NETWORK_CACHE_SPECULATIVE_REVALIDATION) 118 , parameters.shouldEnableNetworkCacheSpeculativeRevalidation 119 if (parameters.shouldEnableNetworkCacheSpeculativeRevalidation) 120 cacheOptions |= NetworkCache::Cache::Option::SpeculativeRevalidation; 119 121 #endif 120 }; 121 NetworkCache::singleton().initialize(m_diskCacheDirectory, cache Parameters);122 123 NetworkCache::singleton().initialize(m_diskCacheDirectory, cacheOptions); 122 124 123 125 if (!parameters.cookiePersistentStoragePath.isEmpty()) {
Note: See TracChangeset
for help on using the changeset viewer.