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

Side by Side Diff: public/platform/WebCryptoKey.h

Issue 48753003: [webcrypto] Make WebCryptoKey nullable. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 1 month 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 | « public/platform/WebCrypto.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 // a "WebCryptoKeyHandle*". 77 // a "WebCryptoKeyHandle*".
78 // 78 //
79 // WebCryptoKey is: 79 // WebCryptoKey is:
80 // * Copiable (cheaply) 80 // * Copiable (cheaply)
81 // * Threadsafe if the embedder's WebCryptoKeyHandle is also threadsafe. 81 // * Threadsafe if the embedder's WebCryptoKeyHandle is also threadsafe.
82 // 82 //
83 // The embedder is responsible for creating all WebCryptoKeys, and therefore can 83 // The embedder is responsible for creating all WebCryptoKeys, and therefore can
84 // safely assume any details regarding the type of the wrapped 84 // safely assume any details regarding the type of the wrapped
85 // WebCryptoKeyHandle*. 85 // WebCryptoKeyHandle*.
86 // 86 //
87 // If WebCryptoKey "isNull()" then it is invalid to call any of the other
88 // methods on it (other than destruction, assignment, or isNull()).
89 //
87 // FIXME: Define the interface to use for structured clone. 90 // FIXME: Define the interface to use for structured clone.
88 // Cloning across a process boundary will need serialization, 91 // Cloning across a process boundary will need serialization,
89 // however cloning for in-process workers could just share the same 92 // however cloning for in-process workers could just share the same
90 // (threadsafe) handle. 93 // (threadsafe) handle.
91 class WebCryptoKey { 94 class WebCryptoKey {
92 public: 95 public:
93 ~WebCryptoKey() { reset(); } 96 ~WebCryptoKey() { reset(); }
94 97
95 WebCryptoKey(const WebCryptoKey& other) { assign(other); } 98 WebCryptoKey(const WebCryptoKey& other) { assign(other); }
96 WebCryptoKey& operator=(const WebCryptoKey& other) 99 WebCryptoKey& operator=(const WebCryptoKey& other)
97 { 100 {
98 assign(other); 101 assign(other);
99 return *this; 102 return *this;
100 } 103 }
101 104
102 // For an explanation of these parameters see: 105 // For an explanation of these parameters see:
103 // https://dvcs.w3.org/hg/webcrypto-api/raw-file/tip/spec/Overview.html#key- interface-members 106 // https://dvcs.w3.org/hg/webcrypto-api/raw-file/tip/spec/Overview.html#key- interface-members
104 // 107 //
105 // Note that the caller is passing ownership of the WebCryptoKeyHandle*. 108 // Note that the caller is passing ownership of the WebCryptoKeyHandle*.
106 BLINK_PLATFORM_EXPORT static WebCryptoKey create(WebCryptoKeyHandle*, WebCry ptoKeyType, bool extractable, const WebCryptoAlgorithm&, WebCryptoKeyUsageMask); 109 BLINK_PLATFORM_EXPORT static WebCryptoKey create(WebCryptoKeyHandle*, WebCry ptoKeyType, bool extractable, const WebCryptoAlgorithm&, WebCryptoKeyUsageMask);
107 110
111 BLINK_PLATFORM_EXPORT static WebCryptoKey createNull();
112
108 // Returns the opaque key handle that was set by the embedder. 113 // Returns the opaque key handle that was set by the embedder.
109 // * Safe to downcast to known type (since embedder creates all the keys) 114 // * Safe to downcast to known type (since embedder creates all the keys)
110 // * Returned pointer's lifetime is bound to |this| 115 // * Returned pointer's lifetime is bound to |this|
111 BLINK_PLATFORM_EXPORT WebCryptoKeyHandle* handle() const; 116 BLINK_PLATFORM_EXPORT WebCryptoKeyHandle* handle() const;
112 117
113 BLINK_PLATFORM_EXPORT WebCryptoKeyType type() const; 118 BLINK_PLATFORM_EXPORT WebCryptoKeyType type() const;
114 BLINK_PLATFORM_EXPORT bool extractable() const; 119 BLINK_PLATFORM_EXPORT bool extractable() const;
115 BLINK_PLATFORM_EXPORT const WebCryptoAlgorithm& algorithm() const; 120 BLINK_PLATFORM_EXPORT const WebCryptoAlgorithm& algorithm() const;
116 BLINK_PLATFORM_EXPORT WebCryptoKeyUsageMask usages() const; 121 BLINK_PLATFORM_EXPORT WebCryptoKeyUsageMask usages() const;
117 122
123 BLINK_PLATFORM_EXPORT bool isNull() const;
124
118 private: 125 private:
119 WebCryptoKey() { } 126 WebCryptoKey() { }
120 BLINK_PLATFORM_EXPORT void assign(const WebCryptoKey& other); 127 BLINK_PLATFORM_EXPORT void assign(const WebCryptoKey& other);
121 BLINK_PLATFORM_EXPORT void reset(); 128 BLINK_PLATFORM_EXPORT void reset();
122 129
123 WebPrivatePtr<WebCryptoKeyPrivate> m_private; 130 WebPrivatePtr<WebCryptoKeyPrivate> m_private;
124 }; 131 };
125 132
126 // Base class for the embedder to define its own opaque key handle. The lifetime 133 // Base class for the embedder to define its own opaque key handle. The lifetime
127 // of this object is controlled by WebCryptoKey using reference counting. 134 // of this object is controlled by WebCryptoKey using reference counting.
128 class WebCryptoKeyHandle { 135 class WebCryptoKeyHandle {
129 public: 136 public:
130 virtual ~WebCryptoKeyHandle() { } 137 virtual ~WebCryptoKeyHandle() { }
131 }; 138 };
132 139
133 } // namespace WebKit 140 } // namespace WebKit
134 141
135 #endif 142 #endif
OLDNEW
« no previous file with comments | « public/platform/WebCrypto.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698