| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 namespace blink { | 41 namespace blink { |
| 42 | 42 |
| 43 typedef uint32_t SnapshotObjectId; | 43 typedef uint32_t SnapshotObjectId; |
| 44 | 44 |
| 45 namespace HeapProfilerAgentState { | 45 namespace HeapProfilerAgentState { |
| 46 static const char heapProfilerEnabled[] = "heapProfilerEnabled"; | 46 static const char heapProfilerEnabled[] = "heapProfilerEnabled"; |
| 47 static const char heapObjectsTrackingEnabled[] = "heapObjectsTrackingEnabled"; | 47 static const char heapObjectsTrackingEnabled[] = "heapObjectsTrackingEnabled"; |
| 48 static const char allocationTrackingEnabled[] = "allocationTrackingEnabled"; | 48 static const char allocationTrackingEnabled[] = "allocationTrackingEnabled"; |
| 49 } | 49 } |
| 50 | 50 |
| 51 class InspectorHeapProfilerAgent::HeapStatsUpdateTask FINAL : public NoBaseWillB
eGarbageCollectedFinalized<InspectorHeapProfilerAgent::HeapStatsUpdateTask> { | 51 class InspectorHeapProfilerAgent::HeapStatsUpdateTask final : public NoBaseWillB
eGarbageCollectedFinalized<InspectorHeapProfilerAgent::HeapStatsUpdateTask> { |
| 52 public: | 52 public: |
| 53 explicit HeapStatsUpdateTask(InspectorHeapProfilerAgent*); | 53 explicit HeapStatsUpdateTask(InspectorHeapProfilerAgent*); |
| 54 void startTimer(); | 54 void startTimer(); |
| 55 void resetTimer() { m_timer.stop(); } | 55 void resetTimer() { m_timer.stop(); } |
| 56 void onTimer(Timer<HeapStatsUpdateTask>*); | 56 void onTimer(Timer<HeapStatsUpdateTask>*); |
| 57 void trace(Visitor*); | 57 void trace(Visitor*); |
| 58 | 58 |
| 59 private: | 59 private: |
| 60 RawPtrWillBeMember<InspectorHeapProfilerAgent> m_heapProfilerAgent; | 60 RawPtrWillBeMember<InspectorHeapProfilerAgent> m_heapProfilerAgent; |
| 61 Timer<HeapStatsUpdateTask> m_timer; | 61 Timer<HeapStatsUpdateTask> m_timer; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 { | 125 { |
| 126 ASSERT(!m_timer.isActive()); | 126 ASSERT(!m_timer.isActive()); |
| 127 m_timer.startRepeating(0.05, FROM_HERE); | 127 m_timer.startRepeating(0.05, FROM_HERE); |
| 128 } | 128 } |
| 129 | 129 |
| 130 void InspectorHeapProfilerAgent::HeapStatsUpdateTask::trace(Visitor* visitor) | 130 void InspectorHeapProfilerAgent::HeapStatsUpdateTask::trace(Visitor* visitor) |
| 131 { | 131 { |
| 132 visitor->trace(m_heapProfilerAgent); | 132 visitor->trace(m_heapProfilerAgent); |
| 133 } | 133 } |
| 134 | 134 |
| 135 class InspectorHeapProfilerAgent::HeapStatsStream FINAL : public ScriptProfiler:
:OutputStream { | 135 class InspectorHeapProfilerAgent::HeapStatsStream final : public ScriptProfiler:
:OutputStream { |
| 136 public: | 136 public: |
| 137 HeapStatsStream(InspectorHeapProfilerAgent* heapProfilerAgent) | 137 HeapStatsStream(InspectorHeapProfilerAgent* heapProfilerAgent) |
| 138 : m_heapProfilerAgent(heapProfilerAgent) | 138 : m_heapProfilerAgent(heapProfilerAgent) |
| 139 { | 139 { |
| 140 } | 140 } |
| 141 | 141 |
| 142 virtual void write(const uint32_t* chunk, const int size) OVERRIDE | 142 virtual void write(const uint32_t* chunk, const int size) override |
| 143 { | 143 { |
| 144 ASSERT(chunk); | 144 ASSERT(chunk); |
| 145 ASSERT(size > 0); | 145 ASSERT(size > 0); |
| 146 m_heapProfilerAgent->pushHeapStatsUpdate(chunk, size); | 146 m_heapProfilerAgent->pushHeapStatsUpdate(chunk, size); |
| 147 } | 147 } |
| 148 private: | 148 private: |
| 149 InspectorHeapProfilerAgent* m_heapProfilerAgent; | 149 InspectorHeapProfilerAgent* m_heapProfilerAgent; |
| 150 }; | 150 }; |
| 151 | 151 |
| 152 void InspectorHeapProfilerAgent::startTrackingHeapObjects(ErrorString*, const bo
ol* trackAllocations) | 152 void InspectorHeapProfilerAgent::startTrackingHeapObjects(ErrorString*, const bo
ol* trackAllocations) |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 | 214 |
| 215 void InspectorHeapProfilerAgent::disable(ErrorString* error) | 215 void InspectorHeapProfilerAgent::disable(ErrorString* error) |
| 216 { | 216 { |
| 217 stopTrackingHeapObjectsInternal(); | 217 stopTrackingHeapObjectsInternal(); |
| 218 ScriptProfiler::clearHeapObjectIds(); | 218 ScriptProfiler::clearHeapObjectIds(); |
| 219 m_state->setBoolean(HeapProfilerAgentState::heapProfilerEnabled, false); | 219 m_state->setBoolean(HeapProfilerAgentState::heapProfilerEnabled, false); |
| 220 } | 220 } |
| 221 | 221 |
| 222 void InspectorHeapProfilerAgent::takeHeapSnapshot(ErrorString* errorString, cons
t bool* reportProgress) | 222 void InspectorHeapProfilerAgent::takeHeapSnapshot(ErrorString* errorString, cons
t bool* reportProgress) |
| 223 { | 223 { |
| 224 class HeapSnapshotProgress FINAL : public ScriptProfiler::HeapSnapshotProgre
ss { | 224 class HeapSnapshotProgress final : public ScriptProfiler::HeapSnapshotProgre
ss { |
| 225 public: | 225 public: |
| 226 explicit HeapSnapshotProgress(InspectorFrontend::HeapProfiler* frontend) | 226 explicit HeapSnapshotProgress(InspectorFrontend::HeapProfiler* frontend) |
| 227 : m_frontend(frontend) { } | 227 : m_frontend(frontend) { } |
| 228 virtual void Start(int totalWork) OVERRIDE | 228 virtual void Start(int totalWork) override |
| 229 { | 229 { |
| 230 m_totalWork = totalWork; | 230 m_totalWork = totalWork; |
| 231 } | 231 } |
| 232 virtual void Worked(int workDone) OVERRIDE | 232 virtual void Worked(int workDone) override |
| 233 { | 233 { |
| 234 if (m_frontend) { | 234 if (m_frontend) { |
| 235 m_frontend->reportHeapSnapshotProgress(workDone, m_totalWork, 0)
; | 235 m_frontend->reportHeapSnapshotProgress(workDone, m_totalWork, 0)
; |
| 236 m_frontend->flush(); | 236 m_frontend->flush(); |
| 237 } | 237 } |
| 238 } | 238 } |
| 239 virtual void Done() OVERRIDE | 239 virtual void Done() override |
| 240 { | 240 { |
| 241 const bool finished = true; | 241 const bool finished = true; |
| 242 if (m_frontend) { | 242 if (m_frontend) { |
| 243 m_frontend->reportHeapSnapshotProgress(m_totalWork, m_totalWork,
&finished); | 243 m_frontend->reportHeapSnapshotProgress(m_totalWork, m_totalWork,
&finished); |
| 244 m_frontend->flush(); | 244 m_frontend->flush(); |
| 245 } | 245 } |
| 246 } | 246 } |
| 247 virtual bool isCanceled() OVERRIDE { return false; } | 247 virtual bool isCanceled() override { return false; } |
| 248 private: | 248 private: |
| 249 InspectorFrontend::HeapProfiler* m_frontend; | 249 InspectorFrontend::HeapProfiler* m_frontend; |
| 250 int m_totalWork; | 250 int m_totalWork; |
| 251 }; | 251 }; |
| 252 | 252 |
| 253 String title = "Snapshot " + String::number(m_nextUserInitiatedHeapSnapshotN
umber++); | 253 String title = "Snapshot " + String::number(m_nextUserInitiatedHeapSnapshotN
umber++); |
| 254 HeapSnapshotProgress progress(asBool(reportProgress) ? m_frontend : 0); | 254 HeapSnapshotProgress progress(asBool(reportProgress) ? m_frontend : 0); |
| 255 RefPtr<ScriptHeapSnapshot> snapshot = ScriptProfiler::takeHeapSnapshot(title
, &progress); | 255 RefPtr<ScriptHeapSnapshot> snapshot = ScriptProfiler::takeHeapSnapshot(title
, &progress); |
| 256 if (!snapshot) { | 256 if (!snapshot) { |
| 257 *errorString = "Failed to take heap snapshot"; | 257 *errorString = "Failed to take heap snapshot"; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 | 320 |
| 321 void InspectorHeapProfilerAgent::trace(Visitor* visitor) | 321 void InspectorHeapProfilerAgent::trace(Visitor* visitor) |
| 322 { | 322 { |
| 323 visitor->trace(m_injectedScriptManager); | 323 visitor->trace(m_injectedScriptManager); |
| 324 visitor->trace(m_heapStatsUpdateTask); | 324 visitor->trace(m_heapStatsUpdateTask); |
| 325 InspectorBaseAgent::trace(visitor); | 325 InspectorBaseAgent::trace(visitor); |
| 326 } | 326 } |
| 327 | 327 |
| 328 } // namespace blink | 328 } // namespace blink |
| 329 | 329 |
| OLD | NEW |