 Chromium Code Reviews
 Chromium Code Reviews Issue 16114002:
  Deprecate profiler methods that accept security origin  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
    
  
    Issue 16114002:
  Deprecate profiler methods that accept security origin  (Closed) 
  Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge| OLD | NEW | 
|---|---|
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 290 | 290 | 
| 291 // Test profiling cancellation by the 'delete' command. | 291 // Test profiling cancellation by the 'delete' command. | 
| 292 profiler->StartProfiling("1"); | 292 profiler->StartProfiling("1"); | 
| 293 profiler->StartProfiling("2"); | 293 profiler->StartProfiling("2"); | 
| 294 CHECK_EQ(0, profiler->GetProfilesCount()); | 294 CHECK_EQ(0, profiler->GetProfilesCount()); | 
| 295 profiler->DeleteAllProfiles(); | 295 profiler->DeleteAllProfiles(); | 
| 296 CHECK_EQ(0, profiler->GetProfilesCount()); | 296 CHECK_EQ(0, profiler->GetProfilesCount()); | 
| 297 } | 297 } | 
| 298 | 298 | 
| 299 | 299 | 
| 300 static const v8::CpuProfile* FindCpuProfile(v8::CpuProfiler* profiler, | |
| 301 unsigned uid) { | |
| 302 int length = profiler->GetProfileCount(); | |
| 303 for (int i = 0; i < length; i++) { | |
| 304 const v8::CpuProfile* profile = profiler->GetCpuProfile(i); | |
| 305 if (profile->GetUid() == uid) { | |
| 306 return profile; | |
| 307 } | |
| 308 } | |
| 309 return NULL; | |
| 310 } | |
| 311 | |
| 312 | |
| 300 TEST(DeleteCpuProfile) { | 313 TEST(DeleteCpuProfile) { | 
| 301 LocalContext env; | 314 LocalContext env; | 
| 302 v8::HandleScope scope(env->GetIsolate()); | 315 v8::HandleScope scope(env->GetIsolate()); | 
| 303 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); | 316 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); | 
| 304 | 317 | 
| 305 CHECK_EQ(0, cpu_profiler->GetProfileCount()); | 318 CHECK_EQ(0, cpu_profiler->GetProfileCount()); | 
| 306 v8::Local<v8::String> name1 = v8::String::New("1"); | 319 v8::Local<v8::String> name1 = v8::String::New("1"); | 
| 307 cpu_profiler->StartCpuProfiling(name1); | 320 cpu_profiler->StartCpuProfiling(name1); | 
| 308 const v8::CpuProfile* p1 = cpu_profiler->StopCpuProfiling(name1); | 321 const v8::CpuProfile* p1 = cpu_profiler->StopCpuProfiling(name1); | 
| 309 CHECK_NE(NULL, p1); | 322 CHECK_NE(NULL, p1); | 
| 310 CHECK_EQ(1, cpu_profiler->GetProfileCount()); | 323 CHECK_EQ(1, cpu_profiler->GetProfileCount()); | 
| 311 unsigned uid1 = p1->GetUid(); | 324 unsigned uid1 = p1->GetUid(); | 
| 312 CHECK_EQ(p1, cpu_profiler->FindCpuProfile(uid1)); | 325 CHECK_EQ(p1, FindCpuProfile(cpu_profiler, uid1)); | 
| 
alph
2013/05/28 05:27:51
Perhaps we should keep testing the current API unt
 
yurys
2013/05/28 06:14:57
That would break compilation because of V8_DEPRECA
 
alph
2013/05/28 06:28:54
I see two ways:
1. #define V8_DISABLE_DEPRECATIONS
 
yurys
2013/05/28 07:19:31
Done #1. PTAL
 | |
| 313 const_cast<v8::CpuProfile*>(p1)->Delete(); | 326 const_cast<v8::CpuProfile*>(p1)->Delete(); | 
| 314 CHECK_EQ(0, cpu_profiler->GetProfileCount()); | 327 CHECK_EQ(0, cpu_profiler->GetProfileCount()); | 
| 315 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid1)); | 328 CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid1)); | 
| 316 | 329 | 
| 317 v8::Local<v8::String> name2 = v8::String::New("2"); | 330 v8::Local<v8::String> name2 = v8::String::New("2"); | 
| 318 cpu_profiler->StartCpuProfiling(name2); | 331 cpu_profiler->StartCpuProfiling(name2); | 
| 319 const v8::CpuProfile* p2 = cpu_profiler->StopCpuProfiling(name2); | 332 const v8::CpuProfile* p2 = cpu_profiler->StopCpuProfiling(name2); | 
| 320 CHECK_NE(NULL, p2); | 333 CHECK_NE(NULL, p2); | 
| 321 CHECK_EQ(1, cpu_profiler->GetProfileCount()); | 334 CHECK_EQ(1, cpu_profiler->GetProfileCount()); | 
| 322 unsigned uid2 = p2->GetUid(); | 335 unsigned uid2 = p2->GetUid(); | 
| 323 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2)); | 336 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2)); | 
| 324 CHECK_EQ(p2, cpu_profiler->FindCpuProfile(uid2)); | 337 CHECK_EQ(p2, FindCpuProfile(cpu_profiler, uid2)); | 
| 325 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid1)); | 338 CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid1)); | 
| 326 v8::Local<v8::String> name3 = v8::String::New("3"); | 339 v8::Local<v8::String> name3 = v8::String::New("3"); | 
| 327 cpu_profiler->StartCpuProfiling(name3); | 340 cpu_profiler->StartCpuProfiling(name3); | 
| 328 const v8::CpuProfile* p3 = cpu_profiler->StopCpuProfiling(name3); | 341 const v8::CpuProfile* p3 = cpu_profiler->StopCpuProfiling(name3); | 
| 329 CHECK_NE(NULL, p3); | |
| 330 CHECK_EQ(2, cpu_profiler->GetProfileCount()); | |
| 331 unsigned uid3 = p3->GetUid(); | |
| 332 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid3)); | |
| 333 CHECK_EQ(p3, cpu_profiler->FindCpuProfile(uid3)); | |
| 334 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid1)); | |
| 335 const_cast<v8::CpuProfile*>(p2)->Delete(); | |
| 336 CHECK_EQ(1, cpu_profiler->GetProfileCount()); | |
| 337 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid2)); | |
| 338 CHECK_EQ(p3, cpu_profiler->FindCpuProfile(uid3)); | |
| 339 const_cast<v8::CpuProfile*>(p3)->Delete(); | |
| 340 CHECK_EQ(0, cpu_profiler->GetProfileCount()); | |
| 341 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid3)); | |
| 342 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid2)); | |
| 343 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid1)); | |
| 344 } | |
| 345 | |
| 346 | |
| 347 TEST(DeleteCpuProfileDifferentTokens) { | |
| 348 LocalContext env; | |
| 349 v8::HandleScope scope(env->GetIsolate()); | |
| 350 v8::CpuProfiler* cpu_profiler = env->GetIsolate()->GetCpuProfiler(); | |
| 351 | |
| 352 CHECK_EQ(0, cpu_profiler->GetProfileCount()); | |
| 353 v8::Local<v8::String> name1 = v8::String::New("1"); | |
| 354 cpu_profiler->StartCpuProfiling(name1); | |
| 355 const v8::CpuProfile* p1 = cpu_profiler->StopCpuProfiling(name1); | |
| 356 CHECK_NE(NULL, p1); | |
| 357 CHECK_EQ(1, cpu_profiler->GetProfileCount()); | |
| 358 unsigned uid1 = p1->GetUid(); | |
| 359 CHECK_EQ(p1, cpu_profiler->FindCpuProfile(uid1)); | |
| 360 v8::Local<v8::String> token1 = v8::String::New("token1"); | |
| 361 const v8::CpuProfile* p1_t1 = cpu_profiler->FindCpuProfile(uid1, token1); | |
| 362 CHECK_NE(NULL, p1_t1); | |
| 363 CHECK_NE(p1, p1_t1); | |
| 364 CHECK_EQ(1, cpu_profiler->GetProfileCount()); | |
| 365 const_cast<v8::CpuProfile*>(p1)->Delete(); | |
| 366 CHECK_EQ(0, cpu_profiler->GetProfileCount()); | |
| 367 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid1)); | |
| 368 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid1, token1)); | |
| 369 const_cast<v8::CpuProfile*>(p1_t1)->Delete(); | |
| 370 CHECK_EQ(0, cpu_profiler->GetProfileCount()); | |
| 371 | |
| 372 v8::Local<v8::String> name2 = v8::String::New("2"); | |
| 373 cpu_profiler->StartCpuProfiling(name2); | |
| 374 v8::Local<v8::String> token2 = v8::String::New("token2"); | |
| 375 const v8::CpuProfile* p2_t2 = cpu_profiler->StopCpuProfiling(name2, token2); | |
| 376 CHECK_NE(NULL, p2_t2); | |
| 377 CHECK_EQ(1, cpu_profiler->GetProfileCount()); | |
| 378 unsigned uid2 = p2_t2->GetUid(); | |
| 379 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid2)); | |
| 380 const v8::CpuProfile* p2 = cpu_profiler->FindCpuProfile(uid2); | |
| 381 CHECK_NE(p2_t2, p2); | |
| 382 v8::Local<v8::String> name3 = v8::String::New("3"); | |
| 383 cpu_profiler->StartCpuProfiling(name3); | |
| 384 const v8::CpuProfile* p3 = cpu_profiler->StopCpuProfiling(name3); | |
| 385 CHECK_NE(NULL, p3); | 342 CHECK_NE(NULL, p3); | 
| 386 CHECK_EQ(2, cpu_profiler->GetProfileCount()); | 343 CHECK_EQ(2, cpu_profiler->GetProfileCount()); | 
| 387 unsigned uid3 = p3->GetUid(); | 344 unsigned uid3 = p3->GetUid(); | 
| 388 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid3)); | 345 CHECK_NE(static_cast<int>(uid1), static_cast<int>(uid3)); | 
| 389 CHECK_EQ(p3, cpu_profiler->FindCpuProfile(uid3)); | 346 CHECK_EQ(p3, FindCpuProfile(cpu_profiler, uid3)); | 
| 390 const_cast<v8::CpuProfile*>(p2_t2)->Delete(); | 347 CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid1)); | 
| 391 CHECK_EQ(1, cpu_profiler->GetProfileCount()); | |
| 392 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid2)); | |
| 393 CHECK_EQ(p3, cpu_profiler->FindCpuProfile(uid3)); | |
| 394 const_cast<v8::CpuProfile*>(p2)->Delete(); | 348 const_cast<v8::CpuProfile*>(p2)->Delete(); | 
| 395 CHECK_EQ(1, cpu_profiler->GetProfileCount()); | 349 CHECK_EQ(1, cpu_profiler->GetProfileCount()); | 
| 396 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid2)); | 350 CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid2)); | 
| 397 CHECK_EQ(p3, cpu_profiler->FindCpuProfile(uid3)); | 351 CHECK_EQ(p3, FindCpuProfile(cpu_profiler, uid3)); | 
| 398 const_cast<v8::CpuProfile*>(p3)->Delete(); | 352 const_cast<v8::CpuProfile*>(p3)->Delete(); | 
| 399 CHECK_EQ(0, cpu_profiler->GetProfileCount()); | 353 CHECK_EQ(0, cpu_profiler->GetProfileCount()); | 
| 400 CHECK_EQ(NULL, cpu_profiler->FindCpuProfile(uid3)); | 354 CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid3)); | 
| 355 CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid2)); | |
| 356 CHECK_EQ(NULL, FindCpuProfile(cpu_profiler, uid1)); | |
| 401 } | 357 } | 
| 402 | 358 | 
| 403 | 359 | 
| 404 static bool ContainsString(v8::Handle<v8::String> string, | 360 static bool ContainsString(v8::Handle<v8::String> string, | 
| 405 const Vector<v8::Handle<v8::String> >& vector) { | 361 const Vector<v8::Handle<v8::String> >& vector) { | 
| 406 for (int i = 0; i < vector.length(); i++) { | 362 for (int i = 0; i < vector.length(); i++) { | 
| 407 if (string->Equals(vector[i])) | 363 if (string->Equals(vector[i])) | 
| 408 return true; | 364 return true; | 
| 409 } | 365 } | 
| 410 return false; | 366 return false; | 
| (...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 620 CHECK_EQ(1, startNode->GetChildrenCount()); | 576 CHECK_EQ(1, startNode->GetChildrenCount()); | 
| 621 const v8::CpuProfileNode* delayNode = GetChild(startNode, "delay"); | 577 const v8::CpuProfileNode* delayNode = GetChild(startNode, "delay"); | 
| 622 if (delayNode->GetChildrenCount() > 0) { | 578 if (delayNode->GetChildrenCount() > 0) { | 
| 623 CHECK_EQ(1, delayNode->GetChildrenCount()); | 579 CHECK_EQ(1, delayNode->GetChildrenCount()); | 
| 624 GetChild(delayNode, "loop"); | 580 GetChild(delayNode, "loop"); | 
| 625 } | 581 } | 
| 626 } | 582 } | 
| 627 | 583 | 
| 628 cpu_profiler->DeleteAllCpuProfiles(); | 584 cpu_profiler->DeleteAllCpuProfiles(); | 
| 629 } | 585 } | 
| OLD | NEW |