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

Side by Side Diff: test/cctest/test-heap-profiler.cc

Issue 16114002: Deprecate profiler methods that accept security origin (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: defined V8_DISABLE_DEPRECATIONS in test-cpu-profiler.cc and returned deleted test for deprecated API Created 7 years, 6 months 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/cctest/test-cpu-profiler.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 heap_profiler->DeleteAllHeapSnapshots(); 1278 heap_profiler->DeleteAllHeapSnapshots();
1279 CHECK_EQ(0, heap_profiler->GetSnapshotCount()); 1279 CHECK_EQ(0, heap_profiler->GetSnapshotCount());
1280 CHECK_NE(NULL, heap_profiler->TakeHeapSnapshot(v8_str("1"))); 1280 CHECK_NE(NULL, heap_profiler->TakeHeapSnapshot(v8_str("1")));
1281 CHECK_NE(NULL, heap_profiler->TakeHeapSnapshot(v8_str("2"))); 1281 CHECK_NE(NULL, heap_profiler->TakeHeapSnapshot(v8_str("2")));
1282 CHECK_EQ(2, heap_profiler->GetSnapshotCount()); 1282 CHECK_EQ(2, heap_profiler->GetSnapshotCount());
1283 heap_profiler->DeleteAllHeapSnapshots(); 1283 heap_profiler->DeleteAllHeapSnapshots();
1284 CHECK_EQ(0, heap_profiler->GetSnapshotCount()); 1284 CHECK_EQ(0, heap_profiler->GetSnapshotCount());
1285 } 1285 }
1286 1286
1287 1287
1288 static const v8::HeapSnapshot* FindHeapSnapshot(v8::HeapProfiler* profiler,
1289 unsigned uid) {
1290 int length = profiler->GetSnapshotCount();
1291 for (int i = 0; i < length; i++) {
1292 const v8::HeapSnapshot* snapshot = profiler->GetHeapSnapshot(i);
1293 if (snapshot->GetUid() == uid) {
1294 return snapshot;
1295 }
1296 }
1297 return NULL;
1298 }
1299
1300
1288 TEST(DeleteHeapSnapshot) { 1301 TEST(DeleteHeapSnapshot) {
1289 LocalContext env; 1302 LocalContext env;
1290 v8::HandleScope scope(env->GetIsolate()); 1303 v8::HandleScope scope(env->GetIsolate());
1291 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler(); 1304 v8::HeapProfiler* heap_profiler = env->GetIsolate()->GetHeapProfiler();
1292 1305
1293 CHECK_EQ(0, heap_profiler->GetSnapshotCount()); 1306 CHECK_EQ(0, heap_profiler->GetSnapshotCount());
1294 const v8::HeapSnapshot* s1 = 1307 const v8::HeapSnapshot* s1 =
1295 heap_profiler->TakeHeapSnapshot(v8_str("1")); 1308 heap_profiler->TakeHeapSnapshot(v8_str("1"));
1296 CHECK_NE(NULL, s1); 1309 CHECK_NE(NULL, s1);
1297 CHECK_EQ(1, heap_profiler->GetSnapshotCount()); 1310 CHECK_EQ(1, heap_profiler->GetSnapshotCount());
1298 unsigned uid1 = s1->GetUid(); 1311 unsigned uid1 = s1->GetUid();
1299 CHECK_EQ(s1, heap_profiler->FindHeapSnapshot(uid1)); 1312 CHECK_EQ(s1, FindHeapSnapshot(heap_profiler, uid1));
1300 const_cast<v8::HeapSnapshot*>(s1)->Delete(); 1313 const_cast<v8::HeapSnapshot*>(s1)->Delete();
1301 CHECK_EQ(0, heap_profiler->GetSnapshotCount()); 1314 CHECK_EQ(0, heap_profiler->GetSnapshotCount());
1302 CHECK_EQ(NULL, heap_profiler->FindHeapSnapshot(uid1)); 1315 CHECK_EQ(NULL, FindHeapSnapshot(heap_profiler, uid1));
1303 1316
1304 const v8::HeapSnapshot* s2 = 1317 const v8::HeapSnapshot* s2 =
1305 heap_profiler->TakeHeapSnapshot(v8_str("2")); 1318 heap_profiler->TakeHeapSnapshot(v8_str("2"));
1306 CHECK_NE(NULL, s2); 1319 CHECK_NE(NULL, s2);
1307 CHECK_EQ(1, heap_profiler->GetSnapshotCount()); 1320 CHECK_EQ(1, heap_profiler->GetSnapshotCount());
1308 unsigned uid2 = s2->GetUid(); 1321 unsigned uid2 = s2->GetUid();
1309 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2)); 1322 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2));
1310 CHECK_EQ(s2, heap_profiler->FindHeapSnapshot(uid2)); 1323 CHECK_EQ(s2, FindHeapSnapshot(heap_profiler, uid2));
1311 const v8::HeapSnapshot* s3 = 1324 const v8::HeapSnapshot* s3 =
1312 heap_profiler->TakeHeapSnapshot(v8_str("3")); 1325 heap_profiler->TakeHeapSnapshot(v8_str("3"));
1313 CHECK_NE(NULL, s3); 1326 CHECK_NE(NULL, s3);
1314 CHECK_EQ(2, heap_profiler->GetSnapshotCount()); 1327 CHECK_EQ(2, heap_profiler->GetSnapshotCount());
1315 unsigned uid3 = s3->GetUid(); 1328 unsigned uid3 = s3->GetUid();
1316 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid3)); 1329 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid3));
1317 CHECK_EQ(s3, heap_profiler->FindHeapSnapshot(uid3)); 1330 CHECK_EQ(s3, FindHeapSnapshot(heap_profiler, uid3));
1318 const_cast<v8::HeapSnapshot*>(s2)->Delete(); 1331 const_cast<v8::HeapSnapshot*>(s2)->Delete();
1319 CHECK_EQ(1, heap_profiler->GetSnapshotCount()); 1332 CHECK_EQ(1, heap_profiler->GetSnapshotCount());
1320 CHECK_EQ(NULL, heap_profiler->FindHeapSnapshot(uid2)); 1333 CHECK_EQ(NULL, FindHeapSnapshot(heap_profiler, uid2));
1321 CHECK_EQ(s3, heap_profiler->FindHeapSnapshot(uid3)); 1334 CHECK_EQ(s3, FindHeapSnapshot(heap_profiler, uid3));
1322 const_cast<v8::HeapSnapshot*>(s3)->Delete(); 1335 const_cast<v8::HeapSnapshot*>(s3)->Delete();
1323 CHECK_EQ(0, heap_profiler->GetSnapshotCount()); 1336 CHECK_EQ(0, heap_profiler->GetSnapshotCount());
1324 CHECK_EQ(NULL, heap_profiler->FindHeapSnapshot(uid3)); 1337 CHECK_EQ(NULL, FindHeapSnapshot(heap_profiler, uid3));
1325 } 1338 }
1326 1339
1327 1340
1328 class NameResolver : public v8::HeapProfiler::ObjectNameResolver { 1341 class NameResolver : public v8::HeapProfiler::ObjectNameResolver {
1329 public: 1342 public:
1330 virtual const char* GetName(v8::Handle<v8::Object> object) { 1343 virtual const char* GetName(v8::Handle<v8::Object> object) {
1331 return "Global object name"; 1344 return "Global object name";
1332 } 1345 }
1333 }; 1346 };
1334 1347
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
1777 // Check all the objects have got their names. 1790 // Check all the objects have got their names.
1778 // ... well check just every 8th because otherwise it's too slow in debug. 1791 // ... well check just every 8th because otherwise it's too slow in debug.
1779 for (int i = 0; i < num_objects - 1; i += 8) { 1792 for (int i = 0; i < num_objects - 1; i += 8) {
1780 i::EmbeddedVector<char, 100> var_name; 1793 i::EmbeddedVector<char, 100> var_name;
1781 i::OS::SNPrintF(var_name, "f_%d", i); 1794 i::OS::SNPrintF(var_name, "f_%d", i);
1782 const v8::HeapGraphNode* f_object = GetProperty( 1795 const v8::HeapGraphNode* f_object = GetProperty(
1783 context_object, v8::HeapGraphEdge::kContextVariable, var_name.start()); 1796 context_object, v8::HeapGraphEdge::kContextVariable, var_name.start());
1784 CHECK_NE(NULL, f_object); 1797 CHECK_NE(NULL, f_object);
1785 } 1798 }
1786 } 1799 }
OLDNEW
« no previous file with comments | « test/cctest/test-cpu-profiler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698