xref: /aosp_15_r20/external/cronet/base/trace_event/trace_id_helper.cc (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2020 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "base/trace_event/trace_id_helper.h"
6 #include "base/atomic_sequence_num.h"
7 #include "base/rand_util.h"
8 
9 namespace base {
10 namespace trace_event {
11 
GetNextGlobalTraceId()12 uint64_t GetNextGlobalTraceId() {
13   static const uint64_t kPerProcessRandomValue = base::RandUint64();
14   static base::AtomicSequenceNumber counter;
15   return kPerProcessRandomValue ^ static_cast<uint64_t>(counter.GetNext());
16 }
17 
18 }  // namespace trace_event
19 }  // namespace base
20