Changeset 219207 in webkit
- Timestamp:
- Jul 6, 2017 11:28:40 AM (7 years ago)
- Location:
- trunk/Source
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r219205 r219207 1 2017-07-06 Chris Dumez <cdumez@apple.com> 2 3 Move ResourceLoadObserver notification throttling logic from WebProcess class to ResourceLoadObserver 4 https://bugs.webkit.org/show_bug.cgi?id=174194 5 6 Reviewed by Brent Fulgham. 7 8 Move ResourceLoadObserver notification throttling logic from WebProcess class to 9 ResourceLoadObserver. This makes more sense and decreases the complexity of the 10 WebProcess class. 11 12 * loader/ResourceLoadObserver.cpp: 13 (WebCore::ResourceLoadObserver::setNotificationCallback): 14 (WebCore::ResourceLoadObserver::ResourceLoadObserver): 15 (WebCore::ResourceLoadObserver::logFrameNavigation): 16 (WebCore::ResourceLoadObserver::logSubresourceLoading): 17 (WebCore::ResourceLoadObserver::logWebSocketLoading): 18 (WebCore::ResourceLoadObserver::logUserInteractionWithReducedTimeResolution): 19 (WebCore::ResourceLoadObserver::scheduleNotificationIfNeeded): 20 (WebCore::ResourceLoadObserver::notificationTimerFired): 21 * loader/ResourceLoadObserver.h: 22 1 23 2017-07-06 Said Abou-Hallawa <sabouhallawa@apple.com> 2 24 -
trunk/Source/WebCore/loader/ResourceLoadObserver.cpp
r219010 r219207 38 38 #include "Settings.h" 39 39 #include "URL.h" 40 #include <wtf/NeverDestroyed.h>41 40 42 41 namespace WebCore { … … 48 47 49 48 static Seconds timestampResolution { 1_h }; 49 static const Seconds minimumNotificationInterval { 5_s }; 50 50 51 51 ResourceLoadObserver& ResourceLoadObserver::shared() … … 55 55 } 56 56 57 void ResourceLoadObserver::setNotificationCallback(WTF::Function<void ()>&& notificationCallback)57 void ResourceLoadObserver::setNotificationCallback(WTF::Function<void (Vector<ResourceLoadStatistics>&&)>&& notificationCallback) 58 58 { 59 59 ASSERT(!m_notificationCallback); 60 60 m_notificationCallback = WTFMove(notificationCallback); 61 } 62 63 ResourceLoadObserver::ResourceLoadObserver() 64 : m_notificationTimer(*this, &ResourceLoadObserver::notificationTimerFired) 65 { 61 66 } 62 67 … … 159 164 160 165 if (shouldCallNotificationCallback) 161 m_notificationCallback();166 scheduleNotificationIfNeeded(); 162 167 } 163 168 … … 225 230 226 231 if (shouldCallNotificationCallback) 227 m_notificationCallback();232 scheduleNotificationIfNeeded(); 228 233 } 229 234 … … 268 273 269 274 if (shouldCallNotificationCallback) 270 m_notificationCallback();275 scheduleNotificationIfNeeded(); 271 276 } 272 277 … … 295 300 statistics.mostRecentUserInteractionTime = newTime; 296 301 297 m_notificationCallback();302 scheduleNotificationIfNeeded(); 298 303 } 299 304 … … 323 328 } 324 329 330 void ResourceLoadObserver::scheduleNotificationIfNeeded() 331 { 332 ASSERT(m_notificationCallback); 333 if (m_resourceStatisticsMap.isEmpty()) { 334 m_notificationTimer.stop(); 335 return; 336 } 337 338 if (!m_notificationTimer.isActive()) 339 m_notificationTimer.startOneShot(minimumNotificationInterval); 340 } 341 342 void ResourceLoadObserver::notificationTimerFired() 343 { 344 ASSERT(m_notificationCallback); 345 m_notificationCallback(takeStatistics()); 346 } 347 325 348 String ResourceLoadObserver::statisticsForOrigin(const String& origin) 326 349 { -
trunk/Source/WebCore/loader/ResourceLoadObserver.h
r219005 r219207 26 26 #pragma once 27 27 28 #include "Timer.h" 28 29 #include <wtf/HashMap.h> 30 #include <wtf/NeverDestroyed.h> 29 31 #include <wtf/text/WTFString.h> 30 32 … … 46 48 47 49 class ResourceLoadObserver { 48 friend class NeverDestroyed<ResourceLoadObserver>;50 friend class WTF::NeverDestroyed<ResourceLoadObserver>; 49 51 public: 50 52 WEBCORE_EXPORT static ResourceLoadObserver& shared(); … … 57 59 WEBCORE_EXPORT String statisticsForOrigin(const String&); 58 60 59 WEBCORE_EXPORT void setNotificationCallback(WTF::Function<void()>&&); 60 WEBCORE_EXPORT Vector<ResourceLoadStatistics> takeStatistics(); 61 WEBCORE_EXPORT void setNotificationCallback(WTF::Function<void (Vector<ResourceLoadStatistics>&&)>&&); 61 62 62 63 private: 64 ResourceLoadObserver(); 65 63 66 bool shouldLog(Page*) const; 64 67 ResourceLoadStatistics& ensureResourceStatisticsForPrimaryDomain(const String&); … … 66 69 bool isPrevalentResource(const String& primaryDomain) const; 67 70 71 void scheduleNotificationIfNeeded(); 72 void notificationTimerFired(); 73 Vector<ResourceLoadStatistics> takeStatistics(); 74 68 75 HashMap<String, ResourceLoadStatistics> m_resourceStatisticsMap; 69 WTF::Function<void()> m_notificationCallback; 76 WTF::Function<void (Vector<ResourceLoadStatistics>&&)> m_notificationCallback; 77 Timer m_notificationTimer; 70 78 HashMap<String, size_t> m_originsVisitedMap; 71 79 }; -
trunk/Source/WebKit2/ChangeLog
r219203 r219207 1 2017-07-06 Chris Dumez <cdumez@apple.com> 2 3 Move ResourceLoadObserver notification throttling logic from WebProcess class to ResourceLoadObserver 4 https://bugs.webkit.org/show_bug.cgi?id=174194 5 6 Reviewed by Brent Fulgham. 7 8 Move ResourceLoadObserver notification throttling logic from WebProcess class to 9 ResourceLoadObserver. This makes more sense and decreases the complexity of the 10 WebProcess class. 11 12 * WebProcess/WebProcess.cpp: 13 (WebKit::m_webSQLiteDatabaseTracker): 14 (WebKit::WebProcess::statisticsChangedTimerFired): Deleted. 15 * WebProcess/WebProcess.h: 16 1 17 2017-07-06 Chris Dumez <cdumez@apple.com> 2 18 -
trunk/Source/WebKit2/WebProcess/WebProcess.cpp
r219005 r219207 171 171 #endif 172 172 , m_nonVisibleProcessCleanupTimer(*this, &WebProcess::nonVisibleProcessCleanupTimerFired) 173 , m_statisticsChangedTimer(*this, &WebProcess::statisticsChangedTimerFired)174 173 #if PLATFORM(IOS) 175 174 , m_webSQLiteDatabaseTracker(*this) … … 200 199 m_plugInAutoStartOriginHashes.add(SessionID::defaultSessionID(), HashMap<unsigned, double>()); 201 200 202 ResourceLoadObserver::shared().setNotificationCallback([this] { 203 if (m_statisticsChangedTimer.isActive()) 204 return; 205 m_statisticsChangedTimer.startOneShot(5_s); 201 ResourceLoadObserver::shared().setNotificationCallback([this] (Vector<ResourceLoadStatistics>&& statistics) { 202 ASSERT(!statistics.isEmpty()); 203 parentProcessConnection()->send(Messages::WebResourceLoadStatisticsStore::ResourceLoadStatisticsUpdated(WTFMove(statistics)), 0); 206 204 }); 207 205 } … … 1458 1456 } 1459 1457 1460 void WebProcess::statisticsChangedTimerFired()1461 {1462 auto statistics = ResourceLoadObserver::shared().takeStatistics();1463 if (statistics.isEmpty())1464 return;1465 1466 parentProcessConnection()->send(Messages::WebResourceLoadStatisticsStore::ResourceLoadStatisticsUpdated(WTFMove(statistics)), 0);1467 }1468 1469 1458 void WebProcess::setResourceLoadStatisticsEnabled(bool enabled) 1470 1459 { -
trunk/Source/WebKit2/WebProcess/WebProcess.h
r219005 r219207 185 185 186 186 void nonVisibleProcessCleanupTimerFired(); 187 void statisticsChangedTimerFired();188 187 189 188 #if PLATFORM(COCOA) … … 410 409 HashSet<uint64_t> m_pagesInWindows; 411 410 WebCore::Timer m_nonVisibleProcessCleanupTimer; 412 WebCore::Timer m_statisticsChangedTimer;413 411 414 412 RefPtr<WebCore::ApplicationCacheStorage> m_applicationCacheStorage;
Note: See TracChangeset
for help on using the changeset viewer.