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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 28 matching lines...) Expand all Loading... |
39 namespace blink { | 39 namespace blink { |
40 | 40 |
41 namespace { | 41 namespace { |
42 | 42 |
43 template <typename T> | 43 template <typename T> |
44 void maybeEmitNamedValue(StringBuilder& builder, bool emit, const char* name, T
value) | 44 void maybeEmitNamedValue(StringBuilder& builder, bool emit, const char* name, T
value) |
45 { | 45 { |
46 if (!emit) | 46 if (!emit) |
47 return; | 47 return; |
48 if (builder.length() > 1) | 48 if (builder.length() > 1) |
49 builder.append(", "); | 49 builder.appendLiteral(", "); |
50 builder.append(name); | 50 builder.append(name); |
51 builder.append(": "); | 51 builder.appendLiteral(": "); |
52 builder.appendNumber(value); | 52 builder.appendNumber(value); |
53 } | 53 } |
54 | 54 |
55 void maybeEmitNamedBoolean(StringBuilder& builder, bool emit, const char* name,
bool value) | 55 void maybeEmitNamedBoolean(StringBuilder& builder, bool emit, const char* name,
bool value) |
56 { | 56 { |
57 if (!emit) | 57 if (!emit) |
58 return; | 58 return; |
59 if (builder.length() > 1) | 59 if (builder.length() > 1) |
60 builder.append(", "); | 60 builder.appendLiteral(", "); |
61 builder.append(name); | 61 builder.append(name); |
62 builder.append(": "); | 62 builder.appendLiteral(": "); |
63 if (value) | 63 if (value) |
64 builder.append("true"); | 64 builder.appendLiteral("true"); |
65 else | 65 else |
66 builder.append("false"); | 66 builder.appendLiteral("false"); |
67 } | 67 } |
68 | 68 |
69 } // namespace | 69 } // namespace |
70 | 70 |
71 class WebMediaConstraintsPrivate final : public RefCounted<WebMediaConstraintsPr
ivate> { | 71 class WebMediaConstraintsPrivate final : public RefCounted<WebMediaConstraintsPr
ivate> { |
72 public: | 72 public: |
73 static PassRefPtr<WebMediaConstraintsPrivate> create(); | 73 static PassRefPtr<WebMediaConstraintsPrivate> create(); |
74 static PassRefPtr<WebMediaConstraintsPrivate> create(const WebMediaTrackCons
traintSet& basic, const WebVector<WebMediaTrackConstraintSet>& advanced); | 74 static PassRefPtr<WebMediaConstraintsPrivate> create(const WebMediaTrackCons
traintSet& basic, const WebVector<WebMediaTrackConstraintSet>& advanced); |
75 | 75 |
76 bool isEmpty() const; | 76 bool isEmpty() const; |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 } | 121 } |
122 | 122 |
123 const String WebMediaConstraintsPrivate::toString() const | 123 const String WebMediaConstraintsPrivate::toString() const |
124 { | 124 { |
125 StringBuilder builder; | 125 StringBuilder builder; |
126 if (!isEmpty()) { | 126 if (!isEmpty()) { |
127 builder.append('{'); | 127 builder.append('{'); |
128 builder.append(basic().toString()); | 128 builder.append(basic().toString()); |
129 if (!advanced().isEmpty()) { | 129 if (!advanced().isEmpty()) { |
130 if (builder.length() > 1) | 130 if (builder.length() > 1) |
131 builder.append(", "); | 131 builder.appendLiteral(", "); |
132 builder.append("advanced: ["); | 132 builder.appendLiteral("advanced: ["); |
133 bool first = true; | 133 bool first = true; |
134 for (const auto& constraintSet : advanced()) { | 134 for (const auto& constraintSet : advanced()) { |
135 if (!first) | 135 if (!first) |
136 builder.append(", "); | 136 builder.appendLiteral(", "); |
137 builder.append('{'); | 137 builder.append('{'); |
138 builder.append(constraintSet.toString()); | 138 builder.append(constraintSet.toString()); |
139 builder.append('}'); | 139 builder.append('}'); |
140 first = false; | 140 first = false; |
141 } | 141 } |
142 builder.append(']'); | 142 builder.append(']'); |
143 } | 143 } |
144 builder.append('}'); | 144 builder.append('}'); |
145 } | 145 } |
146 return builder.toString(); | 146 return builder.toString(); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 const WebVector<WebString>& StringConstraint::ideal() const | 295 const WebVector<WebString>& StringConstraint::ideal() const |
296 { | 296 { |
297 return m_ideal; | 297 return m_ideal; |
298 } | 298 } |
299 | 299 |
300 WebString StringConstraint::toString() const | 300 WebString StringConstraint::toString() const |
301 { | 301 { |
302 StringBuilder builder; | 302 StringBuilder builder; |
303 builder.append('{'); | 303 builder.append('{'); |
304 if (!m_ideal.isEmpty()) { | 304 if (!m_ideal.isEmpty()) { |
305 builder.append("ideal: ["); | 305 builder.appendLiteral("ideal: ["); |
306 bool first = true; | 306 bool first = true; |
307 for (const auto& iter : m_ideal) { | 307 for (const auto& iter : m_ideal) { |
308 if (!first) | 308 if (!first) |
309 builder.append(", "); | 309 builder.appendLiteral(", "); |
310 builder.append('"'); | 310 builder.append('"'); |
311 builder.append(iter); | 311 builder.append(iter); |
312 builder.append('"'); | 312 builder.append('"'); |
313 first = false; | 313 first = false; |
314 } | 314 } |
315 builder.append(']'); | 315 builder.append(']'); |
316 } | 316 } |
317 if (!m_exact.isEmpty()) { | 317 if (!m_exact.isEmpty()) { |
318 if (builder.length() > 1) | 318 if (builder.length() > 1) |
319 builder.append(", "); | 319 builder.appendLiteral(", "); |
320 builder.append("exact: ["); | 320 builder.appendLiteral("exact: ["); |
321 bool first = true; | 321 bool first = true; |
322 for (const auto& iter : m_exact) { | 322 for (const auto& iter : m_exact) { |
323 if (!first) | 323 if (!first) |
324 builder.append(", "); | 324 builder.appendLiteral(", "); |
325 builder.append('"'); | 325 builder.append('"'); |
326 builder.append(iter); | 326 builder.append(iter); |
327 builder.append('"'); | 327 builder.append('"'); |
328 } | 328 } |
329 builder.append(']'); | 329 builder.append(']'); |
330 } | 330 } |
331 builder.append('}'); | 331 builder.append('}'); |
332 return builder.toString(); | 332 return builder.toString(); |
333 } | 333 } |
334 | 334 |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 return hasMandatoryOutsideSet(std::vector<std::string>(), dummyString); | 481 return hasMandatoryOutsideSet(std::vector<std::string>(), dummyString); |
482 } | 482 } |
483 | 483 |
484 WebString WebMediaTrackConstraintSet::toString() const | 484 WebString WebMediaTrackConstraintSet::toString() const |
485 { | 485 { |
486 StringBuilder builder; | 486 StringBuilder builder; |
487 bool first = true; | 487 bool first = true; |
488 for (const auto& constraint : allConstraints()) { | 488 for (const auto& constraint : allConstraints()) { |
489 if (!constraint->isEmpty()) { | 489 if (!constraint->isEmpty()) { |
490 if (!first) | 490 if (!first) |
491 builder.append(", "); | 491 builder.appendLiteral(", "); |
492 builder.append(constraint->name()); | 492 builder.append(constraint->name()); |
493 builder.append(": "); | 493 builder.appendLiteral(": "); |
494 builder.append(constraint->toString()); | 494 builder.append(constraint->toString()); |
495 first = false; | 495 first = false; |
496 } | 496 } |
497 } | 497 } |
498 return builder.toString(); | 498 return builder.toString(); |
499 } | 499 } |
500 | 500 |
501 // WebMediaConstraints | 501 // WebMediaConstraints |
502 | 502 |
503 void WebMediaConstraints::assign(const WebMediaConstraints& other) | 503 void WebMediaConstraints::assign(const WebMediaConstraints& other) |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 } | 540 } |
541 | 541 |
542 const WebString WebMediaConstraints::toString() const | 542 const WebString WebMediaConstraints::toString() const |
543 { | 543 { |
544 if (isNull()) | 544 if (isNull()) |
545 return WebString(""); | 545 return WebString(""); |
546 return m_private->toString(); | 546 return m_private->toString(); |
547 } | 547 } |
548 | 548 |
549 } // namespace blink | 549 } // namespace blink |
OLD | NEW |