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

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

Issue 373423002: Split Dictionary's get and convert into DictionaryHelper. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 return false; 72 return false;
73 73
74 HashMap<String, String>::const_iterator iter = mandatoryConstraintsHashM ap.begin(); 74 HashMap<String, String>::const_iterator iter = mandatoryConstraintsHashM ap.begin();
75 for (; iter != mandatoryConstraintsHashMap.end(); ++iter) 75 for (; iter != mandatoryConstraintsHashMap.end(); ++iter)
76 mandatoryConstraintsVector.append(blink::WebMediaConstraint(iter->ke y, iter->value)); 76 mandatoryConstraintsVector.append(blink::WebMediaConstraint(iter->ke y, iter->value));
77 } 77 }
78 78
79 Vector<blink::WebMediaConstraint> optionalConstraintsVector; 79 Vector<blink::WebMediaConstraint> optionalConstraintsVector;
80 if (names.contains(optionalName)) { 80 if (names.contains(optionalName)) {
81 ArrayValue optionalConstraints; 81 ArrayValue optionalConstraints;
82 bool ok = constraintsDictionary.get(optionalName, optionalConstraints); 82 bool ok = DictionaryHelper::get(constraintsDictionary, optionalName, opt ionalConstraints);
83 if (!ok || optionalConstraints.isUndefinedOrNull()) 83 if (!ok || optionalConstraints.isUndefinedOrNull())
84 return false; 84 return false;
85 85
86 size_t numberOfConstraints; 86 size_t numberOfConstraints;
87 ok = optionalConstraints.length(numberOfConstraints); 87 ok = optionalConstraints.length(numberOfConstraints);
88 if (!ok) 88 if (!ok)
89 return false; 89 return false;
90 90
91 for (size_t i = 0; i < numberOfConstraints; ++i) { 91 for (size_t i = 0; i < numberOfConstraints; ++i) {
92 Dictionary constraint; 92 Dictionary constraint;
93 ok = optionalConstraints.get(i, constraint); 93 ok = optionalConstraints.get(i, constraint);
94 if (!ok || constraint.isUndefinedOrNull()) 94 if (!ok || constraint.isUndefinedOrNull())
95 return false; 95 return false;
96 Vector<String> localNames; 96 Vector<String> localNames;
97 constraint.getOwnPropertyNames(localNames); 97 constraint.getOwnPropertyNames(localNames);
98 if (localNames.size() != 1) 98 if (localNames.size() != 1)
99 return false; 99 return false;
100 String key = localNames[0]; 100 String key = localNames[0];
101 String value; 101 String value;
102 ok = constraint.get(key, value); 102 ok = DictionaryHelper::get(constraint, key, value);
103 if (!ok) 103 if (!ok)
104 return false; 104 return false;
105 optionalConstraintsVector.append(blink::WebMediaConstraint(key, valu e)); 105 optionalConstraintsVector.append(blink::WebMediaConstraint(key, valu e));
106 } 106 }
107 } 107 }
108 108
109 optional.assign(optionalConstraintsVector); 109 optional.assign(optionalConstraintsVector);
110 mandatory.assign(mandatoryConstraintsVector); 110 mandatory.assign(mandatoryConstraintsVector);
111 return true; 111 return true;
112 } 112 }
(...skipping 15 matching lines...) Expand all
128 128
129 blink::WebMediaConstraints create() 129 blink::WebMediaConstraints create()
130 { 130 {
131 blink::WebMediaConstraints constraints; 131 blink::WebMediaConstraints constraints;
132 constraints.initialize(); 132 constraints.initialize();
133 return constraints; 133 return constraints;
134 } 134 }
135 135
136 } // namespace MediaConstraintsImpl 136 } // namespace MediaConstraintsImpl
137 } // namespace WebCore 137 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/modules/indexeddb/IDBObjectStore.cpp ('k') | Source/modules/mediastream/RTCIceCandidate.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698