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 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
109 if (m_resolver) | 109 if (m_resolver) |
110 m_resolver->reject(DOMException::create(webCryptoErrorToExceptionCode(er rorType), errorDetails)); | 110 m_resolver->reject(DOMException::create(webCryptoErrorToExceptionCode(er rorType), errorDetails)); |
111 } | 111 } |
112 | 112 |
113 void CryptoResultImpl::completeWithBuffer(const blink::WebArrayBuffer& buffer) | 113 void CryptoResultImpl::completeWithBuffer(const blink::WebArrayBuffer& buffer) |
114 { | 114 { |
115 if (m_resolver) | 115 if (m_resolver) |
116 m_resolver->resolve(PassRefPtr<ArrayBuffer>(buffer)); | 116 m_resolver->resolve(PassRefPtr<ArrayBuffer>(buffer)); |
117 } | 117 } |
118 | 118 |
119 void CryptoResultImpl::completeWithJson(const char* utf8Data, unsigned length) | |
120 { | |
121 if (m_resolver) { | |
122 ScriptState* scriptState = m_resolver->scriptState(); | |
123 ScriptState::Scope scope(scriptState); | |
124 | |
125 v8::Handle<v8::String> jsonString = v8AtomicString(scriptState->isolate( ), utf8Data, length); | |
abarth-chromium
2014/06/17 05:03:05
Why atomic?
eroman
2014/06/17 17:58:02
Thanks for pointing this out!
I had a misundersta
eroman
2014/06/17 18:06:56
Done.
| |
126 | |
127 v8::TryCatch exceptionCatcher; | |
128 v8::Handle<v8::Value> jsonDictionary = v8::JSON::Parse(jsonString); | |
129 if (exceptionCatcher.HasCaught() || jsonDictionary.IsEmpty()) { | |
130 ASSERT_NOT_REACHED(); | |
131 m_resolver->reject(DOMException::create(OperationError, "Failed infl ating JWK JSON to object")); | |
132 return; | |
133 } | |
134 | |
135 m_resolver->resolve(jsonDictionary); | |
136 } | |
137 } | |
138 | |
119 void CryptoResultImpl::completeWithBoolean(bool b) | 139 void CryptoResultImpl::completeWithBoolean(bool b) |
120 { | 140 { |
121 if (m_resolver) | 141 if (m_resolver) |
122 m_resolver->resolve(b); | 142 m_resolver->resolve(b); |
123 } | 143 } |
124 | 144 |
125 void CryptoResultImpl::completeWithKey(const blink::WebCryptoKey& key) | 145 void CryptoResultImpl::completeWithKey(const blink::WebCryptoKey& key) |
126 { | 146 { |
127 if (m_resolver) | 147 if (m_resolver) |
128 m_resolver->resolve(Key::create(key)); | 148 m_resolver->resolve(Key::create(key)); |
129 } | 149 } |
130 | 150 |
131 void CryptoResultImpl::completeWithKeyPair(const blink::WebCryptoKey& publicKey, const blink::WebCryptoKey& privateKey) | 151 void CryptoResultImpl::completeWithKeyPair(const blink::WebCryptoKey& publicKey, const blink::WebCryptoKey& privateKey) |
132 { | 152 { |
133 if (m_resolver) | 153 if (m_resolver) |
134 m_resolver->resolve(KeyPair::create(publicKey, privateKey)); | 154 m_resolver->resolve(KeyPair::create(publicKey, privateKey)); |
135 } | 155 } |
136 | 156 |
137 CryptoResultImpl::CryptoResultImpl(ScriptState* scriptState) | 157 CryptoResultImpl::CryptoResultImpl(ScriptState* scriptState) |
138 : m_resolver(WeakResolver::create(scriptState)) | 158 : m_resolver(WeakResolver::create(scriptState)) |
139 { | 159 { |
140 } | 160 } |
141 | 161 |
142 ScriptPromise CryptoResultImpl::promise() | 162 ScriptPromise CryptoResultImpl::promise() |
143 { | 163 { |
144 return m_resolver->promise(); | 164 return m_resolver->promise(); |
145 } | 165 } |
146 | 166 |
147 } // namespace WebCore | 167 } // namespace WebCore |
OLD | NEW |