Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(207)

Unified Diff: Source/bindings/v8/ScriptProfiler.cpp

Issue 104313002: Use HeapProfiler::FindObjectById when searching for node (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/bindings/v8/ScriptProfiler.h ('k') | Source/core/inspector/InspectorHeapProfilerAgent.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/v8/ScriptProfiler.cpp
diff --git a/Source/bindings/v8/ScriptProfiler.cpp b/Source/bindings/v8/ScriptProfiler.cpp
index 914a943a2063629d1cdb5b2b2744d9f4321bb495..a32c616d65211437946cffaaf527806fb8884373 100644
--- a/Source/bindings/v8/ScriptProfiler.cpp
+++ b/Source/bindings/v8/ScriptProfiler.cpp
@@ -105,23 +105,9 @@ ScriptObject ScriptProfiler::objectByHeapObjectId(unsigned id)
{
v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::HeapProfiler* profiler = isolate->GetHeapProfiler();
- if (!profiler)
- return ScriptObject();
- // As ids are unique, it doesn't matter which HeapSnapshot owns HeapGraphNode.
- // We need to find first HeapSnapshot containing a node with the specified id.
- const v8::HeapGraphNode* node = 0;
- for (int i = 0, l = profiler->GetSnapshotCount(); i < l; ++i) {
- const v8::HeapSnapshot* snapshot = profiler->GetHeapSnapshot(i);
- node = snapshot->GetNodeById(id);
- if (node)
- break;
- }
- if (!node)
- return ScriptObject();
-
v8::HandleScope handleScope(isolate);
- v8::Handle<v8::Value> value = node->GetHeapValue();
- if (!value->IsObject())
+ v8::Handle<v8::Value> value = profiler->FindObjectById(id);
+ if (value.IsEmpty() || !value->IsObject())
return ScriptObject();
v8::Handle<v8::Object> object = value.As<v8::Object>();
@@ -146,6 +132,13 @@ unsigned ScriptProfiler::getHeapObjectId(const ScriptValue& value)
return id;
}
+void ScriptProfiler::clearHeapObjectIds()
+{
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ v8::HeapProfiler* profiler = isolate->GetHeapProfiler();
+ profiler->ClearObjectIds();
+}
+
namespace {
class ActivityControlAdapter : public v8::ActivityControl {
« no previous file with comments | « Source/bindings/v8/ScriptProfiler.h ('k') | Source/core/inspector/InspectorHeapProfilerAgent.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698