Index: webrtc/common_types.cc |
diff --git a/webrtc/common_types.cc b/webrtc/common_types.cc |
index b9c4737aeb511627bd1b3697269ef047d8a11ad1..961dd6f15921a0ac8ea58b34089b4068f97aa3b4 100644 |
--- a/webrtc/common_types.cc |
+++ b/webrtc/common_types.cc |
@@ -11,6 +11,7 @@ |
#include "webrtc/common_types.h" |
#include <string.h> |
+#include <algorithm> |
#include <limits> |
#include <type_traits> |
@@ -23,9 +24,14 @@ StreamDataCounters::StreamDataCounters() : first_packet_time_ms(-1) {} |
constexpr size_t StreamId::kMaxSize; |
+bool StreamId::IsLegalName(const char* data, size_t size) { |
+ return (size <= kMaxSize && size > 0 && |
+ std::all_of(data, data + size, isalnum)); |
danilchap
2017/06/02 17:42:20
may be remove () around the expression.
https://go
eladalon
2017/06/02 19:44:05
That link seems to suggest that the parenthesis ar
danilchap
2017/06/07 13:45:41
yep, in this case it is ok, thus 'may be'
|
+} |
+ |
void StreamId::Set(const char* data, size_t size) { |
// If |data| contains \0, the stream id size might become less than |size|. |
- RTC_DCHECK_LE(size, kMaxSize); |
+ RTC_DCHECK_LE(size, kMaxSize); // TODO(eladalon): IsLegalName? |
danilchap
2017/06/02 17:42:20
probably not:
Set is called by parser too. While p
eladalon
2017/06/02 19:44:05
My intention with this TODO is to come back to thi
danilchap
2017/06/07 13:45:41
I prefer to think about StreamId as a special impl
|
memcpy(value_, data, size); |
if (size < kMaxSize) |
value_[size] = 0; |