blob: da540b773ded996f4006adc7c3d3d87423dd9ec9 (
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
// 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_TIMING_PROFILER_GROUP_H_
#define THIRD_PARTY_BLINK_RENDERER_CORE_TIMING_PROFILER_GROUP_H_
#include "base/macros.h"
#include "base/time/time.h"
#include "third_party/blink/renderer/core/core_export.h"
#include "third_party/blink/renderer/platform/bindings/v8_per_isolate_data.h"
#include "third_party/blink/renderer/platform/heap/heap_allocator.h"
#include "third_party/blink/renderer/platform/heap/member.h"
#include "third_party/blink/renderer/platform/wtf/forward.h"
#include "v8/include/v8-profiler.h"
#include "v8/include/v8.h"
namespace blink {
class ExceptionState;
class Profiler;
class ProfilerInitOptions;
class ScriptPromiseResolver;
class ScriptState;
// A ProfilerGroup represents a set of profilers sharing an underlying
// v8::CpuProfiler attached to a common isolate.
class CORE_EXPORT ProfilerGroup
: public V8PerIsolateData::GarbageCollectedData {
public:
static ProfilerGroup* From(v8::Isolate*);
static base::TimeDelta GetBaseSampleInterval();
ProfilerGroup(v8::Isolate* isolate);
~ProfilerGroup() override;
Profiler* CreateProfiler(ScriptState* script_state,
const ProfilerInitOptions&,
base::TimeTicks time_origin,
ExceptionState&);
void WillBeDestroyed() override;
void Trace(Visitor*) const override;
private:
friend class Profiler;
void InitV8Profiler();
void TeardownV8Profiler();
void StopProfiler(ScriptState*, Profiler*, ScriptPromiseResolver*);
// Cancels a profiler, discarding its associated trace.
void CancelProfiler(Profiler*);
// Asynchronously cancels a profiler. Invoked on Profiler destruction.
void CancelProfilerAsync(ScriptState*, Profiler*);
// Internal implementation of cancel.
void CancelProfilerImpl(String profiler_id);
// Generates an unused string identifier to use for a new profiling session.
String NextProfilerId();
v8::Isolate* const isolate_;
v8::CpuProfiler* cpu_profiler_;
int next_profiler_id_;
int num_active_profilers_;
HeapHashSet<WeakMember<Profiler>> profilers_;
DISALLOW_COPY_AND_ASSIGN(ProfilerGroup);
};
} // namespace blink
#endif // THIRD_PARTY_BLINK_RENDERER_CORE_TIMING_PROFILER_GROUP_H_
|