| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_CHILD_WEBCRYPTO_CRYPTO_DATA_H_ | 5 #ifndef CONTENT_CHILD_WEBCRYPTO_CRYPTO_DATA_H_ |
| 6 #define CONTENT_CHILD_WEBCRYPTO_CRYPTO_DATA_H_ | 6 #define CONTENT_CHILD_WEBCRYPTO_CRYPTO_DATA_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "content/common/content_export.h" | |
| 13 #include "third_party/WebKit/public/platform/WebVector.h" | 12 #include "third_party/WebKit/public/platform/WebVector.h" |
| 14 | 13 |
| 15 namespace content { | 14 namespace components { |
| 16 | 15 |
| 17 namespace webcrypto { | 16 namespace webcrypto { |
| 18 | 17 |
| 19 // Helper to pass around a range of immutable bytes. This is conceptually | 18 // Helper to pass around a range of immutable bytes. This is conceptually |
| 20 // similar to base::StringPiece, but for crypto byte data. | 19 // similar to base::StringPiece, but for crypto byte data. |
| 21 // | 20 // |
| 22 // The data used at construction is NOT owned, and should remain valid as long | 21 // The data used at construction is NOT owned, and should remain valid as long |
| 23 // as the CryptoData is being used. | 22 // as the CryptoData is being used. |
| 24 class CONTENT_EXPORT CryptoData { | 23 class CryptoData { |
| 25 public: | 24 public: |
| 26 // Constructs empty data. | 25 // Constructs empty data. |
| 27 CryptoData(); | 26 CryptoData(); |
| 28 | 27 |
| 29 CryptoData(const unsigned char* bytes, unsigned int byte_length); | 28 CryptoData(const unsigned char* bytes, unsigned int byte_length); |
| 30 | 29 |
| 31 // These constructors do NOT copy the data. Hence the base pointer should | 30 // These constructors do NOT copy the data. Hence the base pointer should |
| 32 // remain valid for the lifetime of CryptoData. | 31 // remain valid for the lifetime of CryptoData. |
| 33 explicit CryptoData(const std::vector<unsigned char>& bytes); | 32 explicit CryptoData(const std::vector<unsigned char>& bytes); |
| 34 explicit CryptoData(const std::string& bytes); | 33 explicit CryptoData(const std::string& bytes); |
| 35 explicit CryptoData(const blink::WebVector<unsigned char>& bytes); | 34 explicit CryptoData(const blink::WebVector<unsigned char>& bytes); |
| 36 | 35 |
| 37 const unsigned char* bytes() const { return bytes_; } | 36 const unsigned char* bytes() const { return bytes_; } |
| 38 unsigned int byte_length() const { return byte_length_; } | 37 unsigned int byte_length() const { return byte_length_; } |
| 39 | 38 |
| 40 private: | 39 private: |
| 41 const unsigned char* const bytes_; | 40 const unsigned char* const bytes_; |
| 42 const unsigned int byte_length_; | 41 const unsigned int byte_length_; |
| 43 }; | 42 }; |
| 44 | 43 |
| 45 } // namespace webcrypto | 44 } // namespace webcrypto |
| 46 | 45 |
| 47 } // namespace content | 46 } // namespace components |
| 48 | 47 |
| 49 #endif // CONTENT_CHILD_WEBCRYPTO_CRYPTO_DATA_H_ | 48 #endif // CONTENT_CHILD_WEBCRYPTO_CRYPTO_DATA_H_ |
| OLD | NEW |