Fix threading of certificate cache clearing.

The previous instance assumed it was on IO thread. There's also no
handle to IO thread from the Java layer. Introduce another helper in
chrome/ layer which can redirect to IOThread.

BUG=341500
TBR=klobag

Review URL: https://codereview.chromium.org/168313002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@251497 0039d316-1c4b-4281-b951-d872f2087c98
parent 5f0fdf8b
......@@ -293,6 +293,15 @@ public class SSLClientCertificateRequest {
return true;
}
// TODO(yfriedman): Java code doesn't have a global for the IO thread so it's exposed here.
// X509Util helper function could probably move here (as it's still in net/)
public static void notifyClientCertificatesChangedOnIOThread() {
Log.d(TAG, "ClientCertificatesChanged!");
nativeNotifyClientCertificatesChangedOnIOThread();
}
private static native void nativeNotifyClientCertificatesChangedOnIOThread();
// Called to pass request results to native side.
private static native void nativeOnSystemRequestCompletion(
int requestPtr, byte[][] certChain, AndroidPrivateKey androidKey);
......
......@@ -17,11 +17,13 @@
#include "jni/SSLClientCertificateRequest_jni.h"
#include "net/android/keystore_openssl.h"
#include "net/base/host_port_pair.h"
#include "net/cert/cert_database.h"
#include "net/cert/x509_certificate.h"
#include "net/ssl/openssl_client_key_store.h"
#include "net/ssl/ssl_cert_request_info.h"
#include "net/ssl/ssl_client_cert_type.h"
namespace chrome {
namespace {
......@@ -195,6 +197,21 @@ static void OnSystemRequestCompletion(
base::Bind(*callback, client_cert));
}
static void NotifyClientCertificatesChanged() {
net::CertDatabase::GetInstance()->OnAndroidKeyStoreChanged();
}
static void NotifyClientCertificatesChangedOnIOThread(JNIEnv* env, jclass) {
if (content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)) {
NotifyClientCertificatesChanged();
} else {
content::BrowserThread::PostTask(
content::BrowserThread::IO,
FROM_HERE,
base::Bind(&NotifyClientCertificatesChanged));
}
}
bool RegisterSSLClientCertificateRequestAndroid(JNIEnv* env) {
return RegisterNativesImpl(env);
}
......
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