- Revision
- 233468
- Author
- [email protected]
- Date
- 2018-07-03 11:25:36 -0700 (Tue, 03 Jul 2018)
Log Message
Resource Load Statistics: Make WebsiteDataStore::getAllStorageAccessEntries() call the right network process instead of iterating over the process pools
https://bugs.webkit.org/show_bug.cgi?id=187277
<rdar://problem/41745510>
Reviewed by Chris Dumez.
Source/WebKit:
Existing tests use this code. The change is for correctness.
* UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
(-[WKWebsiteDataStore _getAllStorageAccessEntriesFor:completionHandler:]):
Now receives a WKWebView from its caller and gets the page ID from it.
(-[WKWebsiteDataStore _getAllStorageAccessEntries:]): Deleted.
* UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::getAllStorageAccessEntries):
Now gets a page ID from its caller and gets the right network process
through it.
* UIProcess/WebsiteData/WebsiteDataStore.h:
Tools:
* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::TestController::getAllStorageAccessEntries):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (233467 => 233468)
--- trunk/Source/WebKit/ChangeLog 2018-07-03 17:50:12 UTC (rev 233467)
+++ trunk/Source/WebKit/ChangeLog 2018-07-03 18:25:36 UTC (rev 233468)
@@ -1,3 +1,24 @@
+2018-07-03 John Wilander <[email protected]>
+
+ Resource Load Statistics: Make WebsiteDataStore::getAllStorageAccessEntries() call the right network process instead of iterating over the process pools
+ https://bugs.webkit.org/show_bug.cgi?id=187277
+ <rdar://problem/41745510>
+
+ Reviewed by Chris Dumez.
+
+ Existing tests use this code. The change is for correctness.
+
+ * UIProcess/API/Cocoa/WKWebsiteDataStore.mm:
+ (-[WKWebsiteDataStore _getAllStorageAccessEntriesFor:completionHandler:]):
+ Now receives a WKWebView from its caller and gets the page ID from it.
+ (-[WKWebsiteDataStore _getAllStorageAccessEntries:]): Deleted.
+ * UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h:
+ * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+ (WebKit::WebsiteDataStore::getAllStorageAccessEntries):
+ Now gets a page ID from its caller and gets the right network process
+ through it.
+ * UIProcess/WebsiteData/WebsiteDataStore.h:
+
2018-07-03 Jonathan Bedard <[email protected]>
Unreviewed, rolling out r233461.
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm (233467 => 233468)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm 2018-07-03 17:50:12 UTC (rev 233467)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStore.mm 2018-07-03 18:25:36 UTC (rev 233468)
@@ -31,7 +31,9 @@
#import "APIString.h"
#import "WKHTTPCookieStoreInternal.h"
#import "WKNSArray.h"
+#import "WKWebViewInternal.h"
#import "WKWebsiteDataRecordInternal.h"
+#import "WebPageProxy.h"
#import "WebResourceLoadStatisticsStore.h"
#import "WebResourceLoadStatisticsTelemetry.h"
#import "WebsiteDataFetchOption.h"
@@ -343,14 +345,24 @@
WebKit::WebsiteDataStore::allowWebsiteDataRecordsForAllOrigins();
}
-- (void)_getAllStorageAccessEntries:(void (^)(NSArray<NSString *> *domains))completionHandler
+- (void)_getAllStorageAccessEntriesFor:(WKWebView *)webView completionHandler:(void (^)(NSArray<NSString *> *domains))completionHandler
{
- _websiteDataStore->websiteDataStore().getAllStorageAccessEntries([completionHandler = makeBlockPtr(completionHandler)](auto domains) {
+ if (!webView) {
+ completionHandler({ });
+ return;
+ }
+
+ auto* webPageProxy = [webView _page];
+ if (!webPageProxy) {
+ completionHandler({ });
+ return;
+ }
+
+ _websiteDataStore->websiteDataStore().getAllStorageAccessEntries(webPageProxy->pageID(), [completionHandler = makeBlockPtr(completionHandler)](auto domains) {
Vector<RefPtr<API::Object>> apiDomains;
apiDomains.reserveInitialCapacity(domains.size());
for (auto& domain : domains)
apiDomains.uncheckedAppend(API::String::create(domain));
-
completionHandler(wrapper(API::Array::create(WTFMove(apiDomains))));
});
}
Modified: trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h (233467 => 233468)
--- trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h 2018-07-03 17:50:12 UTC (rev 233467)
+++ trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebsiteDataStorePrivate.h 2018-07-03 18:25:36 UTC (rev 233468)
@@ -30,6 +30,7 @@
NS_ASSUME_NONNULL_BEGIN
@class _WKWebsiteDataStoreConfiguration;
+@class WKWebView;
typedef NS_OPTIONS(NSUInteger, _WKWebsiteDataStoreFetchOptions) {
_WKWebsiteDataStoreFetchOptionComputeSizes = 1 << 0,
@@ -56,7 +57,7 @@
- (void)_resourceLoadStatisticsSetShouldSubmitTelemetry:(BOOL)value WK_API_AVAILABLE(macosx(10.13), ios(11.0));
- (void)_setResourceLoadStatisticsTestingCallback:(nullable void (^)(WKWebsiteDataStore *, NSString *))callback WK_API_AVAILABLE(macosx(10.13), ios(11.0));
-- (void)_getAllStorageAccessEntries:(void (^)(NSArray<NSString *> *domains))completionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+- (void)_getAllStorageAccessEntriesFor:(WKWebView *)webView completionHandler:(void (^)(NSArray<NSString *> *domains))completionHandler WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
+ (void)_allowWebsiteDataRecordsForAllOrigins WK_API_AVAILABLE(macosx(10.13.4), ios(11.3));
- (bool)_hasRegisteredServiceWorker WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp (233467 => 233468)
--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp 2018-07-03 17:50:12 UTC (rev 233467)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp 2018-07-03 18:25:36 UTC (rev 233468)
@@ -1230,11 +1230,16 @@
networkProcess.hasStorageAccessForFrame(m_sessionID, resourceDomain, firstPartyDomain, frameID, pageID, WTFMove(completionHandler));
}
-void WebsiteDataStore::getAllStorageAccessEntries(CompletionHandler<void(Vector<String>&& domains)>&& completionHandler)
+void WebsiteDataStore::getAllStorageAccessEntries(uint64_t pageID, CompletionHandler<void(Vector<String>&& domains)>&& completionHandler)
{
- // FIXME: Although this is only used for testing, it should not iterate and WTFMove the completion handler.
- for (auto& processPool : processPools())
- processPool->networkProcess()->getAllStorageAccessEntries(m_sessionID, WTFMove(completionHandler));
+ auto* webPage = WebProcessProxy::webPage(pageID);
+ if (!webPage) {
+ completionHandler({ });
+ return;
+ }
+
+ auto& networkProcess = webPage->process().processPool().ensureNetworkProcess();
+ networkProcess.getAllStorageAccessEntries(m_sessionID, WTFMove(completionHandler));
}
void WebsiteDataStore::grantStorageAccessHandler(const String& resourceDomain, const String& firstPartyDomain, std::optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool wasGranted)>&& completionHandler)
Modified: trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h (233467 => 233468)
--- trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h 2018-07-03 17:50:12 UTC (rev 233467)
+++ trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h 2018-07-03 18:25:36 UTC (rev 233468)
@@ -132,7 +132,7 @@
#if HAVE(CFNETWORK_STORAGE_PARTITIONING)
void updatePrevalentDomainsToPartitionOrBlockCookies(const Vector<String>& domainsToPartition, const Vector<String>& domainsToBlock, const Vector<String>& domainsToNeitherPartitionNorBlock, ShouldClearFirst, CompletionHandler<void()>&&);
void hasStorageAccessForFrameHandler(const String& resourceDomain, const String& firstPartyDomain, uint64_t frameID, uint64_t pageID, CompletionHandler<void(bool hasAccess)>&&);
- void getAllStorageAccessEntries(CompletionHandler<void(Vector<String>&& domains)>&&);
+ void getAllStorageAccessEntries(uint64_t pageID, CompletionHandler<void(Vector<String>&& domains)>&&);
void grantStorageAccessHandler(const String& resourceDomain, const String& firstPartyDomain, std::optional<uint64_t> frameID, uint64_t pageID, CompletionHandler<void(bool wasGranted)>&&);
void removeAllStorageAccessHandler();
void removePrevalentDomains(const Vector<String>& domains);
Modified: trunk/Tools/ChangeLog (233467 => 233468)
--- trunk/Tools/ChangeLog 2018-07-03 17:50:12 UTC (rev 233467)
+++ trunk/Tools/ChangeLog 2018-07-03 18:25:36 UTC (rev 233468)
@@ -1,3 +1,14 @@
+2018-07-03 John Wilander <[email protected]>
+
+ Resource Load Statistics: Make WebsiteDataStore::getAllStorageAccessEntries() call the right network process instead of iterating over the process pools
+ https://bugs.webkit.org/show_bug.cgi?id=187277
+ <rdar://problem/41745510>
+
+ Reviewed by Chris Dumez.
+
+ * WebKitTestRunner/cocoa/TestControllerCocoa.mm:
+ (WTR::TestController::getAllStorageAccessEntries):
+
2018-07-02 Wenson Hsieh <[email protected]>
Fix a leak in ActionSheetTests.DismissingActionSheetShouldNotDismissPresentingViewController
Modified: trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm (233467 => 233468)
--- trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm 2018-07-03 17:50:12 UTC (rev 233467)
+++ trunk/Tools/WebKitTestRunner/cocoa/TestControllerCocoa.mm 2018-07-03 18:25:36 UTC (rev 233468)
@@ -266,7 +266,11 @@
void TestController::getAllStorageAccessEntries()
{
#if WK_API_ENABLED
- [globalWebViewConfiguration.websiteDataStore _getAllStorageAccessEntries:^(NSArray<NSString *> *nsDomains) {
+ auto* parentView = mainWebView();
+ if (!parentView)
+ return;
+
+ [globalWebViewConfiguration.websiteDataStore _getAllStorageAccessEntriesFor:parentView->platformView() completionHandler:^(NSArray<NSString *> *nsDomains) {
Vector<String> domains;
domains.reserveInitialCapacity(nsDomains.count);
for (NSString *domain : nsDomains)