summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/probe/async_task_id.h
blob: 12beaf45743408560cb92df1e83226824de5d5fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef THIRD_PARTY_BLINK_RENDERER_CORE_PROBE_ASYNC_TASK_ID_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_PROBE_ASYNC_TASK_ID_H_

#include <cstdint>

#include "base/trace_event/trace_id_helper.h"
#include "third_party/abseil-cpp/absl/types/optional.h"
#include "third_party/blink/renderer/core/core_export.h"

namespace blink {

namespace probe {

// The core probes use this class as an identifier for an async task.
class CORE_EXPORT AsyncTaskId {
 public:
  AsyncTaskId() = default;

  // Not copyable or movable, since the address of an AsyncTaskId is what's used
  // to keep track of them.
  AsyncTaskId(const AsyncTaskId&) = delete;
  AsyncTaskId& operator=(const AsyncTaskId&) = delete;

  void SetAdTask() { ad_task_ = true; }
  bool IsAdTask() const { return ad_task_; }

  // Trace id for this task.
  absl::optional<uint64_t> GetTraceId() const { return trace_id_; }
  void SetTraceId(uint64_t trace_id) { trace_id_ = trace_id; }

 private:
  bool ad_task_ = false;
  absl::optional<uint64_t> trace_id_;
};

}  // namespace probe

}  // namespace blink

#endif  // THIRD_PARTY_BLINK_RENDERER_CORE_PROBE_ASYNC_TASK_ID_H_