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 26 matching lines...) Expand all Loading... |
37 #include "core/inspector/InspectorState.h" | 37 #include "core/inspector/InspectorState.h" |
38 #include "core/platform/Timer.h" | 38 #include "core/platform/Timer.h" |
39 #include "wtf/CurrentTime.h" | 39 #include "wtf/CurrentTime.h" |
40 | 40 |
41 namespace WebCore { | 41 namespace WebCore { |
42 | 42 |
43 namespace HeapProfilerAgentState { | 43 namespace HeapProfilerAgentState { |
44 static const char profileHeadersRequested[] = "profileHeadersRequested"; | 44 static const char profileHeadersRequested[] = "profileHeadersRequested"; |
45 } | 45 } |
46 | 46 |
47 static const char* const userInitiatedProfileNameHeap = "org.webkit.profiles.use
r-initiated"; | |
48 | |
49 class InspectorHeapProfilerAgent::HeapStatsUpdateTask { | 47 class InspectorHeapProfilerAgent::HeapStatsUpdateTask { |
50 public: | 48 public: |
51 HeapStatsUpdateTask(InspectorHeapProfilerAgent*); | 49 HeapStatsUpdateTask(InspectorHeapProfilerAgent*); |
52 void startTimer(); | 50 void startTimer(); |
53 void resetTimer() { m_timer.stop(); } | 51 void resetTimer() { m_timer.stop(); } |
54 void onTimer(Timer<HeapStatsUpdateTask>*); | 52 void onTimer(Timer<HeapStatsUpdateTask>*); |
55 | 53 |
56 private: | 54 private: |
57 InspectorHeapProfilerAgent* m_heapProfilerAgent; | 55 InspectorHeapProfilerAgent* m_heapProfilerAgent; |
58 Timer<HeapStatsUpdateTask> m_timer; | 56 Timer<HeapStatsUpdateTask> m_timer; |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 if (m_frontend) | 254 if (m_frontend) |
257 m_frontend->reportHeapSnapshotProgress(workDone, m_totalWork); | 255 m_frontend->reportHeapSnapshotProgress(workDone, m_totalWork); |
258 } | 256 } |
259 void Done() { } | 257 void Done() { } |
260 bool isCanceled() { return false; } | 258 bool isCanceled() { return false; } |
261 private: | 259 private: |
262 InspectorFrontend::HeapProfiler* m_frontend; | 260 InspectorFrontend::HeapProfiler* m_frontend; |
263 int m_totalWork; | 261 int m_totalWork; |
264 }; | 262 }; |
265 | 263 |
266 String title = String(userInitiatedProfileNameHeap) + "." + String::number(m
_nextUserInitiatedHeapSnapshotNumber); | 264 String title = "Snapshot " + String::number(m_nextUserInitiatedHeapSnapshotN
umber++); |
267 ++m_nextUserInitiatedHeapSnapshotNumber; | |
268 | |
269 HeapSnapshotProgress progress(reportProgress && *reportProgress ? m_frontend
: 0); | 265 HeapSnapshotProgress progress(reportProgress && *reportProgress ? m_frontend
: 0); |
270 RefPtr<ScriptHeapSnapshot> snapshot = ScriptProfiler::takeHeapSnapshot(title
, &progress); | 266 RefPtr<ScriptHeapSnapshot> snapshot = ScriptProfiler::takeHeapSnapshot(title
, &progress); |
271 if (snapshot) { | 267 if (snapshot) { |
272 m_snapshots.add(snapshot->uid(), snapshot); | 268 m_snapshots.add(snapshot->uid(), snapshot); |
273 if (m_frontend) | 269 if (m_frontend) |
274 m_frontend->addProfileHeader(createSnapshotHeader(*snapshot)); | 270 m_frontend->addProfileHeader(createSnapshotHeader(*snapshot)); |
275 } | 271 } |
276 } | 272 } |
277 | 273 |
278 void InspectorHeapProfilerAgent::getObjectByHeapObjectId(ErrorString* error, con
st String& heapSnapshotObjectId, const String* objectGroup, RefPtr<TypeBuilder::
Runtime::RemoteObject>& result) | 274 void InspectorHeapProfilerAgent::getObjectByHeapObjectId(ErrorString* error, con
st String& heapSnapshotObjectId, const String* objectGroup, RefPtr<TypeBuilder::
Runtime::RemoteObject>& result) |
(...skipping 30 matching lines...) Expand all Loading... |
309 if (value.hasNoValue() || value.isUndefined()) { | 305 if (value.hasNoValue() || value.isUndefined()) { |
310 *errorString = "Object with given id not found"; | 306 *errorString = "Object with given id not found"; |
311 return; | 307 return; |
312 } | 308 } |
313 unsigned id = ScriptProfiler::getHeapObjectId(value); | 309 unsigned id = ScriptProfiler::getHeapObjectId(value); |
314 *heapSnapshotObjectId = String::number(id); | 310 *heapSnapshotObjectId = String::number(id); |
315 } | 311 } |
316 | 312 |
317 } // namespace WebCore | 313 } // namespace WebCore |
318 | 314 |
OLD | NEW |