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

Side by Side Diff: third_party/WebKit/Source/modules/mediastream/MediaConstraintsImpl.cpp

Issue 2614663008: Migrate WTF::Vector::append() to ::push_back() [part 13 of N] (Closed)
Patch Set: Created 3 years, 11 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
OLDNEW
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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 const Dictionary& mandatoryConstraintsDictionary, 157 const Dictionary& mandatoryConstraintsDictionary,
158 Vector<NameValueStringConstraint>& mandatory) { 158 Vector<NameValueStringConstraint>& mandatory) {
159 DummyExceptionStateForTesting exceptionState; 159 DummyExceptionStateForTesting exceptionState;
160 const HashMap<String, String>& mandatoryConstraintsHashMap = 160 const HashMap<String, String>& mandatoryConstraintsHashMap =
161 mandatoryConstraintsDictionary.getOwnPropertiesAsStringHashMap( 161 mandatoryConstraintsDictionary.getOwnPropertiesAsStringHashMap(
162 exceptionState); 162 exceptionState);
163 if (exceptionState.hadException()) 163 if (exceptionState.hadException())
164 return false; 164 return false;
165 165
166 for (const auto& iter : mandatoryConstraintsHashMap) 166 for (const auto& iter : mandatoryConstraintsHashMap)
167 mandatory.append(NameValueStringConstraint(iter.key, iter.value)); 167 mandatory.push_back(NameValueStringConstraint(iter.key, iter.value));
168 return true; 168 return true;
169 } 169 }
170 170
171 static bool parseOptionalConstraintsVectorElement( 171 static bool parseOptionalConstraintsVectorElement(
172 const Dictionary& constraint, 172 const Dictionary& constraint,
173 Vector<NameValueStringConstraint>& optionalConstraintsVector) { 173 Vector<NameValueStringConstraint>& optionalConstraintsVector) {
174 DummyExceptionStateForTesting exceptionState; 174 DummyExceptionStateForTesting exceptionState;
175 const Vector<String>& localNames = 175 const Vector<String>& localNames =
176 constraint.getPropertyNames(exceptionState); 176 constraint.getPropertyNames(exceptionState);
177 if (exceptionState.hadException()) 177 if (exceptionState.hadException())
178 return false; 178 return false;
179 if (localNames.size() != 1) 179 if (localNames.size() != 1)
180 return false; 180 return false;
181 const String& key = localNames[0]; 181 const String& key = localNames[0];
182 String value; 182 String value;
183 bool ok = DictionaryHelper::get(constraint, key, value); 183 bool ok = DictionaryHelper::get(constraint, key, value);
184 if (!ok) 184 if (!ok)
185 return false; 185 return false;
186 optionalConstraintsVector.append(NameValueStringConstraint(key, value)); 186 optionalConstraintsVector.push_back(NameValueStringConstraint(key, value));
187 return true; 187 return true;
188 } 188 }
189 189
190 // Old style parser. Deprecated. 190 // Old style parser. Deprecated.
191 static bool parse(const Dictionary& constraintsDictionary, 191 static bool parse(const Dictionary& constraintsDictionary,
192 Vector<NameValueStringConstraint>& optional, 192 Vector<NameValueStringConstraint>& optional,
193 Vector<NameValueStringConstraint>& mandatory) { 193 Vector<NameValueStringConstraint>& mandatory) {
194 if (constraintsDictionary.isUndefinedOrNull()) 194 if (constraintsDictionary.isUndefinedOrNull())
195 return true; 195 return true;
196 196
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 return constraints; 462 return constraints;
463 // We ignore unknow names and syntax errors in optional constraints. 463 // We ignore unknow names and syntax errors in optional constraints.
464 MediaErrorState ignoredErrorState; 464 MediaErrorState ignoredErrorState;
465 Vector<WebMediaTrackConstraintSet> advancedVector; 465 Vector<WebMediaTrackConstraintSet> advancedVector;
466 for (const auto& optionalConstraint : optional) { 466 for (const auto& optionalConstraint : optional) {
467 WebMediaTrackConstraintSet advancedElement; 467 WebMediaTrackConstraintSet advancedElement;
468 Vector<NameValueStringConstraint> elementAsList(1, optionalConstraint); 468 Vector<NameValueStringConstraint> elementAsList(1, optionalConstraint);
469 parseOldStyleNames(context, elementAsList, false, advancedElement, 469 parseOldStyleNames(context, elementAsList, false, advancedElement,
470 ignoredErrorState); 470 ignoredErrorState);
471 if (!advancedElement.isEmpty()) 471 if (!advancedElement.isEmpty())
472 advancedVector.append(advancedElement); 472 advancedVector.push_back(advancedElement);
473 } 473 }
474 constraints.initialize(basic, advancedVector); 474 constraints.initialize(basic, advancedVector);
475 return constraints; 475 return constraints;
476 } 476 }
477 477
478 // Deprecated. 478 // Deprecated.
479 WebMediaConstraints create(ExecutionContext* context, 479 WebMediaConstraints create(ExecutionContext* context,
480 const Dictionary& constraintsDictionary, 480 const Dictionary& constraintsDictionary,
481 MediaErrorState& errorState) { 481 MediaErrorState& errorState) {
482 Vector<NameValueStringConstraint> optional; 482 Vector<NameValueStringConstraint> optional;
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
677 WebMediaConstraints constraints; 677 WebMediaConstraints constraints;
678 WebMediaTrackConstraintSet constraintBuffer; 678 WebMediaTrackConstraintSet constraintBuffer;
679 Vector<WebMediaTrackConstraintSet> advancedBuffer; 679 Vector<WebMediaTrackConstraintSet> advancedBuffer;
680 copyConstraintSet(constraintsIn, NakedValueDisposition::kTreatAsIdeal, 680 copyConstraintSet(constraintsIn, NakedValueDisposition::kTreatAsIdeal,
681 constraintBuffer); 681 constraintBuffer);
682 if (constraintsIn.hasAdvanced()) { 682 if (constraintsIn.hasAdvanced()) {
683 for (const auto& element : constraintsIn.advanced()) { 683 for (const auto& element : constraintsIn.advanced()) {
684 WebMediaTrackConstraintSet advancedElement; 684 WebMediaTrackConstraintSet advancedElement;
685 copyConstraintSet(element, NakedValueDisposition::kTreatAsExact, 685 copyConstraintSet(element, NakedValueDisposition::kTreatAsExact,
686 advancedElement); 686 advancedElement);
687 advancedBuffer.append(advancedElement); 687 advancedBuffer.push_back(advancedElement);
688 } 688 }
689 } 689 }
690 constraints.initialize(constraintBuffer, advancedBuffer); 690 constraints.initialize(constraintBuffer, advancedBuffer);
691 return constraints; 691 return constraints;
692 } 692 }
693 693
694 WebMediaConstraints create(ExecutionContext* context, 694 WebMediaConstraints create(ExecutionContext* context,
695 const MediaTrackConstraints& constraintsIn, 695 const MediaTrackConstraints& constraintsIn,
696 MediaErrorState& errorState) { 696 MediaErrorState& errorState) {
697 WebMediaConstraints standardForm = convertConstraintsToWeb(constraintsIn); 697 WebMediaConstraints standardForm = convertConstraintsToWeb(constraintsIn);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 } 806 }
807 return outputUnion; 807 return outputUnion;
808 } 808 }
809 809
810 StringOrStringSequence convertStringSequence( 810 StringOrStringSequence convertStringSequence(
811 const WebVector<WebString>& input) { 811 const WebVector<WebString>& input) {
812 StringOrStringSequence theStrings; 812 StringOrStringSequence theStrings;
813 if (input.size() > 1) { 813 if (input.size() > 1) {
814 Vector<String> buffer; 814 Vector<String> buffer;
815 for (const auto& scanner : input) 815 for (const auto& scanner : input)
816 buffer.append(scanner); 816 buffer.push_back(scanner);
817 theStrings.setStringSequence(buffer); 817 theStrings.setStringSequence(buffer);
818 } else if (input.size() > 0) { 818 } else if (input.size() > 0) {
819 theStrings.setString(input[0]); 819 theStrings.setString(input[0]);
820 } 820 }
821 return theStrings; 821 return theStrings;
822 } 822 }
823 823
824 StringOrStringSequenceOrConstrainDOMStringParameters convertString( 824 StringOrStringSequenceOrConstrainDOMStringParameters convertString(
825 const StringConstraint& input, 825 const StringConstraint& input,
826 NakedValueDisposition nakedTreatment) { 826 NakedValueDisposition nakedTreatment) {
827 StringOrStringSequenceOrConstrainDOMStringParameters outputUnion; 827 StringOrStringSequenceOrConstrainDOMStringParameters outputUnion;
828 if (useNakedNonNumeric(input, nakedTreatment)) { 828 if (useNakedNonNumeric(input, nakedTreatment)) {
829 WebVector<WebString> inputBuffer( 829 WebVector<WebString> inputBuffer(
830 getNakedValue<WebVector<WebString>>(input, nakedTreatment)); 830 getNakedValue<WebVector<WebString>>(input, nakedTreatment));
831 if (inputBuffer.size() > 1) { 831 if (inputBuffer.size() > 1) {
832 Vector<String> buffer; 832 Vector<String> buffer;
833 for (const auto& scanner : inputBuffer) 833 for (const auto& scanner : inputBuffer)
834 buffer.append(scanner); 834 buffer.push_back(scanner);
835 outputUnion.setStringSequence(buffer); 835 outputUnion.setStringSequence(buffer);
836 } else if (inputBuffer.size() > 0) { 836 } else if (inputBuffer.size() > 0) {
837 outputUnion.setString(inputBuffer[0]); 837 outputUnion.setString(inputBuffer[0]);
838 } 838 }
839 } else if (!input.isEmpty()) { 839 } else if (!input.isEmpty()) {
840 ConstrainDOMStringParameters output; 840 ConstrainDOMStringParameters output;
841 if (input.hasExact()) 841 if (input.hasExact())
842 output.setExact(convertStringSequence(input.exact())); 842 output.setExact(convertStringSequence(input.exact()));
843 if (input.hasIdeal()) 843 if (input.hasIdeal())
844 output.setIdeal(convertStringSequence(input.ideal())); 844 output.setIdeal(convertStringSequence(input.ideal()));
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 void convertConstraints(const WebMediaConstraints& input, 903 void convertConstraints(const WebMediaConstraints& input,
904 MediaTrackConstraints& output) { 904 MediaTrackConstraints& output) {
905 if (input.isNull()) 905 if (input.isNull())
906 return; 906 return;
907 convertConstraintSet(input.basic(), NakedValueDisposition::kTreatAsIdeal, 907 convertConstraintSet(input.basic(), NakedValueDisposition::kTreatAsIdeal,
908 output); 908 output);
909 HeapVector<MediaTrackConstraintSet> advancedVector; 909 HeapVector<MediaTrackConstraintSet> advancedVector;
910 for (const auto& it : input.advanced()) { 910 for (const auto& it : input.advanced()) {
911 MediaTrackConstraintSet element; 911 MediaTrackConstraintSet element;
912 convertConstraintSet(it, NakedValueDisposition::kTreatAsExact, element); 912 convertConstraintSet(it, NakedValueDisposition::kTreatAsExact, element);
913 advancedVector.append(element); 913 advancedVector.push_back(element);
914 } 914 }
915 if (!advancedVector.isEmpty()) 915 if (!advancedVector.isEmpty())
916 output.setAdvanced(advancedVector); 916 output.setAdvanced(advancedVector);
917 } 917 }
918 918
919 } // namespace MediaConstraintsImpl 919 } // namespace MediaConstraintsImpl
920 } // namespace blink 920 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698