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

Side by Side Diff: content/renderer/webcrypto/crypto_data.h

Issue 155623005: Refactor to share more code between OpenSSL and NSS implementations. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change header guard Created 6 years, 10 months 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 | « content/content_tests.gypi ('k') | content/renderer/webcrypto/crypto_data.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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_H_
6 #define CONTENT_RENDERER_WEBCRYPTO_CRYPTO_DATA_H_
7
8 #include <string>
9 #include <vector>
10
11 #include "base/basictypes.h"
12 #include "content/common/content_export.h"
13 #include "third_party/WebKit/public/platform/WebVector.h"
14
15 namespace blink {
16 class WebArrayBuffer;
17 }
18
19 namespace content {
20
21 namespace webcrypto {
22
23 // Helper to pass around a range of immutable bytes. This is conceptually
24 // similar to base::StringPiece, but for crypto byte data.
25 //
26 // The data used at construction is NOT owned, and should remain valid as long
27 // as the CryptoData is being used.
28 class CONTENT_EXPORT CryptoData {
29 public:
30 // Constructs empty data.
31 CryptoData();
32
33 CryptoData(const unsigned char* bytes, unsigned int byte_length);
34
35 // These constructors do NOT copy the data. Hence the base pointer should
36 // remain valid for the lifetime of CryptoData.
37 explicit CryptoData(const std::vector<unsigned char>& bytes);
38 explicit CryptoData(const std::string& bytes);
39 explicit CryptoData(const blink::WebArrayBuffer& buffer);
40 explicit CryptoData(const blink::WebVector<unsigned char>& bytes);
41
42 const unsigned char* bytes() const { return bytes_; }
43 unsigned int byte_length() const { return byte_length_; }
44
45 private:
46 const unsigned char* const bytes_;
47 const unsigned int byte_length_;
48
49 DISALLOW_COPY_AND_ASSIGN(CryptoData);
50 };
51
52 } // namespace webcrypto
53
54 } // namespace content
55
56 #endif // CONTENT_RENDERER_WEBCRYPTO_CRYPTO_DATA_H_
OLDNEW
« no previous file with comments | « content/content_tests.gypi ('k') | content/renderer/webcrypto/crypto_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698