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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 visitor->trace(m_heapProfilerAgent); | 113 visitor->trace(m_heapProfilerAgent); |
114 } | 114 } |
115 | 115 |
116 class InspectorHeapProfilerAgent::HeapStatsStream final : public ScriptProfiler:
:OutputStream { | 116 class InspectorHeapProfilerAgent::HeapStatsStream final : public ScriptProfiler:
:OutputStream { |
117 public: | 117 public: |
118 HeapStatsStream(InspectorHeapProfilerAgent* heapProfilerAgent) | 118 HeapStatsStream(InspectorHeapProfilerAgent* heapProfilerAgent) |
119 : m_heapProfilerAgent(heapProfilerAgent) | 119 : m_heapProfilerAgent(heapProfilerAgent) |
120 { | 120 { |
121 } | 121 } |
122 | 122 |
123 virtual void write(const uint32_t* chunk, const int size) override | 123 void write(const uint32_t* chunk, const int size) override |
124 { | 124 { |
125 ASSERT(chunk); | 125 ASSERT(chunk); |
126 ASSERT(size > 0); | 126 ASSERT(size > 0); |
127 m_heapProfilerAgent->pushHeapStatsUpdate(chunk, size); | 127 m_heapProfilerAgent->pushHeapStatsUpdate(chunk, size); |
128 } | 128 } |
129 private: | 129 private: |
130 InspectorHeapProfilerAgent* m_heapProfilerAgent; | 130 InspectorHeapProfilerAgent* m_heapProfilerAgent; |
131 }; | 131 }; |
132 | 132 |
133 void InspectorHeapProfilerAgent::startTrackingHeapObjects(ErrorString*, const bo
ol* trackAllocations) | 133 void InspectorHeapProfilerAgent::startTrackingHeapObjects(ErrorString*, const bo
ol* trackAllocations) |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 m_state->setBoolean(HeapProfilerAgentState::heapProfilerEnabled, false); | 200 m_state->setBoolean(HeapProfilerAgentState::heapProfilerEnabled, false); |
201 } | 201 } |
202 | 202 |
203 void InspectorHeapProfilerAgent::takeHeapSnapshot(ErrorString* errorString, cons
t bool* reportProgress) | 203 void InspectorHeapProfilerAgent::takeHeapSnapshot(ErrorString* errorString, cons
t bool* reportProgress) |
204 { | 204 { |
205 class HeapSnapshotProgress final : public ScriptProfiler::HeapSnapshotProgre
ss { | 205 class HeapSnapshotProgress final : public ScriptProfiler::HeapSnapshotProgre
ss { |
206 public: | 206 public: |
207 explicit HeapSnapshotProgress(InspectorFrontend::HeapProfiler* frontend) | 207 explicit HeapSnapshotProgress(InspectorFrontend::HeapProfiler* frontend) |
208 : m_frontend(frontend) | 208 : m_frontend(frontend) |
209 , m_totalWork(0) { } | 209 , m_totalWork(0) { } |
210 virtual void Start(int totalWork) override | 210 void Start(int totalWork) override |
211 { | 211 { |
212 m_totalWork = totalWork; | 212 m_totalWork = totalWork; |
213 } | 213 } |
214 virtual void Worked(int workDone) override | 214 void Worked(int workDone) override |
215 { | 215 { |
216 if (m_frontend) { | 216 if (m_frontend) { |
217 m_frontend->reportHeapSnapshotProgress(workDone, m_totalWork, 0)
; | 217 m_frontend->reportHeapSnapshotProgress(workDone, m_totalWork, 0)
; |
218 m_frontend->flush(); | 218 m_frontend->flush(); |
219 } | 219 } |
220 } | 220 } |
221 virtual void Done() override | 221 void Done() override |
222 { | 222 { |
223 const bool finished = true; | 223 const bool finished = true; |
224 if (m_frontend) { | 224 if (m_frontend) { |
225 m_frontend->reportHeapSnapshotProgress(m_totalWork, m_totalWork,
&finished); | 225 m_frontend->reportHeapSnapshotProgress(m_totalWork, m_totalWork,
&finished); |
226 m_frontend->flush(); | 226 m_frontend->flush(); |
227 } | 227 } |
228 } | 228 } |
229 virtual bool isCanceled() override { return false; } | 229 bool isCanceled() override { return false; } |
230 private: | 230 private: |
231 InspectorFrontend::HeapProfiler* m_frontend; | 231 InspectorFrontend::HeapProfiler* m_frontend; |
232 int m_totalWork; | 232 int m_totalWork; |
233 }; | 233 }; |
234 | 234 |
235 HeapSnapshotProgress progress(asBool(reportProgress) ? frontend() : 0); | 235 HeapSnapshotProgress progress(asBool(reportProgress) ? frontend() : 0); |
236 RefPtr<ScriptHeapSnapshot> snapshot = ScriptProfiler::takeHeapSnapshot(&prog
ress); | 236 RefPtr<ScriptHeapSnapshot> snapshot = ScriptProfiler::takeHeapSnapshot(&prog
ress); |
237 if (!snapshot) { | 237 if (!snapshot) { |
238 *errorString = "Failed to take heap snapshot"; | 238 *errorString = "Failed to take heap snapshot"; |
239 return; | 239 return; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 return; | 278 return; |
279 } | 279 } |
280 result = injectedScript.wrapObject(heapObject, objectGroup ? *objectGroup :
""); | 280 result = injectedScript.wrapObject(heapObject, objectGroup ? *objectGroup :
""); |
281 if (!result) | 281 if (!result) |
282 *error = "Failed to wrap object"; | 282 *error = "Failed to wrap object"; |
283 } | 283 } |
284 | 284 |
285 class InspectableHeapObject final : public InjectedScriptHost::InspectableObject
{ | 285 class InspectableHeapObject final : public InjectedScriptHost::InspectableObject
{ |
286 public: | 286 public: |
287 explicit InspectableHeapObject(unsigned heapObjectId) : m_heapObjectId(heapO
bjectId) { } | 287 explicit InspectableHeapObject(unsigned heapObjectId) : m_heapObjectId(heapO
bjectId) { } |
288 virtual ScriptValue get(ScriptState*) override | 288 ScriptValue get(ScriptState*) override |
289 { | 289 { |
290 return ScriptProfiler::objectByHeapObjectId(m_heapObjectId); | 290 return ScriptProfiler::objectByHeapObjectId(m_heapObjectId); |
291 } | 291 } |
292 private: | 292 private: |
293 unsigned m_heapObjectId; | 293 unsigned m_heapObjectId; |
294 }; | 294 }; |
295 | 295 |
296 void InspectorHeapProfilerAgent::addInspectedHeapObject(ErrorString* errorString
, const String& inspectedHeapObjectId) | 296 void InspectorHeapProfilerAgent::addInspectedHeapObject(ErrorString* errorString
, const String& inspectedHeapObjectId) |
297 { | 297 { |
298 bool ok; | 298 bool ok; |
(...skipping 24 matching lines...) Expand all Loading... |
323 | 323 |
324 DEFINE_TRACE(InspectorHeapProfilerAgent) | 324 DEFINE_TRACE(InspectorHeapProfilerAgent) |
325 { | 325 { |
326 visitor->trace(m_injectedScriptManager); | 326 visitor->trace(m_injectedScriptManager); |
327 visitor->trace(m_heapStatsUpdateTask); | 327 visitor->trace(m_heapStatsUpdateTask); |
328 InspectorBaseAgent::trace(visitor); | 328 InspectorBaseAgent::trace(visitor); |
329 } | 329 } |
330 | 330 |
331 } // namespace blink | 331 } // namespace blink |
332 | 332 |
OLD | NEW |