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

Unified Diff: third_party/WebKit/public/platform/WebRTCKeyParams.h

Issue 1373023002: RTCCertificate, RTCPeerConnection.generateCertificate (WebRTC JavaScript) added. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed jochen's comments Created 5 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/public/platform/WebRTCKeyParams.h
diff --git a/third_party/WebKit/public/platform/WebData.h b/third_party/WebKit/public/platform/WebRTCKeyParams.h
similarity index 52%
copy from third_party/WebKit/public/platform/WebData.h
copy to third_party/WebKit/public/platform/WebRTCKeyParams.h
index e4d6b879c237732e7eb10c81d617fa4d76d2dda1..c930f079b3f0a5013d300831ab97fe1f859c38a0 100644
--- a/third_party/WebKit/public/platform/WebData.h
+++ b/third_party/WebKit/public/platform/WebRTCKeyParams.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2009 Google Inc. All rights reserved.
+ * Copyright (C) 2015 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -28,78 +28,66 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef WebData_h
-#define WebData_h
+#ifndef WebRTCKeyParams_h
+#define WebRTCKeyParams_h
#include "WebCommon.h"
-#include "WebPrivatePtr.h"
namespace blink {
-class SharedBuffer;
+// Corresponds to rtc::KeyType in WebRTC.
+enum WebRTCKeyType { WebRTCKeyTypeRSA, WebRTCKeyTypeECDSA, WebRTCKeyTypeNull };
-// A container for raw bytes. It is inexpensive to copy a WebData object.
-//
-// WARNING: It is not safe to pass a WebData across threads!!!
-//
-class BLINK_PLATFORM_EXPORT WebData {
-public:
- ~WebData() { reset(); }
-
- WebData() { }
+// Corresponds to rtc::RSAParams in WebRTC.
+struct WebRTCRSAParams {
+ unsigned modLength;
+ unsigned pubExp;
+};
- WebData(const char* data, size_t size)
- {
- assign(data, size);
- }
+// Corresponds to rtc::ECCurve in WebRTC.
+enum WebRTCECCurve { WebRTCECCurveNistP256 };
eroman 2015/10/21 22:55:51 Is it expected that this will always be fixed to P
hbos_chromium 2015/10/22 09:40:56 The current standard only says we must support P-2
- template <int N>
- WebData(const char (&data)[N])
+// Corresponds to rtc::KeyParams in WebRTC.
+class WebRTCKeyParams {
+public:
+ static WebRTCKeyParams createRSA(unsigned modLength, unsigned pubExp)
{
- assign(data, N - 1);
+ WebRTCKeyParams keyParams(WebRTCKeyTypeRSA);
+ keyParams.m_params.rsa.modLength = modLength;
+ keyParams.m_params.rsa.pubExp = pubExp;
+ return keyParams;
}
-
- WebData(const WebData& d) { assign(d); }
-
- WebData& operator=(const WebData& d)
+ static WebRTCKeyParams createECDSA(WebRTCECCurve curve)
{
- assign(d);
- return *this;
+ WebRTCKeyParams keyParams(WebRTCKeyTypeECDSA);
+ keyParams.m_params.ecCurve = curve;
+ return keyParams;
}
- void reset();
- void assign(const WebData&);
- void assign(const char* data, size_t size);
-
- size_t size() const;
- const char* data() const;
+ WebRTCKeyParams() : WebRTCKeyParams(WebRTCKeyTypeNull) {}
- bool isEmpty() const { return !size(); }
- bool isNull() const { return m_private.isNull(); }
-
-#if INSIDE_BLINK
- WebData(const PassRefPtr<SharedBuffer>&);
- WebData& operator=(const PassRefPtr<SharedBuffer>&);
- operator PassRefPtr<SharedBuffer>() const;
-#else
- template <class C>
- WebData(const C& c)
+ WebRTCKeyType keyType() const { return m_keyType; }
+ WebRTCRSAParams rsaParams() const
{
- assign(c.data(), c.size());
+ BLINK_ASSERT(m_keyType == WebRTCKeyTypeRSA);
+ return m_params.rsa;
}
-
- template <class C>
- WebData& operator=(const C& c)
+ WebRTCECCurve ecCurve() const
{
- assign(c.data(), c.size());
- return *this;
+ BLINK_ASSERT(m_keyType == WebRTCKeyTypeECDSA);
+ return m_params.ecCurve;
}
-#endif
private:
- WebPrivatePtr<SharedBuffer> m_private;
+ WebRTCKeyParams(WebRTCKeyType keyType) : m_keyType(keyType) {}
+
+ WebRTCKeyType m_keyType;
+ union {
+ WebRTCRSAParams rsa;
+ WebRTCECCurve ecCurve;
+ } m_params;
};
} // namespace blink
-#endif
+#endif // WebRTCKeyParams_h

Powered by Google App Engine
This is Rietveld 408576698