RTCStatsIdGenerator.h (1086B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 3 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 5 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 6 7 #ifndef _RTCSTATSIDGENERATOR_H_ 8 #define _RTCSTATSIDGENERATOR_H_ 9 10 #include <map> 11 12 #include "mozilla/UniquePtr.h" 13 #include "nsISupportsImpl.h" 14 #include "nsString.h" 15 #include "nsTArray.h" 16 17 namespace mozilla { 18 namespace dom { 19 struct RTCStatsCollection; 20 } // namespace dom 21 22 class RTCStatsIdGenerator { 23 public: 24 RTCStatsIdGenerator(); 25 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(RTCStatsIdGenerator); 26 27 void RewriteIds(nsTArray<UniquePtr<dom::RTCStatsCollection>> aFromStats, 28 dom::RTCStatsCollection* aIntoReport); 29 30 private: 31 virtual ~RTCStatsIdGenerator() {}; 32 nsString Id(const nsString& aKey); 33 nsString Generate(); 34 35 const uint64_t mSalt; 36 uint64_t mCounter; 37 std::map<nsString, nsString> mAllocated; 38 }; 39 40 } // namespace mozilla 41 #endif