Commit 398625c5 authored by Eugene But's avatar Eugene But Committed by Commit Bot

Use WebThread::PostTask in CRWCertVerificationController.

GCD API was used to make sure that completion callbacks are called
during the app shutdown. Calling completion handler is required by
WKWebView, otherwise web view throws an exception. This CL uses
WebThread::PostTask instead of GCD behind feature flag. This will allow
to run an experiment to see if using WebThread::PostTask leads to crashes
during app shutdown.

WebThread::PostTask is preferable for testing, because there is no
good way to wait until GCD tasks are completed in a unit test.

Bug: 853774
Cq-Include-Trybots: luci.chromium.try:ios-simulator-full-configs;master.tryserver.chromium.mac:ios-simulator-cronet
Change-Id: Ie9eefa7f7cef0c7432a2f733086fc5d630d8a969
Reviewed-on: https://chromium-review.googlesource.com/1113182Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Commit-Queue: Eugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#570028}
parent c6d904ca
...@@ -22,6 +22,10 @@ const base::Feature kNewFileDownload{"NewFileDownload", ...@@ -22,6 +22,10 @@ const base::Feature kNewFileDownload{"NewFileDownload",
const base::Feature kWebErrorPages{"WebErrorPages", const base::Feature kWebErrorPages{"WebErrorPages",
base::FEATURE_ENABLED_BY_DEFAULT}; base::FEATURE_ENABLED_BY_DEFAULT};
const base::Feature kUseWebThreadInCertVerificationController{
"UseWebThreadInCertVerificationController",
base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kWKHTTPSystemCookieStore{"WKHTTPSystemCookieStore", const base::Feature kWKHTTPSystemCookieStore{"WKHTTPSystemCookieStore",
base::FEATURE_DISABLED_BY_DEFAULT}; base::FEATURE_DISABLED_BY_DEFAULT};
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "base/task_scheduler/post_task.h" #include "base/task_scheduler/post_task.h"
#include "ios/web/public/browser_state.h" #include "ios/web/public/browser_state.h"
#include "ios/web/public/certificate_policy_cache.h" #include "ios/web/public/certificate_policy_cache.h"
#include "ios/web/public/features.h"
#include "ios/web/public/web_thread.h" #include "ios/web/public/web_thread.h"
#import "ios/web/web_state/wk_web_view_security_util.h" #import "ios/web/web_state/wk_web_view_security_util.h"
#include "net/cert/cert_verify_proc_ios.h" #include "net/cert/cert_verify_proc_ios.h"
...@@ -197,9 +198,18 @@ decideLoadPolicyForRejectedTrustResult:(SecTrustResultType)trustResult ...@@ -197,9 +198,18 @@ decideLoadPolicyForRejectedTrustResult:(SecTrustResultType)trustResult
trustResult = kSecTrustResultInvalid; trustResult = kSecTrustResultInvalid;
} }
// Use GCD API, which is guaranteed to be called during shutdown. // Use GCD API, which is guaranteed to be called during shutdown.
dispatch_async(dispatch_get_main_queue(), ^{
completionHandler(trustResult); if (base::FeatureList::IsEnabled(
}); web::features::kUseWebThreadInCertVerificationController)) {
web::WebThread::PostTask(web::WebThread::UI, FROM_HERE,
base::BindOnce(^{
completionHandler(trustResult);
}));
} else {
dispatch_async(dispatch_get_main_queue(), ^{
completionHandler(trustResult);
});
}
})); }));
} }
......
...@@ -25,6 +25,12 @@ extern const base::Feature kNewFileDownload; ...@@ -25,6 +25,12 @@ extern const base::Feature kNewFileDownload;
// Used to enable displaying error pages in WebState by loading HTML string. // Used to enable displaying error pages in WebState by loading HTML string.
extern const base::Feature kWebErrorPages; extern const base::Feature kWebErrorPages;
// If enabled the CRWCertVerificationController will use WebThread::PostTask
// instead of GCD. GCD API was used to make sure that completion callbacks are
// called during the app shutdown, which may be unnecessary
// (https://crbug.com/853774).
extern const base::Feature kUseWebThreadInCertVerificationController;
// Used to enable using WKHTTPSystemCookieStore in main context URL requests. // Used to enable using WKHTTPSystemCookieStore in main context URL requests.
extern const base::Feature kWKHTTPSystemCookieStore; extern const base::Feature kWKHTTPSystemCookieStore;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment