Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(632)

Side by Side Diff: Source/core/platform/chromium/support/WebCryptoAlgorithm.cpp

Issue 44993003: [webcrypto] Make WebCryptoAlgorithm "nullable". (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/core/platform/chromium/support/WebCryptoKey.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 47
48 WebCryptoAlgorithmId id; 48 WebCryptoAlgorithmId id;
49 OwnPtr<WebCryptoAlgorithmParams> params; 49 OwnPtr<WebCryptoAlgorithmParams> params;
50 }; 50 };
51 51
52 WebCryptoAlgorithm::WebCryptoAlgorithm(WebCryptoAlgorithmId id, PassOwnPtr<WebCr yptoAlgorithmParams> params) 52 WebCryptoAlgorithm::WebCryptoAlgorithm(WebCryptoAlgorithmId id, PassOwnPtr<WebCr yptoAlgorithmParams> params)
53 : m_private(adoptRef(new WebCryptoAlgorithmPrivate(id, params))) 53 : m_private(adoptRef(new WebCryptoAlgorithmPrivate(id, params)))
54 { 54 {
55 } 55 }
56 56
57 WebCryptoAlgorithm WebCryptoAlgorithm::createNull()
58 {
59 return WebCryptoAlgorithm();
60 }
61
57 WebCryptoAlgorithm WebCryptoAlgorithm::adoptParamsAndCreate(WebCryptoAlgorithmId id, WebCryptoAlgorithmParams* params) 62 WebCryptoAlgorithm WebCryptoAlgorithm::adoptParamsAndCreate(WebCryptoAlgorithmId id, WebCryptoAlgorithmParams* params)
58 { 63 {
59 return WebCryptoAlgorithm(id, adoptPtr(params)); 64 return WebCryptoAlgorithm(id, adoptPtr(params));
60 } 65 }
61 66
67 bool WebCryptoAlgorithm::isNull() const
68 {
69 return m_private.isNull();
70 }
71
62 WebCryptoAlgorithmId WebCryptoAlgorithm::id() const 72 WebCryptoAlgorithmId WebCryptoAlgorithm::id() const
63 { 73 {
74 ASSERT(!isNull());
64 return m_private->id; 75 return m_private->id;
65 } 76 }
66 77
67 WebCryptoAlgorithmParamsType WebCryptoAlgorithm::paramsType() const 78 WebCryptoAlgorithmParamsType WebCryptoAlgorithm::paramsType() const
68 { 79 {
80 ASSERT(!isNull());
69 if (!m_private->params) 81 if (!m_private->params)
70 return WebCryptoAlgorithmParamsTypeNone; 82 return WebCryptoAlgorithmParamsTypeNone;
71 return m_private->params->type(); 83 return m_private->params->type();
72 } 84 }
73 85
74 const WebCryptoAesCbcParams* WebCryptoAlgorithm::aesCbcParams() const 86 const WebCryptoAesCbcParams* WebCryptoAlgorithm::aesCbcParams() const
75 { 87 {
88 ASSERT(!isNull());
76 if (paramsType() == WebCryptoAlgorithmParamsTypeAesCbcParams) 89 if (paramsType() == WebCryptoAlgorithmParamsTypeAesCbcParams)
77 return static_cast<WebCryptoAesCbcParams*>(m_private->params.get()); 90 return static_cast<WebCryptoAesCbcParams*>(m_private->params.get());
78 return 0; 91 return 0;
79 } 92 }
80 93
81 const WebCryptoAesKeyGenParams* WebCryptoAlgorithm::aesKeyGenParams() const 94 const WebCryptoAesKeyGenParams* WebCryptoAlgorithm::aesKeyGenParams() const
82 { 95 {
96 ASSERT(!isNull());
83 if (paramsType() == WebCryptoAlgorithmParamsTypeAesKeyGenParams) 97 if (paramsType() == WebCryptoAlgorithmParamsTypeAesKeyGenParams)
84 return static_cast<WebCryptoAesKeyGenParams*>(m_private->params.get()); 98 return static_cast<WebCryptoAesKeyGenParams*>(m_private->params.get());
85 return 0; 99 return 0;
86 } 100 }
87 101
88 const WebCryptoHmacParams* WebCryptoAlgorithm::hmacParams() const 102 const WebCryptoHmacParams* WebCryptoAlgorithm::hmacParams() const
89 { 103 {
104 ASSERT(!isNull());
90 if (paramsType() == WebCryptoAlgorithmParamsTypeHmacParams) 105 if (paramsType() == WebCryptoAlgorithmParamsTypeHmacParams)
91 return static_cast<WebCryptoHmacParams*>(m_private->params.get()); 106 return static_cast<WebCryptoHmacParams*>(m_private->params.get());
92 return 0; 107 return 0;
93 } 108 }
94 109
95 const WebCryptoHmacKeyParams* WebCryptoAlgorithm::hmacKeyParams() const 110 const WebCryptoHmacKeyParams* WebCryptoAlgorithm::hmacKeyParams() const
96 { 111 {
112 ASSERT(!isNull());
97 if (paramsType() == WebCryptoAlgorithmParamsTypeHmacKeyParams) 113 if (paramsType() == WebCryptoAlgorithmParamsTypeHmacKeyParams)
98 return static_cast<WebCryptoHmacKeyParams*>(m_private->params.get()); 114 return static_cast<WebCryptoHmacKeyParams*>(m_private->params.get());
99 return 0; 115 return 0;
100 } 116 }
101 117
102 const WebCryptoRsaSsaParams* WebCryptoAlgorithm::rsaSsaParams() const 118 const WebCryptoRsaSsaParams* WebCryptoAlgorithm::rsaSsaParams() const
103 { 119 {
120 ASSERT(!isNull());
104 if (paramsType() == WebCryptoAlgorithmParamsTypeRsaSsaParams) 121 if (paramsType() == WebCryptoAlgorithmParamsTypeRsaSsaParams)
105 return static_cast<WebCryptoRsaSsaParams*>(m_private->params.get()); 122 return static_cast<WebCryptoRsaSsaParams*>(m_private->params.get());
106 return 0; 123 return 0;
107 } 124 }
108 125
109 const WebCryptoRsaKeyGenParams* WebCryptoAlgorithm::rsaKeyGenParams() const 126 const WebCryptoRsaKeyGenParams* WebCryptoAlgorithm::rsaKeyGenParams() const
110 { 127 {
128 ASSERT(!isNull());
111 if (paramsType() == WebCryptoAlgorithmParamsTypeRsaKeyGenParams) 129 if (paramsType() == WebCryptoAlgorithmParamsTypeRsaKeyGenParams)
112 return static_cast<WebCryptoRsaKeyGenParams*>(m_private->params.get()); 130 return static_cast<WebCryptoRsaKeyGenParams*>(m_private->params.get());
113 return 0; 131 return 0;
114 } 132 }
115 133
116 const WebCryptoAesGcmParams* WebCryptoAlgorithm::aesGcmParams() const 134 const WebCryptoAesGcmParams* WebCryptoAlgorithm::aesGcmParams() const
117 { 135 {
136 ASSERT(!isNull());
118 if (paramsType() == WebCryptoAlgorithmParamsTypeAesGcmParams) 137 if (paramsType() == WebCryptoAlgorithmParamsTypeAesGcmParams)
119 return static_cast<WebCryptoAesGcmParams*>(m_private->params.get()); 138 return static_cast<WebCryptoAesGcmParams*>(m_private->params.get());
120 return 0; 139 return 0;
121 } 140 }
122 141
123 const WebCryptoRsaOaepParams* WebCryptoAlgorithm::rsaOaepParams() const 142 const WebCryptoRsaOaepParams* WebCryptoAlgorithm::rsaOaepParams() const
124 { 143 {
144 ASSERT(!isNull());
125 if (paramsType() == WebCryptoAlgorithmParamsTypeRsaOaepParams) 145 if (paramsType() == WebCryptoAlgorithmParamsTypeRsaOaepParams)
126 return static_cast<WebCryptoRsaOaepParams*>(m_private->params.get()); 146 return static_cast<WebCryptoRsaOaepParams*>(m_private->params.get());
127 return 0; 147 return 0;
128 } 148 }
129 149
130 void WebCryptoAlgorithm::assign(const WebCryptoAlgorithm& other) 150 void WebCryptoAlgorithm::assign(const WebCryptoAlgorithm& other)
131 { 151 {
132 m_private = other.m_private; 152 m_private = other.m_private;
133 } 153 }
134 154
135 void WebCryptoAlgorithm::reset() 155 void WebCryptoAlgorithm::reset()
136 { 156 {
137 m_private.reset(); 157 m_private.reset();
138 } 158 }
139 159
140 } // namespace WebKit 160 } // namespace WebKit
OLDNEW
« no previous file with comments | « no previous file | Source/core/platform/chromium/support/WebCryptoKey.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698