Chromium Code Reviews| Index: content/child/webcrypto/webcrypto_impl.cc |
| diff --git a/content/child/webcrypto/webcrypto_impl.cc b/content/child/webcrypto/webcrypto_impl.cc |
| index 3eed92769c9eab0fe1ae854a2ca48cb2169402f1..bfa111295bb1ac7249a0c179b0899cd56f5393ce 100644 |
| --- a/content/child/webcrypto/webcrypto_impl.cc |
| +++ b/content/child/webcrypto/webcrypto_impl.cc |
| @@ -170,6 +170,14 @@ struct BaseState { |
| explicit BaseState(const blink::WebCryptoResult& result) |
| : origin_thread(GetCurrentBlinkThread()), result(result) {} |
| + bool cancelled() { |
| +#ifdef WEBCRYPTO_RESULT_HAS_CANCELLED |
| + return result.cancelled(); |
|
Ryan Sleevi
2014/06/18 23:59:51
Is this really safe? Seems like we try to only acc
|
| +#else |
| + return false; |
| +#endif |
| + } |
| + |
| scoped_refptr<base::TaskRunner> origin_thread; |
| webcrypto::Status status; |
| @@ -352,6 +360,8 @@ void DoEncryptReply(scoped_ptr<EncryptState> state) { |
| void DoEncrypt(scoped_ptr<EncryptState> passed_state) { |
| EncryptState* state = passed_state.get(); |
| + if (state->cancelled()) |
| + return; |
| state->status = webcrypto::Encrypt(state->algorithm, |
| state->key, |
| webcrypto::CryptoData(state->data), |
| @@ -366,6 +376,8 @@ void DoDecryptReply(scoped_ptr<DecryptState> state) { |
| void DoDecrypt(scoped_ptr<DecryptState> passed_state) { |
| DecryptState* state = passed_state.get(); |
| + if (state->cancelled()) |
| + return; |
| state->status = webcrypto::Decrypt(state->algorithm, |
| state->key, |
| webcrypto::CryptoData(state->data), |
| @@ -380,6 +392,8 @@ void DoDigestReply(scoped_ptr<DigestState> state) { |
| void DoDigest(scoped_ptr<DigestState> passed_state) { |
| DigestState* state = passed_state.get(); |
| + if (state->cancelled()) |
| + return; |
| state->status = webcrypto::Digest( |
| state->algorithm, webcrypto::CryptoData(state->data), &state->buffer); |
| state->origin_thread->PostTask( |
| @@ -399,6 +413,8 @@ void DoGenerateKeyReply(scoped_ptr<GenerateKeyState> state) { |
| void DoGenerateKey(scoped_ptr<GenerateKeyState> passed_state) { |
| GenerateKeyState* state = passed_state.get(); |
| + if (state->cancelled()) |
| + return; |
| state->is_asymmetric = |
| webcrypto::IsAlgorithmAsymmetric(state->algorithm.id()); |
| if (state->is_asymmetric) { |
| @@ -440,6 +456,8 @@ void DoImportKeyReply(scoped_ptr<ImportKeyState> state) { |
| void DoImportKey(scoped_ptr<ImportKeyState> passed_state) { |
| ImportKeyState* state = passed_state.get(); |
| + if (state->cancelled()) |
| + return; |
| state->status = webcrypto::ImportKey(state->format, |
| webcrypto::CryptoData(state->key_data), |
| state->algorithm, |
| @@ -479,6 +497,8 @@ void DoExportKeyReply(scoped_ptr<ExportKeyState> state) { |
| void DoExportKey(scoped_ptr<ExportKeyState> passed_state) { |
| ExportKeyState* state = passed_state.get(); |
| + if (state->cancelled()) |
| + return; |
| state->status = |
| webcrypto::ExportKey(state->format, state->key, &state->buffer); |
| state->origin_thread->PostTask( |
| @@ -491,6 +511,8 @@ void DoSignReply(scoped_ptr<SignState> state) { |
| void DoSign(scoped_ptr<SignState> passed_state) { |
| SignState* state = passed_state.get(); |
| + if (state->cancelled()) |
| + return; |
| state->status = webcrypto::Sign(state->algorithm, |
| state->key, |
| webcrypto::CryptoData(state->data), |
| @@ -510,6 +532,8 @@ void DoVerifyReply(scoped_ptr<VerifySignatureState> state) { |
| void DoVerify(scoped_ptr<VerifySignatureState> passed_state) { |
| VerifySignatureState* state = passed_state.get(); |
| + if (state->cancelled()) |
| + return; |
| state->status = |
| webcrypto::VerifySignature(state->algorithm, |
| state->key, |
| @@ -527,6 +551,8 @@ void DoWrapKeyReply(scoped_ptr<WrapKeyState> state) { |
| void DoWrapKey(scoped_ptr<WrapKeyState> passed_state) { |
| WrapKeyState* state = passed_state.get(); |
| + if (state->cancelled()) |
| + return; |
| state->status = webcrypto::WrapKey(state->format, |
| state->key, |
| state->wrapping_key, |
| @@ -543,6 +569,8 @@ void DoUnwrapKeyReply(scoped_ptr<UnwrapKeyState> state) { |
| void DoUnwrapKey(scoped_ptr<UnwrapKeyState> passed_state) { |
| UnwrapKeyState* state = passed_state.get(); |
| + if (state->cancelled()) |
| + return; |
| state->status = |
| webcrypto::UnwrapKey(state->format, |
| webcrypto::CryptoData(state->wrapped_key), |