Title: [220136] trunk/Source/WebKit
- Revision
- 220136
- Author
- [email protected]
- Date
- 2017-08-02 10:45:52 -0700 (Wed, 02 Aug 2017)
Log Message
ResourceLoadStatisticsClassifierCocoa::singletonPredictionModel() should check the return value of storagePath()
https://bugs.webkit.org/show_bug.cgi?id=175055
<rdar://problem/32671352>
Reviewed by David Kilzer.
* Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp:
(WebKit::ResourceLoadStatisticsClassifierCocoa::singletonPredictionModel):
Now uses dispatch_once() instead of NeverDestroyed and checks the
return value of storagePath() before using it to load the model.
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (220135 => 220136)
--- trunk/Source/WebKit/ChangeLog 2017-08-02 17:38:57 UTC (rev 220135)
+++ trunk/Source/WebKit/ChangeLog 2017-08-02 17:45:52 UTC (rev 220136)
@@ -1,3 +1,16 @@
+2017-08-02 John Wilander <[email protected]>
+
+ ResourceLoadStatisticsClassifierCocoa::singletonPredictionModel() should check the return value of storagePath()
+ https://bugs.webkit.org/show_bug.cgi?id=175055
+ <rdar://problem/32671352>
+
+ Reviewed by David Kilzer.
+
+ * Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp:
+ (WebKit::ResourceLoadStatisticsClassifierCocoa::singletonPredictionModel):
+ Now uses dispatch_once() instead of NeverDestroyed and checks the
+ return value of storagePath() before using it to load the model.
+
2017-08-01 Brian Burg <[email protected]>
HTML file input elements do not support file extensions in the "accept" attribute
Modified: trunk/Source/WebKit/Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp (220135 => 220136)
--- trunk/Source/WebKit/Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp 2017-08-02 17:38:57 UTC (rev 220135)
+++ trunk/Source/WebKit/Platform/classifier/cocoa/ResourceLoadStatisticsClassifierCocoa.cpp 2017-08-02 17:45:52 UTC (rev 220136)
@@ -103,11 +103,19 @@
const struct svm_model* ResourceLoadStatisticsClassifierCocoa::singletonPredictionModel()
{
- static NeverDestroyed<struct svm_model*> corePredictionModel = svm_load_model(storagePath().utf8().data());
+ static std::optional<struct svm_model*> corePredictionModel;
+ static dispatch_once_t onceToken;
+ dispatch_once(&onceToken, ^{
+ auto path = storagePath();
+ if (path.isEmpty())
+ return;
- if (corePredictionModel)
- return corePredictionModel;
+ corePredictionModel = svm_load_model(path.utf8().data());
+ });
+ if (corePredictionModel && corePredictionModel.value())
+ return corePredictionModel.value();
+
WTFLogAlways("ResourceLoadStatisticsClassifierCocoa::singletonPredictionModel(): Couldn't load model file at path %s.", storagePath().utf8().data());
m_useCorePrediction = false;
return nullptr;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes