diff options
author | mnaganov@chromium.org <mnaganov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-23 12:47:10 +0000 |
---|---|---|
committer | mnaganov@chromium.org <mnaganov@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-06-23 12:47:10 +0000 |
commit | 6f0cb4c999ca2f2f48962542709266a522691812 (patch) | |
tree | ea7a8e9ac6617a8a47c237d2c2b97c137c8b47b9 /webkit | |
parent | 1a369fd46dfd97e3cba6c4b3b127809e42d06c8d (diff) | |
download | chromium_src-6f0cb4c999ca2f2f48962542709266a522691812.zip chromium_src-6f0cb4c999ca2f2f48962542709266a522691812.tar.gz chromium_src-6f0cb4c999ca2f2f48962542709266a522691812.tar.bz2 |
Convert ListenerLeakTest to use full V8 snapshots, so we can kill aggregated ones.
R=vitalyr@chromium.org
BUG=none
TEST=ListenerLeakTest
Review URL: http://codereview.chromium.org/7246005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@90205 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/tools/test_shell/listener_leak_test.cc | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/webkit/tools/test_shell/listener_leak_test.cc b/webkit/tools/test_shell/listener_leak_test.cc index 157891a..59cd12e 100644 --- a/webkit/tools/test_shell/listener_leak_test.cc +++ b/webkit/tools/test_shell/listener_leak_test.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -17,30 +17,22 @@ class ListenerLeakTest : public TestShellTest { }; -static const v8::HeapGraphNode* GetChild( - const v8::HeapGraphNode* node, - v8::HeapGraphNode::Type type, - const char* name) { - for (int i = 0, count = node->GetChildrenCount(); i < count; ++i) { - const v8::HeapGraphEdge* prop = node->GetChild(i); - const v8::HeapGraphNode* child = prop->GetToNode(); - v8::String::AsciiValue child_name(child->GetName()); - if (child->GetType() == type && strcmp(name, *child_name) == 0) - return child; - } - return NULL; -} - static int GetNumObjects(const char* constructor) { v8::HandleScope scope; const v8::HeapSnapshot* snapshot = - v8::HeapProfiler::TakeSnapshot(v8::String::New(""), - v8::HeapSnapshot::kAggregated); + v8::HeapProfiler::TakeSnapshot(v8::String::New(""), + v8::HeapSnapshot::kFull); CHECK(snapshot); - const v8::HeapGraphNode* node = GetChild(snapshot->GetRoot(), - v8::HeapGraphNode::kObject, - constructor); - return node != NULL ? node->GetInstancesCount() : 0; + int count = 0; + for (int i = 0; i < snapshot->GetNodesCount(); ++i) { + const v8::HeapGraphNode* node = snapshot->GetNode(i); + if (node->GetType() != v8::HeapGraphNode::kObject) + continue; + v8::String::AsciiValue node_name(node->GetName()); + if (strcmp(constructor, *node_name) == 0) + ++count; + } + return count; } // This test tries to create a reference cycle between node and its listener. |