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

Side by Side Diff: content/renderer/media/webrtc/media_stream_track_metrics.cc

Issue 1547073003: Switch to standard integer types in content/renderer/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/media/webrtc/media_stream_track_metrics.h" 5 #include "content/renderer/media/webrtc/media_stream_track_metrics.h"
6 6
7 #include <inttypes.h> 7 #include <inttypes.h>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 stream_type == RECEIVED_STREAM)); 359 stream_type == RECEIVED_STREAM));
360 } else { 360 } else {
361 DCHECK_EQ(DISCONNECTED, event); 361 DCHECK_EQ(DISCONNECTED, event);
362 RenderThreadImpl::current()->Send( 362 RenderThreadImpl::current()->Send(
363 new MediaStreamTrackMetricsHost_RemoveTrack( 363 new MediaStreamTrackMetricsHost_RemoveTrack(
364 MakeUniqueId(track_id, stream_type))); 364 MakeUniqueId(track_id, stream_type)));
365 } 365 }
366 } 366 }
367 } 367 }
368 368
369 uint64 MediaStreamTrackMetrics::MakeUniqueIdImpl(uint64 pc_id, 369 uint64_t MediaStreamTrackMetrics::MakeUniqueIdImpl(uint64_t pc_id,
370 const std::string& track_id, 370 const std::string& track_id,
371 StreamType stream_type) { 371 StreamType stream_type) {
372 // We use a hash over the |track| pointer and the PeerConnection ID, 372 // We use a hash over the |track| pointer and the PeerConnection ID,
373 // plus a boolean flag indicating whether the track is remote (since 373 // plus a boolean flag indicating whether the track is remote (since
374 // you might conceivably have a remote track added back as a sent 374 // you might conceivably have a remote track added back as a sent
375 // track) as the unique ID. 375 // track) as the unique ID.
376 // 376 //
377 // We don't need a cryptographically secure hash (which MD5 should 377 // We don't need a cryptographically secure hash (which MD5 should
378 // no longer be considered), just one with virtually zero chance of 378 // no longer be considered), just one with virtually zero chance of
379 // collisions when faced with non-malicious data. 379 // collisions when faced with non-malicious data.
380 std::string unique_id_string = 380 std::string unique_id_string =
381 base::StringPrintf("%" PRIu64 " %s %d", 381 base::StringPrintf("%" PRIu64 " %s %d",
382 pc_id, 382 pc_id,
383 track_id.c_str(), 383 track_id.c_str(),
384 stream_type == RECEIVED_STREAM ? 1 : 0); 384 stream_type == RECEIVED_STREAM ? 1 : 0);
385 385
386 base::MD5Context ctx; 386 base::MD5Context ctx;
387 base::MD5Init(&ctx); 387 base::MD5Init(&ctx);
388 base::MD5Update(&ctx, unique_id_string); 388 base::MD5Update(&ctx, unique_id_string);
389 base::MD5Digest digest; 389 base::MD5Digest digest;
390 base::MD5Final(&digest, &ctx); 390 base::MD5Final(&digest, &ctx);
391 391
392 static_assert(sizeof(digest.a) > sizeof(uint64), "need a bigger digest"); 392 static_assert(sizeof(digest.a) > sizeof(uint64_t), "need a bigger digest");
393 return *reinterpret_cast<uint64*>(digest.a); 393 return *reinterpret_cast<uint64_t*>(digest.a);
394 } 394 }
395 395
396 uint64 MediaStreamTrackMetrics::MakeUniqueId(const std::string& track_id, 396 uint64_t MediaStreamTrackMetrics::MakeUniqueId(const std::string& track_id,
397 StreamType stream_type) { 397 StreamType stream_type) {
398 return MakeUniqueIdImpl( 398 return MakeUniqueIdImpl(
399 reinterpret_cast<uint64>(reinterpret_cast<void*>(this)), 399 reinterpret_cast<uint64_t>(reinterpret_cast<void*>(this)), track_id,
400 track_id,
401 stream_type); 400 stream_type);
402 } 401 }
403 402
404 } // namespace content 403 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698