trace_id_helper.cc 597 B

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