- Revision
- 200304
- Author
- [email protected]
- Date
- 2016-05-01 09:37:04 -0700 (Sun, 01 May 2016)
Log Message
Use enum class instead of string-based enums in RTC code
https://bugs.webkit.org/show_bug.cgi?id=157242
Reviewed by Alex Christensen.
* Modules/mediastream/RTCConfiguration.cpp:
(WebCore::RTCConfiguration::RTCConfiguration): Don't initialize members here,
do it in the header instead.
(WebCore::RTCConfiguration::initialize): Initialize data members to enum values,
not strings.
* Modules/mediastream/RTCConfiguration.h: Tried to keep this class compiling.
Added the new enum class, and changed to use that instead of strings. But note,
this should not even be a class. Needs to become a dictionary.
* Modules/mediastream/RTCConfiguration.idl: Updated the names and values of the
enums to match the current RTC specification. Again, as I said, this should be
a dictionary, not an interface.
* bindings/scripts/CodeGenerator.pm: Removed the RTC enumerations from the list
of string-based enums.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (200303 => 200304)
--- trunk/Source/WebCore/ChangeLog 2016-05-01 14:09:27 UTC (rev 200303)
+++ trunk/Source/WebCore/ChangeLog 2016-05-01 16:37:04 UTC (rev 200304)
@@ -1,3 +1,27 @@
+2016-05-01 Darin Adler <[email protected]>
+
+ Use enum class instead of string-based enums in RTC code
+ https://bugs.webkit.org/show_bug.cgi?id=157242
+
+ Reviewed by Alex Christensen.
+
+ * Modules/mediastream/RTCConfiguration.cpp:
+ (WebCore::RTCConfiguration::RTCConfiguration): Don't initialize members here,
+ do it in the header instead.
+ (WebCore::RTCConfiguration::initialize): Initialize data members to enum values,
+ not strings.
+
+ * Modules/mediastream/RTCConfiguration.h: Tried to keep this class compiling.
+ Added the new enum class, and changed to use that instead of strings. But note,
+ this should not even be a class. Needs to become a dictionary.
+
+ * Modules/mediastream/RTCConfiguration.idl: Updated the names and values of the
+ enums to match the current RTC specification. Again, as I said, this should be
+ a dictionary, not an interface.
+
+ * bindings/scripts/CodeGenerator.pm: Removed the RTC enumerations from the list
+ of string-based enums.
+
2016-04-30 Antti Koivisto <[email protected]>
REGRESSION (r199640): position:absolute generated content inherits text-decoration from its element
Modified: trunk/Source/WebCore/Modules/mediastream/RTCConfiguration.cpp (200303 => 200304)
--- trunk/Source/WebCore/Modules/mediastream/RTCConfiguration.cpp 2016-05-01 14:09:27 UTC (rev 200303)
+++ trunk/Source/WebCore/Modules/mediastream/RTCConfiguration.cpp 2016-05-01 16:37:04 UTC (rev 200304)
@@ -105,8 +105,6 @@
}
RTCConfiguration::RTCConfiguration()
- : m_iceTransportPolicy("all")
- , m_bundlePolicy("balanced")
{
}
@@ -143,8 +141,12 @@
String iceTransportPolicy;
if (configuration.get("iceTransportPolicy", iceTransportPolicy)) {
- if (iceTransportPolicy == "none" || iceTransportPolicy == "relay" || iceTransportPolicy == "all")
- m_iceTransportPolicy = iceTransportPolicy;
+ if (iceTransportPolicy == "public")
+ m_iceTransportPolicy = RTCIceTransportPolicy::Public;
+ else if (iceTransportPolicy == "relay")
+ m_iceTransportPolicy = RTCIceTransportPolicy::Relay;
+ else if (iceTransportPolicy == "all")
+ m_iceTransportPolicy = RTCIceTransportPolicy::All;
else {
ec = TypeError;
return;
@@ -153,8 +155,12 @@
String bundlePolicy;
if (configuration.get("bundlePolicy", bundlePolicy)) {
- if (bundlePolicy == "balanced" || bundlePolicy == "max-compat" || bundlePolicy == "max-bundle")
- m_bundlePolicy = bundlePolicy;
+ if (bundlePolicy == "balanced")
+ m_bundlePolicy = RTCBundlePolicy::Balanced;
+ else if (bundlePolicy == "max-compat")
+ m_bundlePolicy = RTCBundlePolicy::MaxCompat;
+ else if (bundlePolicy == "max-bundle")
+ m_bundlePolicy = RTCBundlePolicy::MaxBundle;
else
ec = TypeError;
}
Modified: trunk/Source/WebCore/Modules/mediastream/RTCConfiguration.h (200303 => 200304)
--- trunk/Source/WebCore/Modules/mediastream/RTCConfiguration.h 2016-05-01 14:09:27 UTC (rev 200303)
+++ trunk/Source/WebCore/Modules/mediastream/RTCConfiguration.h 2016-05-01 16:37:04 UTC (rev 200304)
@@ -45,13 +45,16 @@
typedef int ExceptionCode;
+enum class RTCBundlePolicy { Balanced, MaxCompat, MaxBundle };
+enum class RTCIceTransportPolicy { Public, Relay, All };
+
class RTCConfiguration : public RefCounted<RTCConfiguration> {
public:
static RefPtr<RTCConfiguration> create(const Dictionary& configuration, ExceptionCode&);
virtual ~RTCConfiguration() { }
- const String& iceTransportPolicy() const { return m_iceTransportPolicy; }
- const String& bundlePolicy() const { return m_bundlePolicy; }
+ RTCIceTransportPolicy iceTransportPolicy() const { return m_iceTransportPolicy; }
+ RTCBundlePolicy bundlePolicy() const { return m_bundlePolicy; }
Vector<RefPtr<RTCIceServer>> iceServers() const { return m_iceServers; }
private:
@@ -60,8 +63,8 @@
void initialize(const Dictionary& configuration, ExceptionCode&);
Vector<RefPtr<RTCIceServer>> m_iceServers;
- String m_iceTransportPolicy;
- String m_bundlePolicy;
+ RTCIceTransportPolicy m_iceTransportPolicy { RTCIceTransportPolicy::All };
+ RTCBundlePolicy m_bundlePolicy { RTCBundlePolicy::Balanced };
};
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/mediastream/RTCConfiguration.idl (200303 => 200304)
--- trunk/Source/WebCore/Modules/mediastream/RTCConfiguration.idl 2016-05-01 14:09:27 UTC (rev 200303)
+++ trunk/Source/WebCore/Modules/mediastream/RTCConfiguration.idl 2016-05-01 16:37:04 UTC (rev 200304)
@@ -23,14 +23,14 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-enum RTCIceTransportPolicyEnum { "none", "relay", "all" };
-enum RTCBundlePolicyEnum { "balanced", "max-compat", "max-bundle" };
+enum RTCIceTransportPolicy { "public", "relay", "all" };
+enum RTCBundlePolicy { "balanced", "max-compat", "max-bundle" };
[
Conditional=WEB_RTC,
NoInterfaceObject,
] interface RTCConfiguration {
readonly attribute RTCIceServer[] iceServers;
- readonly attribute RTCIceTransportPolicyEnum iceTransportPolicy;
- readonly attribute RTCBundlePolicyEnum bundlePolicy;
+ readonly attribute RTCIceTransportPolicy iceTransportPolicy;
+ readonly attribute RTCBundlePolicy bundlePolicy;
};
Modified: trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm (200303 => 200304)
--- trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm 2016-05-01 14:09:27 UTC (rev 200303)
+++ trunk/Source/WebCore/bindings/scripts/CodeGenerator.pm 2016-05-01 16:37:04 UTC (rev 200304)
@@ -133,8 +133,6 @@
# enumeration to using an actual enum class in the C++. Once that is done, we should
# remove this hash and the function that calls it.
my %stringBasedEnumerationHash = (
- "RTCBundlePolicyEnum" => 1,
- "RTCIceTransportPolicyEnum" => 1,
"ReferrerPolicy" => 1,
"RequestCache" => 1,
"RequestCredentials" => 1,