| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 #include "WebPrivatePtr.h" | 37 #include "WebPrivatePtr.h" |
| 38 #include "WebString.h" | 38 #include "WebString.h" |
| 39 #include "WebVector.h" | 39 #include "WebVector.h" |
| 40 | 40 |
| 41 namespace WebCore { class CryptoResult; } | 41 namespace WebCore { class CryptoResult; } |
| 42 | 42 |
| 43 #if INSIDE_BLINK | 43 #if INSIDE_BLINK |
| 44 namespace WTF { template <typename T> class PassRefPtr; } | 44 namespace WTF { template <typename T> class PassRefPtr; } |
| 45 #endif | 45 #endif |
| 46 | 46 |
| 47 // FIXME: Remove once chromium side rolls. |
| 48 #define WEBCRYPTO_RESULT_HAS_CANCELLED 1 |
| 49 |
| 47 namespace blink { | 50 namespace blink { |
| 48 | 51 |
| 49 class WebArrayBuffer; | 52 class WebArrayBuffer; |
| 50 class WebString; | 53 class WebString; |
| 51 | 54 |
| 52 enum WebCryptoErrorType { | 55 enum WebCryptoErrorType { |
| 53 WebCryptoErrorTypeType, | 56 WebCryptoErrorTypeType, |
| 54 WebCryptoErrorTypeNotSupported, | 57 WebCryptoErrorTypeNotSupported, |
| 55 WebCryptoErrorTypeSyntax, | 58 WebCryptoErrorTypeSyntax, |
| 56 WebCryptoErrorTypeInvalidState, | 59 WebCryptoErrorTypeInvalidState, |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 | 91 |
| 89 // Note that WebArrayBuffer is NOT safe to create from another thread. | 92 // Note that WebArrayBuffer is NOT safe to create from another thread. |
| 90 BLINK_PLATFORM_EXPORT void completeWithBuffer(const WebArrayBuffer&); | 93 BLINK_PLATFORM_EXPORT void completeWithBuffer(const WebArrayBuffer&); |
| 91 // Makes a copy of the input data given as a pointer and byte length. | 94 // Makes a copy of the input data given as a pointer and byte length. |
| 92 BLINK_PLATFORM_EXPORT void completeWithBuffer(const void*, unsigned); | 95 BLINK_PLATFORM_EXPORT void completeWithBuffer(const void*, unsigned); |
| 93 BLINK_PLATFORM_EXPORT void completeWithJson(const char* utf8Data, unsigned l
ength); | 96 BLINK_PLATFORM_EXPORT void completeWithJson(const char* utf8Data, unsigned l
ength); |
| 94 BLINK_PLATFORM_EXPORT void completeWithBoolean(bool); | 97 BLINK_PLATFORM_EXPORT void completeWithBoolean(bool); |
| 95 BLINK_PLATFORM_EXPORT void completeWithKey(const WebCryptoKey&); | 98 BLINK_PLATFORM_EXPORT void completeWithKey(const WebCryptoKey&); |
| 96 BLINK_PLATFORM_EXPORT void completeWithKeyPair(const WebCryptoKey& publicKey
, const WebCryptoKey& privateKey); | 99 BLINK_PLATFORM_EXPORT void completeWithKeyPair(const WebCryptoKey& publicKey
, const WebCryptoKey& privateKey); |
| 97 | 100 |
| 101 // Returns true if the underlying operation was cancelled. |
| 102 // This method can be called from any thread. |
| 103 BLINK_PLATFORM_EXPORT bool cancelled() const; |
| 104 |
| 98 #if INSIDE_BLINK | 105 #if INSIDE_BLINK |
| 99 BLINK_PLATFORM_EXPORT explicit WebCryptoResult(const WTF::PassRefPtr<WebCore
::CryptoResult>&); | 106 BLINK_PLATFORM_EXPORT explicit WebCryptoResult(const WTF::PassRefPtr<WebCore
::CryptoResult>&); |
| 100 #endif | 107 #endif |
| 101 | 108 |
| 102 private: | 109 private: |
| 103 BLINK_PLATFORM_EXPORT void reset(); | 110 BLINK_PLATFORM_EXPORT void reset(); |
| 104 BLINK_PLATFORM_EXPORT void assign(const WebCryptoResult&); | 111 BLINK_PLATFORM_EXPORT void assign(const WebCryptoResult&); |
| 105 | 112 |
| 106 WebPrivatePtr<WebCore::CryptoResult> m_impl; | 113 WebPrivatePtr<WebCore::CryptoResult> m_impl; |
| 107 }; | 114 }; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 // Implementations signal completion by calling one of the methods on | 146 // Implementations signal completion by calling one of the methods on |
| 140 // "result". Only a single result/error should be set for the request. | 147 // "result". Only a single result/error should be set for the request. |
| 141 // Different operations expect different result types based on the | 148 // Different operations expect different result types based on the |
| 142 // algorithm parameters; see the Web Crypto standard for details. | 149 // algorithm parameters; see the Web Crypto standard for details. |
| 143 // | 150 // |
| 144 // The result can be set either synchronously while handling the request, | 151 // The result can be set either synchronously while handling the request, |
| 145 // or asynchronously after the method has returned. When completing | 152 // or asynchronously after the method has returned. When completing |
| 146 // asynchronously make a copy of the WebCryptoResult and call it from the | 153 // asynchronously make a copy of the WebCryptoResult and call it from the |
| 147 // same thread that started the request. | 154 // same thread that started the request. |
| 148 // | 155 // |
| 156 // If the request was cancelled it is not necessary for implementations to |
| 157 // set the result. |
| 158 // |
| 149 // ----------------------- | 159 // ----------------------- |
| 150 // Threading | 160 // Threading |
| 151 // ----------------------- | 161 // ----------------------- |
| 152 // | 162 // |
| 153 // The WebCrypto interface will be called from blink threads (main or | 163 // The WebCrypto interface will be called from blink threads (main or |
| 154 // web worker). All communication back to Blink must be on this same thread. | 164 // web worker). All communication back to Blink must be on this same thread. |
| 155 // | 165 // |
| 156 // Notably: | 166 // Notably: |
| 157 // | 167 // |
| 158 // * The WebCryptoResult can be copied between threads, however all | 168 // * The WebCryptoResult can be copied between threads, however all |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 // Returns true on success. | 277 // Returns true on success. |
| 268 virtual bool serializeKeyForClone(const WebCryptoKey&, WebVector<unsigned ch
ar>&) { return false; } | 278 virtual bool serializeKeyForClone(const WebCryptoKey&, WebVector<unsigned ch
ar>&) { return false; } |
| 269 | 279 |
| 270 protected: | 280 protected: |
| 271 virtual ~WebCrypto() { } | 281 virtual ~WebCrypto() { } |
| 272 }; | 282 }; |
| 273 | 283 |
| 274 } // namespace blink | 284 } // namespace blink |
| 275 | 285 |
| 276 #endif | 286 #endif |
| OLD | NEW |