Don't preload rarely seen large images
[chromium-blink-merge.git] / components / webcrypto / crypto_data.h
blob0056a209f93017514b4658c34df8e0f2657a6140
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_WEBCRYPTO_CRYPTO_DATA_H_
6 #define COMPONENTS_WEBCRYPTO_CRYPTO_DATA_H_
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "third_party/WebKit/public/platform/WebVector.h"
14 namespace webcrypto {
16 // Helper to pass around a range of immutable bytes. This is conceptually
17 // similar to base::StringPiece, but for crypto byte data.
19 // The data used at construction is NOT owned, and should remain valid as long
20 // as the CryptoData is being used.
21 class CryptoData {
22 public:
23 // Constructs empty data.
24 CryptoData();
26 CryptoData(const unsigned char* bytes, unsigned int byte_length);
28 // These constructors do NOT copy the data. Hence the base pointer should
29 // remain valid for the lifetime of CryptoData.
30 explicit CryptoData(const std::vector<unsigned char>& bytes);
31 explicit CryptoData(const std::string& bytes);
32 explicit CryptoData(const blink::WebVector<unsigned char>& bytes);
34 const unsigned char* bytes() const { return bytes_; }
35 unsigned int byte_length() const { return byte_length_; }
37 private:
38 const unsigned char* const bytes_;
39 const unsigned int byte_length_;
42 } // namespace webcrypto
44 #endif // COMPONENTS_WEBCRYPTO_CRYPTO_DATA_H_