Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_RENDERER_WEBCRYPTO_CRYPTO_DATA_ | |
| 6 #define CONTENT_RENDERER_WEBCRYPTO_CRYPTO_DATA_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <vector> | |
| 10 | |
| 11 #include "base/basictypes.h" | |
| 12 #include "content/common/content_export.h" | |
| 13 | |
| 14 namespace blink { | |
| 15 class WebArrayBuffer; | |
| 16 } | |
| 17 | |
| 18 namespace content { | |
| 19 | |
| 20 namespace webcrypto { | |
| 21 | |
| 22 // Helper to pass around a range of immutable bytes. This is conceptually | |
| 23 // similar to base::StringPiece, but for crypto byte data. | |
| 24 // | |
| 25 // The data used at construction is NOT owned, and should remain valid as long | |
| 26 // as the CryptoData is being used. | |
| 27 class CONTENT_EXPORT CryptoData { | |
|
Ryan Sleevi
2014/02/07 21:18:49
CryptoDataReference?
| |
| 28 public: | |
| 29 // Constructs empty data. | |
| 30 CryptoData(); | |
| 31 | |
| 32 CryptoData(const unsigned char* bytes, unsigned int byte_length); | |
| 33 | |
| 34 // Allow implicit conversions for convenience. | |
| 35 CryptoData(const std::vector<unsigned char>& bytes); | |
| 36 CryptoData(const std::string& bytes); | |
| 37 CryptoData(const blink::WebArrayBuffer& buffer); | |
| 38 | |
| 39 const unsigned char* bytes() const { return bytes_; } | |
| 40 unsigned int byte_length() const { return byte_length_; } | |
| 41 | |
| 42 private: | |
| 43 const unsigned char* bytes_; | |
| 44 const unsigned int byte_length_; | |
| 45 | |
| 46 // Copying would not be safe, since the data is not owned. | |
| 47 DISALLOW_COPY_AND_ASSIGN(CryptoData); | |
| 48 }; | |
| 49 | |
| 50 } // namespace webcrypto | |
| 51 | |
| 52 } // namespace content | |
| 53 | |
| 54 #endif // CONTENT_RENDERER_WEBCRYPTO_CRYPTO_DATA_ | |
| OLD | NEW |