Correct applicationWillTerminate logic for ResourceLoadStatistics
authorbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Apr 2016 01:31:13 +0000 (01:31 +0000)
committerbfulgham@apple.com <bfulgham@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 6 Apr 2016 01:31:13 +0000 (01:31 +0000)
https://bugs.webkit.org/show_bug.cgi?id=156249
<rdar://problem/25179611>

Reviewed by Andy Estes.

The applicationWillTerminate handling for ResourceLoadStatistics incorrectly
assumes that a ResourceLoadStatistics object will always be present.
1. The termination handling for 'dataStoresWithStorageManagers' should be
   calling 'applicationWillTerminate' on any ResourceLoadStatistics
   objects attached to the dataStore.
2. platformInitialize should null-check before attempting to dispatch.
3. platformDestroy should null check before attempting to dispatch.

* UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
(WebKit::WebsiteDataStore::platformInitialize):
(WebKit::WebsiteDataStore::platformDestroy): Invoke 'applicationWillTerminate' on
m_resourceLoadStatistics if present.

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

Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm

index 6003026..99d5d0b 100644 (file)
@@ -1,3 +1,24 @@
+2016-04-05  Brent Fulgham  <bfulgham@apple.com>
+
+        Correct applicationWillTerminate logic for ResourceLoadStatistics
+        https://bugs.webkit.org/show_bug.cgi?id=156249
+        <rdar://problem/25179611>
+
+        Reviewed by Andy Estes.
+
+        The applicationWillTerminate handling for ResourceLoadStatistics incorrectly
+        assumes that a ResourceLoadStatistics object will always be present.
+        1. The termination handling for 'dataStoresWithStorageManagers' should be
+           calling 'applicationWillTerminate' on any ResourceLoadStatistics
+           objects attached to the dataStore.
+        2. platformInitialize should null-check before attempting to dispatch.
+        3. platformDestroy should null check before attempting to dispatch.
+
+        * UIProcess/WebsiteData/Cocoa/WebsiteDataStoreCocoa.mm:
+        (WebKit::WebsiteDataStore::platformInitialize): 
+        (WebKit::WebsiteDataStore::platformDestroy): Invoke 'applicationWillTerminate' on
+        m_resourceLoadStatistics if present.
+
 2016-04-05  Youenn Fablet  <youenn.fablet@crf.canon.fr>
 
         [Fetch API] Add a runtime flag to fetch API and related constructs
index 867fdae..9c79881 100644 (file)
@@ -60,20 +60,25 @@ void WebsiteDataStore::platformInitialize()
         NSString *notificationName = UIApplicationWillTerminateNotification;
 #endif
         terminationObserver = [[NSNotificationCenter defaultCenter] addObserverForName:notificationName object:nil queue:nil usingBlock:^(NSNotification *note) {
-            for (auto& dataStore : dataStoresWithStorageManagers())
+            for (auto& dataStore : dataStoresWithStorageManagers()) {
                 dataStore->m_storageManager->applicationWillTerminate();
-
-            m_resourceLoadStatistics->applicationWillTerminate();
+                if (dataStore->m_resourceLoadStatistics)
+                    dataStore->m_resourceLoadStatistics->applicationWillTerminate();
+            }
         }];
     }
 
     ASSERT(!dataStoresWithStorageManagers().contains(this));
     dataStoresWithStorageManagers().append(this);
-    m_resourceLoadStatistics->readDataFromDiskIfNeeded();
+    if (m_resourceLoadStatistics)
+        m_resourceLoadStatistics->readDataFromDiskIfNeeded();
 }
 
 void WebsiteDataStore::platformDestroy()
 {
+    if (m_resourceLoadStatistics)
+        m_resourceLoadStatistics->applicationWillTerminate();
+
     if (!m_storageManager)
         return;