11cb0ef41Sopenharmony_ci// Copyright 2016 the V8 project authors. All rights reserved. 21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be 31cb0ef41Sopenharmony_ci// found in the LICENSE file. 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci#ifndef V8_INSPECTOR_V8_HEAP_PROFILER_AGENT_IMPL_H_ 61cb0ef41Sopenharmony_ci#define V8_INSPECTOR_V8_HEAP_PROFILER_AGENT_IMPL_H_ 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ci#include <memory> 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ci#include "src/base/macros.h" 111cb0ef41Sopenharmony_ci#include "src/inspector/protocol/Forward.h" 121cb0ef41Sopenharmony_ci#include "src/inspector/protocol/HeapProfiler.h" 131cb0ef41Sopenharmony_ci 141cb0ef41Sopenharmony_cinamespace v8 { 151cb0ef41Sopenharmony_ciclass Isolate; 161cb0ef41Sopenharmony_ci} 171cb0ef41Sopenharmony_ci 181cb0ef41Sopenharmony_cinamespace v8_inspector { 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_ciclass V8InspectorSessionImpl; 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ciusing protocol::Maybe; 231cb0ef41Sopenharmony_ciusing protocol::Response; 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_ciclass V8HeapProfilerAgentImpl : public protocol::HeapProfiler::Backend { 261cb0ef41Sopenharmony_ci public: 271cb0ef41Sopenharmony_ci V8HeapProfilerAgentImpl(V8InspectorSessionImpl*, protocol::FrontendChannel*, 281cb0ef41Sopenharmony_ci protocol::DictionaryValue* state); 291cb0ef41Sopenharmony_ci ~V8HeapProfilerAgentImpl() override; 301cb0ef41Sopenharmony_ci V8HeapProfilerAgentImpl(const V8HeapProfilerAgentImpl&) = delete; 311cb0ef41Sopenharmony_ci V8HeapProfilerAgentImpl& operator=(const V8HeapProfilerAgentImpl&) = delete; 321cb0ef41Sopenharmony_ci void restore(); 331cb0ef41Sopenharmony_ci 341cb0ef41Sopenharmony_ci void collectGarbage( 351cb0ef41Sopenharmony_ci std::unique_ptr<CollectGarbageCallback> callback) override; 361cb0ef41Sopenharmony_ci 371cb0ef41Sopenharmony_ci Response enable() override; 381cb0ef41Sopenharmony_ci Response startTrackingHeapObjects(Maybe<bool> trackAllocations) override; 391cb0ef41Sopenharmony_ci Response stopTrackingHeapObjects(Maybe<bool> reportProgress, 401cb0ef41Sopenharmony_ci Maybe<bool> treatGlobalObjectsAsRoots, 411cb0ef41Sopenharmony_ci Maybe<bool> captureNumericValue) override; 421cb0ef41Sopenharmony_ci 431cb0ef41Sopenharmony_ci Response disable() override; 441cb0ef41Sopenharmony_ci 451cb0ef41Sopenharmony_ci Response takeHeapSnapshot(Maybe<bool> reportProgress, 461cb0ef41Sopenharmony_ci Maybe<bool> treatGlobalObjectsAsRoots, 471cb0ef41Sopenharmony_ci Maybe<bool> captureNumericValue) override; 481cb0ef41Sopenharmony_ci 491cb0ef41Sopenharmony_ci Response getObjectByHeapObjectId( 501cb0ef41Sopenharmony_ci const String16& heapSnapshotObjectId, Maybe<String16> objectGroup, 511cb0ef41Sopenharmony_ci std::unique_ptr<protocol::Runtime::RemoteObject>* result) override; 521cb0ef41Sopenharmony_ci Response addInspectedHeapObject( 531cb0ef41Sopenharmony_ci const String16& inspectedHeapObjectId) override; 541cb0ef41Sopenharmony_ci Response getHeapObjectId(const String16& objectId, 551cb0ef41Sopenharmony_ci String16* heapSnapshotObjectId) override; 561cb0ef41Sopenharmony_ci 571cb0ef41Sopenharmony_ci Response startSampling(Maybe<double> samplingInterval) override; 581cb0ef41Sopenharmony_ci Response stopSampling( 591cb0ef41Sopenharmony_ci std::unique_ptr<protocol::HeapProfiler::SamplingHeapProfile>*) override; 601cb0ef41Sopenharmony_ci Response getSamplingProfile( 611cb0ef41Sopenharmony_ci std::unique_ptr<protocol::HeapProfiler::SamplingHeapProfile>*) override; 621cb0ef41Sopenharmony_ci 631cb0ef41Sopenharmony_ci private: 641cb0ef41Sopenharmony_ci struct AsyncGC; 651cb0ef41Sopenharmony_ci class GCTask; 661cb0ef41Sopenharmony_ci 671cb0ef41Sopenharmony_ci void startTrackingHeapObjectsInternal(bool trackAllocations); 681cb0ef41Sopenharmony_ci void stopTrackingHeapObjectsInternal(); 691cb0ef41Sopenharmony_ci void requestHeapStatsUpdate(); 701cb0ef41Sopenharmony_ci static void onTimer(void*); 711cb0ef41Sopenharmony_ci 721cb0ef41Sopenharmony_ci V8InspectorSessionImpl* m_session; 731cb0ef41Sopenharmony_ci v8::Isolate* m_isolate; 741cb0ef41Sopenharmony_ci protocol::HeapProfiler::Frontend m_frontend; 751cb0ef41Sopenharmony_ci protocol::DictionaryValue* m_state; 761cb0ef41Sopenharmony_ci bool m_hasTimer; 771cb0ef41Sopenharmony_ci std::shared_ptr<AsyncGC> m_async_gc; 781cb0ef41Sopenharmony_ci}; 791cb0ef41Sopenharmony_ci 801cb0ef41Sopenharmony_ci} // namespace v8_inspector 811cb0ef41Sopenharmony_ci 821cb0ef41Sopenharmony_ci#endif // V8_INSPECTOR_V8_HEAP_PROFILER_AGENT_IMPL_H_ 83