OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8ProfilerAgentImpl_h | 5 #ifndef V8ProfilerAgentImpl_h |
6 #define V8ProfilerAgentImpl_h | 6 #define V8ProfilerAgentImpl_h |
7 | 7 |
8 #include "platform/inspector_protocol/Allocator.h" | 8 #include "platform/inspector_protocol/Allocator.h" |
9 #include "platform/inspector_protocol/String16.h" | 9 #include "platform/inspector_protocol/String16.h" |
10 #include "platform/v8_inspector/protocol/Profiler.h" | 10 #include "platform/v8_inspector/protocol/Profiler.h" |
11 | 11 |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 namespace v8 { | 14 namespace v8 { |
| 15 class CpuProfiler; |
15 class Isolate; | 16 class Isolate; |
16 } | 17 } |
17 | 18 |
18 namespace blink { | 19 namespace blink { |
19 | 20 |
20 class V8InspectorSessionImpl; | 21 class V8InspectorSessionImpl; |
21 | 22 |
22 class V8ProfilerAgentImpl : public protocol::Profiler::Backend { | 23 class V8ProfilerAgentImpl : public protocol::Profiler::Backend { |
23 PROTOCOL_DISALLOW_COPY(V8ProfilerAgentImpl); | 24 PROTOCOL_DISALLOW_COPY(V8ProfilerAgentImpl); |
24 public: | 25 public: |
25 V8ProfilerAgentImpl(V8InspectorSessionImpl*, protocol::FrontendChannel*, pro
tocol::DictionaryValue* state); | 26 V8ProfilerAgentImpl(V8InspectorSessionImpl*, protocol::FrontendChannel*, pro
tocol::DictionaryValue* state); |
26 ~V8ProfilerAgentImpl() override; | 27 ~V8ProfilerAgentImpl() override; |
27 | 28 |
28 bool enabled() const { return m_enabled; } | 29 bool enabled() const { return m_enabled; } |
29 void restore(); | 30 void restore(); |
30 | 31 |
31 void enable(ErrorString*) override; | 32 void enable(ErrorString*) override; |
32 void disable(ErrorString*) override; | 33 void disable(ErrorString*) override; |
33 void setSamplingInterval(ErrorString*, int) override; | 34 void setSamplingInterval(ErrorString*, int) override; |
34 void start(ErrorString*) override; | 35 void start(ErrorString*) override; |
35 void stop(ErrorString*, std::unique_ptr<protocol::Profiler::CPUProfile>*) ov
erride; | 36 void stop(ErrorString*, std::unique_ptr<protocol::Profiler::CPUProfile>*) ov
erride; |
36 | 37 |
37 void consoleProfile(const String16& title); | 38 void consoleProfile(const String16& title); |
38 void consoleProfileEnd(const String16& title); | 39 void consoleProfileEnd(const String16& title); |
39 | 40 |
40 private: | 41 private: |
41 String16 nextProfileId(); | 42 String16 nextProfileId(); |
| 43 v8::CpuProfiler* profiler(); |
42 | 44 |
43 void startProfiling(const String16& title); | 45 void startProfiling(const String16& title); |
44 std::unique_ptr<protocol::Profiler::CPUProfile> stopProfiling(const String16
& title, bool serialize); | 46 std::unique_ptr<protocol::Profiler::CPUProfile> stopProfiling(const String16
& title, bool serialize); |
45 | 47 |
46 bool isRecording() const; | 48 bool isRecording() const; |
47 | 49 |
48 V8InspectorSessionImpl* m_session; | 50 V8InspectorSessionImpl* m_session; |
49 v8::Isolate* m_isolate; | 51 v8::Isolate* m_isolate; |
| 52 v8::CpuProfiler* m_profiler; |
50 protocol::DictionaryValue* m_state; | 53 protocol::DictionaryValue* m_state; |
51 protocol::Profiler::Frontend m_frontend; | 54 protocol::Profiler::Frontend m_frontend; |
52 bool m_enabled; | 55 bool m_enabled; |
53 bool m_recordingCPUProfile; | 56 bool m_recordingCPUProfile; |
54 class ProfileDescriptor; | 57 class ProfileDescriptor; |
55 std::vector<ProfileDescriptor> m_startedProfiles; | 58 std::vector<ProfileDescriptor> m_startedProfiles; |
56 String16 m_frontendInitiatedProfileId; | 59 String16 m_frontendInitiatedProfileId; |
57 }; | 60 }; |
58 | 61 |
59 } // namespace blink | 62 } // namespace blink |
60 | 63 |
61 | |
62 #endif // !defined(V8ProfilerAgentImpl_h) | 64 #endif // !defined(V8ProfilerAgentImpl_h) |
OLD | NEW |