Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 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 | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 145 const char kGoogLeakyBucket[] = "googLeakyBucket"; | 145 const char kGoogLeakyBucket[] = "googLeakyBucket"; |
| 146 const char kPowerLineFrequency[] = "googPowerLineFrequency"; | 146 const char kPowerLineFrequency[] = "googPowerLineFrequency"; |
| 147 // Names used for testing. | 147 // Names used for testing. |
| 148 const char kTestConstraint1[] = "valid_and_supported_1"; | 148 const char kTestConstraint1[] = "valid_and_supported_1"; |
| 149 const char kTestConstraint2[] = "valid_and_supported_2"; | 149 const char kTestConstraint2[] = "valid_and_supported_2"; |
| 150 | 150 |
| 151 static bool parseMandatoryConstraintsDictionary( | 151 static bool parseMandatoryConstraintsDictionary( |
| 152 const Dictionary& mandatoryConstraintsDictionary, | 152 const Dictionary& mandatoryConstraintsDictionary, |
| 153 Vector<NameValueStringConstraint>& mandatory) { | 153 Vector<NameValueStringConstraint>& mandatory) { |
| 154 HashMap<String, String> mandatoryConstraintsHashMap; | 154 HashMap<String, String> mandatoryConstraintsHashMap; |
| 155 TrackExceptionState exceptionState; | |
|
haraken
2016/11/24 07:22:31
We should avoid using TrackExceptionState in produ
Yuki
2016/11/24 10:19:33
MediaConstraintsImpl looks a little bit different.
haraken
2016/11/24 12:39:13
Okay. However, in long term I think we should repl
Yuki
2016/11/25 08:31:04
Acknowledged.
| |
| 155 bool ok = mandatoryConstraintsDictionary.getOwnPropertiesAsStringHashMap( | 156 bool ok = mandatoryConstraintsDictionary.getOwnPropertiesAsStringHashMap( |
| 156 mandatoryConstraintsHashMap); | 157 mandatoryConstraintsHashMap, exceptionState); |
| 157 if (!ok) | 158 if (!ok) |
| 158 return false; | 159 return false; |
| 159 | 160 |
| 160 for (const auto& iter : mandatoryConstraintsHashMap) | 161 for (const auto& iter : mandatoryConstraintsHashMap) |
| 161 mandatory.append(NameValueStringConstraint(iter.key, iter.value)); | 162 mandatory.append(NameValueStringConstraint(iter.key, iter.value)); |
| 162 return true; | 163 return true; |
| 163 } | 164 } |
| 164 | 165 |
| 165 static bool parseOptionalConstraintsVectorElement( | 166 static bool parseOptionalConstraintsVectorElement( |
| 166 const Dictionary& constraint, | 167 const Dictionary& constraint, |
| 167 Vector<NameValueStringConstraint>& optionalConstraintsVector) { | 168 Vector<NameValueStringConstraint>& optionalConstraintsVector) { |
| 168 Vector<String> localNames; | 169 Vector<String> localNames; |
| 169 bool ok = constraint.getPropertyNames(localNames); | 170 TrackExceptionState exceptionState; |
| 171 bool ok = constraint.getPropertyNames(localNames, exceptionState); | |
| 170 if (!ok) | 172 if (!ok) |
| 171 return false; | 173 return false; |
| 172 if (localNames.size() != 1) | 174 if (localNames.size() != 1) |
| 173 return false; | 175 return false; |
| 174 const String& key = localNames[0]; | 176 const String& key = localNames[0]; |
| 175 String value; | 177 String value; |
| 176 ok = DictionaryHelper::get(constraint, key, value); | 178 ok = DictionaryHelper::get(constraint, key, value); |
| 177 if (!ok) | 179 if (!ok) |
| 178 return false; | 180 return false; |
| 179 optionalConstraintsVector.append(NameValueStringConstraint(key, value)); | 181 optionalConstraintsVector.append(NameValueStringConstraint(key, value)); |
| 180 return true; | 182 return true; |
| 181 } | 183 } |
| 182 | 184 |
| 183 // Old style parser. Deprecated. | 185 // Old style parser. Deprecated. |
| 184 static bool parse(const Dictionary& constraintsDictionary, | 186 static bool parse(const Dictionary& constraintsDictionary, |
| 185 Vector<NameValueStringConstraint>& optional, | 187 Vector<NameValueStringConstraint>& optional, |
| 186 Vector<NameValueStringConstraint>& mandatory) { | 188 Vector<NameValueStringConstraint>& mandatory) { |
| 187 if (constraintsDictionary.isUndefinedOrNull()) | 189 if (constraintsDictionary.isUndefinedOrNull()) |
| 188 return true; | 190 return true; |
| 189 | 191 |
| 190 Vector<String> names; | 192 Vector<String> names; |
| 191 bool ok = constraintsDictionary.getPropertyNames(names); | 193 TrackExceptionState exceptionState; |
| 194 bool ok = constraintsDictionary.getPropertyNames(names, exceptionState); | |
| 192 if (!ok) | 195 if (!ok) |
| 193 return false; | 196 return false; |
| 194 | 197 |
| 195 String mandatoryName("mandatory"); | 198 String mandatoryName("mandatory"); |
| 196 String optionalName("optional"); | 199 String optionalName("optional"); |
| 197 | 200 |
| 198 for (Vector<String>::iterator it = names.begin(); it != names.end(); ++it) { | 201 for (Vector<String>::iterator it = names.begin(); it != names.end(); ++it) { |
| 199 if (*it != mandatoryName && *it != optionalName) | 202 if (*it != mandatoryName && *it != optionalName) |
| 200 return false; | 203 return false; |
| 201 } | 204 } |
| (...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 800 MediaTrackConstraintSet element; | 803 MediaTrackConstraintSet element; |
| 801 convertConstraintSet(it, element); | 804 convertConstraintSet(it, element); |
| 802 advancedVector.append(element); | 805 advancedVector.append(element); |
| 803 } | 806 } |
| 804 if (!advancedVector.isEmpty()) | 807 if (!advancedVector.isEmpty()) |
| 805 output.setAdvanced(advancedVector); | 808 output.setAdvanced(advancedVector); |
| 806 } | 809 } |
| 807 | 810 |
| 808 } // namespace MediaConstraintsImpl | 811 } // namespace MediaConstraintsImpl |
| 809 } // namespace blink | 812 } // namespace blink |
| OLD | NEW |