1926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)/* 2926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * Copyright (C) 2013 Google Inc. All rights reserved. 3926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * 4926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * Redistribution and use in source and binary forms, with or without 5926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * modification, are permitted provided that the following conditions are 6926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * met: 7926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * 8926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * * Redistributions of source code must retain the above copyright 9926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * notice, this list of conditions and the following disclaimer. 10926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * * Redistributions in binary form must reproduce the above 11926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * copyright notice, this list of conditions and the following disclaimer 12926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * in the documentation and/or other materials provided with the 13926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * distribution. 14926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * * Neither the name of Google Inc. nor the names of its 15926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * contributors may be used to endorse or promote products derived from 16926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * this software without specific prior written permission. 17926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * 18926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 21926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 22926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) */ 30926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 31926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)#ifndef InspectorHeapProfilerAgent_h 32926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)#define InspectorHeapProfilerAgent_h 33926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 345d92fedcae5e801a8b224de090094f2d9df0b54aTorne (Richard Coles)#include "core/InspectorFrontend.h" 3553e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)#include "core/inspector/InspectorBaseAgent.h" 36e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch#include "wtf/Forward.h" 37e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch#include "wtf/HashMap.h" 38e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch#include "wtf/Noncopyable.h" 39e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch#include "wtf/OwnPtr.h" 40e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch#include "wtf/PassOwnPtr.h" 41e69819bd8e388ea4ad1636a19aa6b2eed4952191Ben Murdoch#include "wtf/text/WTFString.h" 42926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 43c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)namespace blink { 44926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 45926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)class InjectedScriptManager; 4653e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles)class HeapStatsUpdateTask; 47926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)class ScriptHeapSnapshot; 48926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 49926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)typedef String ErrorString; 50926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 5109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles)class InspectorHeapProfilerAgent FINAL : public InspectorBaseAgent<InspectorHeapProfilerAgent>, public InspectorBackendDispatcher::HeapProfilerCommandHandler { 52c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) WTF_MAKE_NONCOPYABLE(InspectorHeapProfilerAgent); 53c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; 54926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)public: 55c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) static PassOwnPtrWillBeRawPtr<InspectorHeapProfilerAgent> create(InjectedScriptManager*); 56926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) virtual ~InspectorHeapProfilerAgent(); 57c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) virtual void trace(Visitor*) OVERRIDE; 58926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 5909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) virtual void collectGarbage(ErrorString*) OVERRIDE; 60926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 6109380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) virtual void enable(ErrorString*) OVERRIDE; 6209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) virtual void disable(ErrorString*) OVERRIDE; 6309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) virtual void startTrackingHeapObjects(ErrorString*, const bool* trackAllocations) OVERRIDE; 6409380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) virtual void stopTrackingHeapObjects(ErrorString*, const bool* reportProgress) OVERRIDE; 65926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 6609380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) virtual void setFrontend(InspectorFrontend*) OVERRIDE; 6709380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) virtual void clearFrontend() OVERRIDE; 6809380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) virtual void restore() OVERRIDE; 69926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 7009380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) virtual void takeHeapSnapshot(ErrorString*, const bool* reportProgress) OVERRIDE; 71926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 7209380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) virtual void getObjectByHeapObjectId(ErrorString*, const String& heapSnapshotObjectId, const String* objectGroup, RefPtr<TypeBuilder::Runtime::RemoteObject>& result) OVERRIDE; 7309380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) virtual void getHeapObjectId(ErrorString*, const String& objectId, String* heapSnapshotObjectId) OVERRIDE; 74926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 75926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)private: 7653e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) class HeapStatsStream; 7753e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) class HeapStatsUpdateTask; 7853e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) 7909380295ba73501a205346becac22c6978e4671dTorne (Richard Coles) explicit InspectorHeapProfilerAgent(InjectedScriptManager*); 80926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 8153e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) void requestHeapStatsUpdate(); 8253e740f4a82e17f3ae59772501622dc354e42336Torne (Richard Coles) void pushHeapStatsUpdate(const uint32_t* const data, const int size); 83926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 84d5428f32f5d1719f774f62e19147104ca245a3abTorne (Richard Coles) void startTrackingHeapObjectsInternal(bool trackAllocations); 85a854de003a23bf3c7f95ec0f8154ada64092ff5cTorne (Richard Coles) void stopTrackingHeapObjectsInternal(); 86926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 87c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) RawPtrWillBeMember<InjectedScriptManager> m_injectedScriptManager; 88926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) InspectorFrontend::HeapProfiler* m_frontend; 89926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) unsigned m_nextUserInitiatedHeapSnapshotNumber; 90c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles) OwnPtrWillBeMember<HeapStatsUpdateTask> m_heapStatsUpdateTask; 91926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)}; 92926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 93c1847b1379d12d0e05df27436bf19a9b1bf12deaTorne (Richard Coles)} // namespace blink 94926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 95926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles) 96926b001d589ce2f10facb93dd4b87578ea35a855Torne (Richard Coles)#endif // !defined(InspectorHeapProfilerAgent_h) 97