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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 | 216 |
217 void InspectorHeapProfilerAgent::disable(ErrorString* error) | 217 void InspectorHeapProfilerAgent::disable(ErrorString* error) |
218 { | 218 { |
219 stopTrackingHeapObjectsInternal(); | 219 stopTrackingHeapObjectsInternal(); |
220 ScriptProfiler::clearHeapObjectIds(); | 220 ScriptProfiler::clearHeapObjectIds(); |
221 m_state->setBoolean(HeapProfilerAgentState::heapProfilerEnabled, false); | 221 m_state->setBoolean(HeapProfilerAgentState::heapProfilerEnabled, false); |
222 } | 222 } |
223 | 223 |
224 void InspectorHeapProfilerAgent::getHeapSnapshot(ErrorString* errorString, int r
awUid) | 224 void InspectorHeapProfilerAgent::getHeapSnapshot(ErrorString* errorString, int r
awUid) |
225 { | 225 { |
226 class OutputStream : public ScriptHeapSnapshot::OutputStream { | 226 class OutputStream FINAL : public ScriptHeapSnapshot::OutputStream { |
227 public: | 227 public: |
228 OutputStream(InspectorFrontend::HeapProfiler* frontend, unsigned uid) | 228 OutputStream(InspectorFrontend::HeapProfiler* frontend, unsigned uid) |
229 : m_frontend(frontend), m_uid(uid) { } | 229 : m_frontend(frontend), m_uid(uid) { } |
230 void Write(const String& chunk) { m_frontend->addHeapSnapshotChunk(m_uid
, chunk); } | 230 virtual void Write(const String& chunk) OVERRIDE { m_frontend->addHeapSn
apshotChunk(m_uid, chunk); } |
231 void Close() { } | 231 virtual void Close() OVERRIDE { } |
232 private: | 232 private: |
233 InspectorFrontend::HeapProfiler* m_frontend; | 233 InspectorFrontend::HeapProfiler* m_frontend; |
234 int m_uid; | 234 int m_uid; |
235 }; | 235 }; |
236 | 236 |
237 unsigned uid = static_cast<unsigned>(rawUid); | 237 unsigned uid = static_cast<unsigned>(rawUid); |
238 IdToHeapSnapshotMap::iterator it = m_snapshots.find(uid); | 238 IdToHeapSnapshotMap::iterator it = m_snapshots.find(uid); |
239 if (it == m_snapshots.end()) { | 239 if (it == m_snapshots.end()) { |
240 *errorString = "Profile wasn't found"; | 240 *errorString = "Profile wasn't found"; |
241 return; | 241 return; |
242 } | 242 } |
243 RefPtr<ScriptHeapSnapshot> snapshot = it->value; | 243 RefPtr<ScriptHeapSnapshot> snapshot = it->value; |
244 if (m_frontend) { | 244 if (m_frontend) { |
245 OutputStream stream(m_frontend, uid); | 245 OutputStream stream(m_frontend, uid); |
246 snapshot->writeJSON(&stream); | 246 snapshot->writeJSON(&stream); |
247 } | 247 } |
248 } | 248 } |
249 | 249 |
250 void InspectorHeapProfilerAgent::removeProfile(ErrorString*, int rawUid) | 250 void InspectorHeapProfilerAgent::removeProfile(ErrorString*, int rawUid) |
251 { | 251 { |
252 unsigned uid = static_cast<unsigned>(rawUid); | 252 unsigned uid = static_cast<unsigned>(rawUid); |
253 if (m_snapshots.contains(uid)) | 253 if (m_snapshots.contains(uid)) |
254 m_snapshots.remove(uid); | 254 m_snapshots.remove(uid); |
255 } | 255 } |
256 | 256 |
257 void InspectorHeapProfilerAgent::takeHeapSnapshot(ErrorString*, const bool* repo
rtProgress) | 257 void InspectorHeapProfilerAgent::takeHeapSnapshot(ErrorString*, const bool* repo
rtProgress) |
258 { | 258 { |
259 class HeapSnapshotProgress: public ScriptProfiler::HeapSnapshotProgress { | 259 class HeapSnapshotProgress FINAL : public ScriptProfiler::HeapSnapshotProgre
ss { |
260 public: | 260 public: |
261 explicit HeapSnapshotProgress(InspectorFrontend::HeapProfiler* frontend) | 261 explicit HeapSnapshotProgress(InspectorFrontend::HeapProfiler* frontend) |
262 : m_frontend(frontend) { } | 262 : m_frontend(frontend) { } |
263 void Start(int totalWork) | 263 virtual void Start(int totalWork) OVERRIDE |
264 { | 264 { |
265 m_totalWork = totalWork; | 265 m_totalWork = totalWork; |
266 } | 266 } |
267 void Worked(int workDone) | 267 virtual void Worked(int workDone) OVERRIDE |
268 { | 268 { |
269 if (m_frontend) | 269 if (m_frontend) |
270 m_frontend->reportHeapSnapshotProgress(workDone, m_totalWork); | 270 m_frontend->reportHeapSnapshotProgress(workDone, m_totalWork); |
271 } | 271 } |
272 void Done() { } | 272 virtual void Done() OVERRIDE { } |
273 bool isCanceled() { return false; } | 273 virtual bool isCanceled() OVERRIDE { return false; } |
274 private: | 274 private: |
275 InspectorFrontend::HeapProfiler* m_frontend; | 275 InspectorFrontend::HeapProfiler* m_frontend; |
276 int m_totalWork; | 276 int m_totalWork; |
277 }; | 277 }; |
278 | 278 |
279 String title = "Snapshot " + String::number(m_nextUserInitiatedHeapSnapshotN
umber++); | 279 String title = "Snapshot " + String::number(m_nextUserInitiatedHeapSnapshotN
umber++); |
280 HeapSnapshotProgress progress(reportProgress && *reportProgress ? m_frontend
: 0); | 280 HeapSnapshotProgress progress(reportProgress && *reportProgress ? m_frontend
: 0); |
281 RefPtr<ScriptHeapSnapshot> snapshot = ScriptProfiler::takeHeapSnapshot(title
, &progress); | 281 RefPtr<ScriptHeapSnapshot> snapshot = ScriptProfiler::takeHeapSnapshot(title
, &progress); |
282 if (snapshot) { | 282 if (snapshot) { |
283 m_snapshots.add(snapshot->uid(), snapshot); | 283 m_snapshots.add(snapshot->uid(), snapshot); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 if (value.hasNoValue() || value.isUndefined()) { | 321 if (value.hasNoValue() || value.isUndefined()) { |
322 *errorString = "Object with given id not found"; | 322 *errorString = "Object with given id not found"; |
323 return; | 323 return; |
324 } | 324 } |
325 unsigned id = ScriptProfiler::getHeapObjectId(value); | 325 unsigned id = ScriptProfiler::getHeapObjectId(value); |
326 *heapSnapshotObjectId = String::number(id); | 326 *heapSnapshotObjectId = String::number(id); |
327 } | 327 } |
328 | 328 |
329 } // namespace WebCore | 329 } // namespace WebCore |
330 | 330 |
OLD | NEW |