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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 #include "public/platform/WebCryptoAlgorithm.h" | 43 #include "public/platform/WebCryptoAlgorithm.h" |
44 #include "wtf/ArrayBufferView.h" | 44 #include "wtf/ArrayBufferView.h" |
45 | 45 |
46 namespace WebCore { | 46 namespace WebCore { |
47 | 47 |
48 CryptoResultImpl::~CryptoResultImpl() | 48 CryptoResultImpl::~CryptoResultImpl() |
49 { | 49 { |
50 ASSERT(m_finished); | 50 ASSERT(m_finished); |
51 } | 51 } |
52 | 52 |
53 PassRefPtr<CryptoResultImpl> CryptoResultImpl::create() | 53 PassRefPtr<CryptoResultImpl> CryptoResultImpl::create(ScriptPromise promise) |
54 { | 54 { |
55 return adoptRef(new CryptoResultImpl); | 55 return adoptRef(new CryptoResultImpl(promise)); |
56 } | 56 } |
57 | 57 |
58 void CryptoResultImpl::completeWithError() | 58 void CryptoResultImpl::completeWithError() |
59 { | 59 { |
60 m_promiseResolver->reject(ScriptValue::createNull()); | 60 m_promiseResolver->reject(ScriptValue::createNull()); |
61 finish(); | 61 finish(); |
62 } | 62 } |
63 | 63 |
64 void CryptoResultImpl::completeWithBuffer(const WebKit::WebArrayBuffer& buffer) | 64 void CryptoResultImpl::completeWithBuffer(const WebKit::WebArrayBuffer& buffer) |
65 { | 65 { |
66 m_promiseResolver->fulfill(PassRefPtr<ArrayBuffer>(buffer)); | 66 m_promiseResolver->resolve(PassRefPtr<ArrayBuffer>(buffer)); |
67 finish(); | 67 finish(); |
68 } | 68 } |
69 | 69 |
70 void CryptoResultImpl::completeWithBoolean(bool b) | 70 void CryptoResultImpl::completeWithBoolean(bool b) |
71 { | 71 { |
72 m_promiseResolver->fulfill(ScriptValue::createBoolean(b)); | 72 m_promiseResolver->resolve(ScriptValue::createBoolean(b)); |
73 finish(); | 73 finish(); |
74 } | 74 } |
75 | 75 |
76 void CryptoResultImpl::completeWithKey(const WebKit::WebCryptoKey& key) | 76 void CryptoResultImpl::completeWithKey(const WebKit::WebCryptoKey& key) |
77 { | 77 { |
78 m_promiseResolver->fulfill(Key::create(key)); | 78 m_promiseResolver->resolve(Key::create(key)); |
79 finish(); | 79 finish(); |
80 } | 80 } |
81 | 81 |
82 void CryptoResultImpl::completeWithKeyPair(const WebKit::WebCryptoKey& publicKey
, const WebKit::WebCryptoKey& privateKey) | 82 void CryptoResultImpl::completeWithKeyPair(const WebKit::WebCryptoKey& publicKey
, const WebKit::WebCryptoKey& privateKey) |
83 { | 83 { |
84 m_promiseResolver->fulfill(KeyPair::create(publicKey, privateKey)); | 84 m_promiseResolver->resolve(KeyPair::create(publicKey, privateKey)); |
85 finish(); | 85 finish(); |
86 } | 86 } |
87 | 87 |
88 ScriptPromise CryptoResultImpl::promise() | 88 CryptoResultImpl::CryptoResultImpl(ScriptPromise promise) |
89 { | 89 : m_promiseResolver(ScriptPromiseResolver::create(promise)) |
90 return m_promiseResolver->promise(); | |
91 } | |
92 | |
93 CryptoResultImpl::CryptoResultImpl() | |
94 : m_promiseResolver(ScriptPromiseResolver::create()) | |
95 , m_finished(false) { } | 90 , m_finished(false) { } |
96 | 91 |
97 void CryptoResultImpl::finish() | 92 void CryptoResultImpl::finish() |
98 { | 93 { |
99 ASSERT(!m_finished); | 94 ASSERT(!m_finished); |
100 m_finished = true; | 95 m_finished = true; |
101 } | 96 } |
102 | 97 |
103 } // namespace WebCore | 98 } // namespace WebCore |
OLD | NEW |