Index: src/heap-profiler.cc |
diff --git a/src/heap-profiler.cc b/src/heap-profiler.cc |
index 91ac9867a2855d83963fc6c35ee031b9485fdf8c..6700d38b250c426e4767dbe9674121dba12af12e 100644 |
--- a/src/heap-profiler.cc |
+++ b/src/heap-profiler.cc |
@@ -348,27 +348,34 @@ void HeapProfiler::TearDown() { |
#ifdef ENABLE_LOGGING_AND_PROFILING |
-HeapSnapshot* HeapProfiler::TakeSnapshot(const char* name, int type) { |
+HeapSnapshot* HeapProfiler::TakeSnapshot(const char* name, |
+ int type, |
+ v8::ActivityControl* control) { |
ASSERT(singleton_ != NULL); |
- return singleton_->TakeSnapshotImpl(name, type); |
+ return singleton_->TakeSnapshotImpl(name, type, control); |
} |
-HeapSnapshot* HeapProfiler::TakeSnapshot(String* name, int type) { |
+HeapSnapshot* HeapProfiler::TakeSnapshot(String* name, |
+ int type, |
+ v8::ActivityControl* control) { |
ASSERT(singleton_ != NULL); |
- return singleton_->TakeSnapshotImpl(name, type); |
+ return singleton_->TakeSnapshotImpl(name, type, control); |
} |
-HeapSnapshot* HeapProfiler::TakeSnapshotImpl(const char* name, int type) { |
+HeapSnapshot* HeapProfiler::TakeSnapshotImpl(const char* name, |
+ int type, |
+ v8::ActivityControl* control) { |
Heap::CollectAllGarbage(true); |
HeapSnapshot::Type s_type = static_cast<HeapSnapshot::Type>(type); |
HeapSnapshot* result = |
snapshots_->NewSnapshot(s_type, name, next_snapshot_uid_++); |
+ bool generation_completed = true; |
switch (s_type) { |
case HeapSnapshot::kFull: { |
- HeapSnapshotGenerator generator(result); |
- generator.GenerateSnapshot(); |
+ HeapSnapshotGenerator generator(result, control); |
+ generation_completed = generator.GenerateSnapshot(); |
break; |
} |
case HeapSnapshot::kAggregated: { |
@@ -381,13 +388,19 @@ HeapSnapshot* HeapProfiler::TakeSnapshotImpl(const char* name, int type) { |
default: |
UNREACHABLE(); |
} |
- snapshots_->SnapshotGenerationFinished(); |
+ if (!generation_completed) { |
+ delete result; |
+ result = NULL; |
+ } |
+ snapshots_->SnapshotGenerationFinished(result); |
return result; |
} |
-HeapSnapshot* HeapProfiler::TakeSnapshotImpl(String* name, int type) { |
- return TakeSnapshotImpl(snapshots_->GetName(name), type); |
+HeapSnapshot* HeapProfiler::TakeSnapshotImpl(String* name, |
+ int type, |
+ v8::ActivityControl* control) { |
+ return TakeSnapshotImpl(snapshots_->GetName(name), type, control); |
} |