| 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 21 matching lines...) Expand all Loading... |
| 32 #include "public/platform/WebCryptoAlgorithm.h" | 32 #include "public/platform/WebCryptoAlgorithm.h" |
| 33 | 33 |
| 34 #include "public/platform/WebCryptoAlgorithmParams.h" | 34 #include "public/platform/WebCryptoAlgorithmParams.h" |
| 35 #include "wtf/OwnPtr.h" | 35 #include "wtf/OwnPtr.h" |
| 36 #include "wtf/ThreadSafeRefCounted.h" | 36 #include "wtf/ThreadSafeRefCounted.h" |
| 37 | 37 |
| 38 namespace WebKit { | 38 namespace WebKit { |
| 39 | 39 |
| 40 class WebCryptoAlgorithmPrivate : public ThreadSafeRefCounted<WebCryptoAlgorithm
Private> { | 40 class WebCryptoAlgorithmPrivate : public ThreadSafeRefCounted<WebCryptoAlgorithm
Private> { |
| 41 public: | 41 public: |
| 42 WebCryptoAlgorithmPrivate(WebCryptoAlgorithmId id, const char* name, PassOwn
Ptr<WebCryptoAlgorithmParams> params) | 42 WebCryptoAlgorithmPrivate(WebCryptoAlgorithmId id, PassOwnPtr<WebCryptoAlgor
ithmParams> params) |
| 43 : id(id) | 43 : id(id) |
| 44 , name(name) | |
| 45 , params(params) | 44 , params(params) |
| 46 { | 45 { |
| 47 } | 46 } |
| 48 | 47 |
| 49 WebCryptoAlgorithmId id; | 48 WebCryptoAlgorithmId id; |
| 50 const char* const name; | |
| 51 OwnPtr<WebCryptoAlgorithmParams> params; | 49 OwnPtr<WebCryptoAlgorithmParams> params; |
| 52 }; | 50 }; |
| 53 | 51 |
| 54 WebCryptoAlgorithm::WebCryptoAlgorithm(WebCryptoAlgorithmId id, const char* name
, PassOwnPtr<WebCryptoAlgorithmParams> params) | 52 WebCryptoAlgorithm::WebCryptoAlgorithm(WebCryptoAlgorithmId id, PassOwnPtr<WebCr
yptoAlgorithmParams> params) |
| 55 : m_private(adoptRef(new WebCryptoAlgorithmPrivate(id, name, params))) | 53 : m_private(adoptRef(new WebCryptoAlgorithmPrivate(id, params))) |
| 56 { | 54 { |
| 57 } | 55 } |
| 58 | 56 |
| 59 WebCryptoAlgorithm WebCryptoAlgorithm::adoptParamsAndCreate(WebCryptoAlgorithmId
id, const char* name, WebCryptoAlgorithmParams* params) | 57 WebCryptoAlgorithm WebCryptoAlgorithm::adoptParamsAndCreate(WebCryptoAlgorithmId
id, const char*, WebCryptoAlgorithmParams* params) |
| 60 { | 58 { |
| 61 return WebCryptoAlgorithm(id, name, adoptPtr(params)); | 59 return WebCryptoAlgorithm(id, adoptPtr(params)); |
| 60 } |
| 61 |
| 62 WebCryptoAlgorithm WebCryptoAlgorithm::adoptParamsAndCreate(WebCryptoAlgorithmId
id, WebCryptoAlgorithmParams* params) |
| 63 { |
| 64 return WebCryptoAlgorithm(id, adoptPtr(params)); |
| 62 } | 65 } |
| 63 | 66 |
| 64 WebCryptoAlgorithmId WebCryptoAlgorithm::id() const | 67 WebCryptoAlgorithmId WebCryptoAlgorithm::id() const |
| 65 { | 68 { |
| 66 return m_private->id; | 69 return m_private->id; |
| 67 } | 70 } |
| 68 | 71 |
| 69 const char* WebCryptoAlgorithm::name() const | |
| 70 { | |
| 71 return m_private->name; | |
| 72 } | |
| 73 | |
| 74 WebCryptoAlgorithmParamsType WebCryptoAlgorithm::paramsType() const | 72 WebCryptoAlgorithmParamsType WebCryptoAlgorithm::paramsType() const |
| 75 { | 73 { |
| 76 if (!m_private->params) | 74 if (!m_private->params) |
| 77 return WebCryptoAlgorithmParamsTypeNone; | 75 return WebCryptoAlgorithmParamsTypeNone; |
| 78 return m_private->params->type(); | 76 return m_private->params->type(); |
| 79 } | 77 } |
| 80 | 78 |
| 81 WebCryptoAesCbcParams* WebCryptoAlgorithm::aesCbcParams() const | 79 WebCryptoAesCbcParams* WebCryptoAlgorithm::aesCbcParams() const |
| 82 { | 80 { |
| 83 if (paramsType() == WebCryptoAlgorithmParamsTypeAesCbcParams) | 81 if (paramsType() == WebCryptoAlgorithmParamsTypeAesCbcParams) |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 { | 122 { |
| 125 m_private = other.m_private; | 123 m_private = other.m_private; |
| 126 } | 124 } |
| 127 | 125 |
| 128 void WebCryptoAlgorithm::reset() | 126 void WebCryptoAlgorithm::reset() |
| 129 { | 127 { |
| 130 m_private.reset(); | 128 m_private.reset(); |
| 131 } | 129 } |
| 132 | 130 |
| 133 } // namespace WebKit | 131 } // namespace WebKit |
| OLD | NEW |