Changeset 219274 in webkit
- Timestamp:
- Jul 7, 2017 5:07:13 PM (7 years ago)
- Location:
- trunk/Source
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r219260 r219274 1 2017-07-07 Brent Fulgham <bfulgham@apple.com> 2 3 [WK2] Use a rolling 30-day uptime for processing statistics 4 https://bugs.webkit.org/show_bug.cgi?id=174235 5 <rdar://problem/33164381> 6 7 Reviewed by Chris Dumez. 8 9 Modify Deque to allow it to be used in a template specialization in KeyedDecoder. 10 11 * wtf/Deque.h: 12 1 13 2017-07-07 Commit Queue <commit-queue@webkit.org> 2 14 -
trunk/Source/WTF/wtf/Deque.h
r214636 r219274 47 47 WTF_MAKE_FAST_ALLOCATED; 48 48 public: 49 typedef T ValueType; 50 49 51 typedef DequeIterator<T, inlineCapacity> iterator; 50 52 typedef DequeConstIterator<T, inlineCapacity> const_iterator; -
trunk/Source/WebCore/ChangeLog
r219272 r219274 1 2017-07-07 Brent Fulgham <bfulgham@apple.com> 2 3 [WK2] Use a rolling 30-day uptime for processing statistics 4 https://bugs.webkit.org/show_bug.cgi?id=174235 5 <rdar://problem/33164381> 6 7 Reviewed by Chris Dumez. 8 9 Add a KeyedDecoder specialization for Deque. 10 11 * platform/KeyedCoding.h: 12 (WebCore::KeyedDecoder::decodeObjects): 13 1 14 2017-07-07 Daniel Bates <dabates@apple.com> 2 15 -
trunk/Source/WebCore/platform/KeyedCoding.h
r210758 r219274 1 1 /* 2 * Copyright (C) 2013 Apple Inc. All rights reserved.2 * Copyright (C) 2013-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 27 27 28 28 #include <functional> 29 #include <wtf/Deque.h> 29 30 #include <wtf/Forward.h> 30 31 #include <wtf/Vector.h> … … 105 106 } 106 107 107 template<typename T, typename F>108 bool decodeObjects(const String& key, Vector<T>& objects, F&& function)108 template<typename ContainerType, typename F> 109 bool decodeObjects(const String& key, ContainerType& objects, F&& function) 109 110 { 110 111 if (!beginArray(key)) … … 113 114 bool result = true; 114 115 while (beginArrayElement()) { 115 Telement;116 typename ContainerType::ValueType element; 116 117 if (!function(*this, element)) { 117 118 result = false; -
trunk/Source/WebKit2/ChangeLog
r219271 r219274 1 2017-07-07 Brent Fulgham <bfulgham@apple.com> 2 3 [WK2] Use a rolling 30-day uptime for processing statistics 4 https://bugs.webkit.org/show_bug.cgi?id=174235 5 <rdar://problem/33164381> 6 7 Reviewed by Chris Dumez. 8 9 * UIProcess/API/Cocoa/WKWebsiteDataStore.cpp: 10 (WebKit::WKWebsiteDataStore::_resourceLoadStatisticsResetToConsistentState): Initialize time-to-live to zero by default. 11 * UIProcess/Storage/ResourceLoadStatisticsStore.cpp: 12 (WebKit::ResourceLoadStatisticsStore::createEncoderFromData): Write out vector 13 of operating dates. 14 (WebKit::ResourceLoadStatisticsStore::readDataFromDecoder): Read in vector of 15 operating dates. 16 (WebKit::ResourceLoadStatisticsStore::hasHadRecentUserInteraction): Check new 17 convenience method. 18 (WebKit::ResourceLoadStatisticsStore::markTodayAsOperatingDate): Added. 19 (WebKit::ResourceLoadStatisticsStore::hasStatisticsExpired): Added. 20 * UIProcess/Storage/ResourceLoadStatisticsStore.h: 21 * UIProcess/WebResourceLoadStatisticsStore.cpp: 22 (WebKit::WebResourceLoadStatisticsStore::readDataFromDiskIfNeeded): When reading 23 a new data file, update the current operating date (if needed). 24 (WebKit::WebResourceLoadStatisticsStore::handleDailyTasks): Roll uptime dates as 25 needed, then handle telemetry. 26 * UIProcess/WebResourceLoadStatisticsStore.h: 27 1 28 2017-07-07 Wenson Hsieh <wenson_hsieh@apple.com> 2 29 -
trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebsiteDataStore.mm
r219071 r219274 1 1 /* 2 * Copyright (C) 2014 , 2016Apple Inc. All rights reserved.2 * Copyright (C) 2014-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 441 441 return; 442 442 443 store->setTimeToLiveUserInteraction( 24_h * 30.);443 store->setTimeToLiveUserInteraction(0_s); 444 444 store->setTimeToLiveCookiePartitionFree(24_h); 445 445 store->setMinimumTimeBetweenDataRecordsRemoval(1_h); -
trunk/Source/WebKit2/UIProcess/Storage/ResourceLoadStatisticsStore.cpp
r219242 r219274 40 40 using namespace WebCore; 41 41 42 const unsigned statisticsModelVersion { 5 }; 43 42 const unsigned statisticsModelVersion { 6 }; 43 const unsigned operatingDatesWindow { 30 }; 44 44 45 Ref<ResourceLoadStatisticsStore> ResourceLoadStatisticsStore::create() 45 46 { … … 90 91 }); 91 92 93 encoder->encodeObjects("operatingDates", m_operatingDates.begin(), m_operatingDates.end(), [](KeyedEncoder& encoderInner, WallTime date) { 94 encoderInner.encodeDouble("date", date.secondsSinceEpoch().value()); 95 }); 96 92 97 return encoder; 93 98 } … … 129 134 m_resourceStatisticsMap.set(statistics.highLevelDomain, WTFMove(statistics)); 130 135 } 136 137 succeeded = decoder.decodeObjects("operatingDates", m_operatingDates, [](KeyedDecoder& decoder, WallTime& wallTime) { 138 double value; 139 if (!decoder.decodeDouble("date", value)) 140 return false; 141 142 wallTime = WallTime::fromRawSeconds(value); 143 return true; 144 }); 145 146 if (!succeeded) 147 return; 131 148 132 149 fireShouldPartitionCookiesHandler({ }, prevalentResourceDomainsWithoutUserInteraction, true); … … 137 154 ASSERT(!RunLoop::isMain()); 138 155 m_resourceStatisticsMap.clear(); 139 156 m_operatingDates.clear(); 157 140 158 fireShouldPartitionCookiesHandler({ }, { }, true); 141 159 } … … 294 312 return false; 295 313 296 if ( WallTime::now() > resourceStatistic.mostRecentUserInteractionTime + m_timeToLiveUserInteraction) {314 if (hasStatisticsExpired(resourceStatistic)) { 297 315 // Drop privacy sensitive data because we no longer need it. 298 316 // Set timestamp to 0 so that statistics merge will know … … 404 422 m_dataRecordsRemovalPending = false; 405 423 } 406 407 } 424 425 void ResourceLoadStatisticsStore::includeTodayAsOperatingDateIfNecessary() 426 { 427 if (!m_operatingDates.isEmpty() && (WallTime::now() - m_operatingDates.last() < 24_h)) 428 return; 429 430 while (m_operatingDates.size() >= operatingDatesWindow) 431 m_operatingDates.removeFirst(); 432 433 m_operatingDates.append(WallTime::now()); 434 } 435 436 bool ResourceLoadStatisticsStore::hasStatisticsExpired(const ResourceLoadStatistics& resourceStatistic) const 437 { 438 if (m_operatingDates.size() >= operatingDatesWindow) { 439 if (resourceStatistic.mostRecentUserInteractionTime < m_operatingDates.first()) 440 return true; 441 } 442 443 // If we don't meet the real criteria for an expired statistic, check the user 444 // setting for a tighter restriction (mainly for testing). 445 if (m_timeToLiveUserInteraction) { 446 if (WallTime::now() > resourceStatistic.mostRecentUserInteractionTime + m_timeToLiveUserInteraction) 447 return true; 448 } 449 450 return false; 451 } 452 453 } -
trunk/Source/WebKit2/UIProcess/Storage/ResourceLoadStatisticsStore.h
r219260 r219274 26 26 #pragma once 27 27 28 #include <wtf/Deque.h> 28 29 #include <wtf/Function.h> 29 30 #include <wtf/HashMap.h> … … 100 101 void dataRecordsWereRemoved(); 101 102 103 void includeTodayAsOperatingDateIfNecessary(); 104 102 105 private: 103 106 ResourceLoadStatisticsStore() = default; 104 107 105 108 bool shouldPartitionCookies(const WebCore::ResourceLoadStatistics&) const; 109 bool hasStatisticsExpired(const WebCore::ResourceLoadStatistics&) const; 106 110 107 111 HashMap<String, WebCore::ResourceLoadStatistics> m_resourceStatisticsMap; 112 Deque<WTF::WallTime> m_operatingDates; 108 113 109 114 WTF::Function<void()> m_dataAddedHandler; … … 113 118 WTF::Function<void()> m_fireTelemetryHandler; 114 119 115 Seconds m_timeToLiveUserInteraction { 24_h * 30.};120 Seconds m_timeToLiveUserInteraction { 0_s }; 116 121 Seconds m_timeToLiveCookiePartitionFree { 24_h }; 117 122 Seconds m_grandfatheringTime { 1_h }; -
trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.cpp
r219220 r219274 95 95 , m_statisticsQueue(WorkQueue::create("WebResourceLoadStatisticsStore Process Data Queue", WorkQueue::Type::Serial, WorkQueue::QOS::Utility)) 96 96 , m_statisticsStoragePath(resourceLoadStatisticsDirectory) 97 , m_telemetryOneShotTimer(RunLoop::main(), this, &WebResourceLoadStatisticsStore:: telemetryTimerFired)98 , m_telemetryRepeatedTimer(RunLoop::main(), this, &WebResourceLoadStatisticsStore:: telemetryTimerFired)97 , m_telemetryOneShotTimer(RunLoop::main(), this, &WebResourceLoadStatisticsStore::submitTelemetryIfNecessary) 98 , m_telemetryRepeatedTimer(RunLoop::main(), this, &WebResourceLoadStatisticsStore::performDailyTasks) 99 99 { 100 100 ASSERT(RunLoop::isMain()); … … 273 273 if (coreStore().isEmpty()) 274 274 grandfatherExistingWebsiteData(); 275 276 coreStore().includeTodayAsOperatingDateIfNecessary(); 275 277 } 276 278 … … 527 529 } 528 530 529 void WebResourceLoadStatisticsStore::telemetryTimerFired() 531 void WebResourceLoadStatisticsStore::performDailyTasks() 532 { 533 ASSERT(RunLoop::isMain()); 534 535 coreStore().includeTodayAsOperatingDateIfNecessary(); 536 537 submitTelemetryIfNecessary(); 538 } 539 540 void WebResourceLoadStatisticsStore::submitTelemetryIfNecessary() 530 541 { 531 542 ASSERT(RunLoop::isMain()); -
trunk/Source/WebKit2/UIProcess/WebResourceLoadStatisticsStore.h
r219220 r219274 133 133 void syncWithExistingStatisticsStorageIfNeeded(); 134 134 void refreshFromDisk(); 135 void telemetryTimerFired();135 void submitTelemetryIfNecessary(); 136 136 void submitTelemetry(); 137 137 bool hasStatisticsFileChangedSinceLastSync(const String& path); 138 void performDailyTasks(); 138 139 139 140 #if PLATFORM(COCOA)
Note: See TracChangeset
for help on using the changeset viewer.