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

Side by Side Diff: components/metrics/call_stack_profile_metrics_provider_unittest.cc

Issue 2362493002: Stack sampling profiler: set process and thread information (Closed)
Patch Set: address comments Created 4 years, 3 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/metrics/call_stack_profile_metrics_provider.h" 5 #include "components/metrics/call_stack_profile_metrics_provider.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 198
199 profile.profile_duration = profile_durations[i]; 199 profile.profile_duration = profile_durations[i];
200 profile.sampling_period = profile_sampling_periods[i]; 200 profile.sampling_period = profile_sampling_periods[i];
201 201
202 profiles.push_back(profile); 202 profiles.push_back(profile);
203 } 203 }
204 204
205 CallStackProfileMetricsProvider provider; 205 CallStackProfileMetricsProvider provider;
206 provider.OnRecordingEnabled(); 206 provider.OnRecordingEnabled();
207 AppendProfiles( 207 AppendProfiles(
208 CallStackProfileParams(CallStackProfileParams::PROCESS_STARTUP, 208 CallStackProfileParams(CallStackProfileParams::BROWSER_PROCESS,
209 CallStackProfileParams::UI_THREAD,
210 CallStackProfileParams::PROCESS_STARTUP,
209 CallStackProfileParams::MAY_SHUFFLE), 211 CallStackProfileParams::MAY_SHUFFLE),
210 profiles); 212 profiles);
211 ChromeUserMetricsExtension uma_proto; 213 ChromeUserMetricsExtension uma_proto;
212 provider.ProvideGeneralMetrics(&uma_proto); 214 provider.ProvideGeneralMetrics(&uma_proto);
213 215
214 ASSERT_EQ(static_cast<int>(arraysize(profile_sample_frames)), 216 ASSERT_EQ(static_cast<int>(arraysize(profile_sample_frames)),
215 uma_proto.sampled_profile().size()); 217 uma_proto.sampled_profile().size());
216 for (size_t i = 0; i < arraysize(profile_sample_frames); ++i) { 218 for (size_t i = 0; i < arraysize(profile_sample_frames); ++i) {
217 SCOPED_TRACE("profile " + base::SizeTToString(i)); 219 SCOPED_TRACE("profile " + base::SizeTToString(i));
218 const SampledProfile& sampled_profile = uma_proto.sampled_profile().Get(i); 220 const SampledProfile& sampled_profile = uma_proto.sampled_profile().Get(i);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 EXPECT_EQ(profile_expected_name_md5_prefixes[i][j], 262 EXPECT_EQ(profile_expected_name_md5_prefixes[i][j],
261 module_identifier.name_md5_prefix()); 263 module_identifier.name_md5_prefix());
262 } 264 }
263 265
264 ASSERT_TRUE(call_stack_profile.has_profile_duration_ms()); 266 ASSERT_TRUE(call_stack_profile.has_profile_duration_ms());
265 EXPECT_EQ(profile_durations[i].InMilliseconds(), 267 EXPECT_EQ(profile_durations[i].InMilliseconds(),
266 call_stack_profile.profile_duration_ms()); 268 call_stack_profile.profile_duration_ms());
267 ASSERT_TRUE(call_stack_profile.has_sampling_period_ms()); 269 ASSERT_TRUE(call_stack_profile.has_sampling_period_ms());
268 EXPECT_EQ(profile_sampling_periods[i].InMilliseconds(), 270 EXPECT_EQ(profile_sampling_periods[i].InMilliseconds(),
269 call_stack_profile.sampling_period_ms()); 271 call_stack_profile.sampling_period_ms());
272 ASSERT_TRUE(sampled_profile.has_process());
273 EXPECT_EQ(BROWSER_PROCESS, sampled_profile.process());
274 ASSERT_TRUE(sampled_profile.has_thread());
275 EXPECT_EQ(UI_THREAD, sampled_profile.thread());
270 ASSERT_TRUE(sampled_profile.has_trigger_event()); 276 ASSERT_TRUE(sampled_profile.has_trigger_event());
271 EXPECT_EQ(SampledProfile::PROCESS_STARTUP, sampled_profile.trigger_event()); 277 EXPECT_EQ(SampledProfile::PROCESS_STARTUP, sampled_profile.trigger_event());
272 } 278 }
273 } 279 }
274 280
275 // Checks that all duplicate samples are collapsed with 281 // Checks that all duplicate samples are collapsed with
276 // preserve_sample_ordering = false. 282 // preserve_sample_ordering = false.
277 TEST_F(CallStackProfileMetricsProviderTest, RepeatedStacksUnordered) { 283 TEST_F(CallStackProfileMetricsProviderTest, RepeatedStacksUnordered) {
278 const uintptr_t module_base_address = 0x1000; 284 const uintptr_t module_base_address = 0x1000;
279 285
(...skipping 27 matching lines...) Expand all
307 sample.insert(sample.end(), &sample_frames[i][0], 313 sample.insert(sample.end(), &sample_frames[i][0],
308 &sample_frames[i][0] + arraysize(sample_frames[i])); 314 &sample_frames[i][0] + arraysize(sample_frames[i]));
309 } 315 }
310 316
311 profile.profile_duration = base::TimeDelta::FromMilliseconds(100); 317 profile.profile_duration = base::TimeDelta::FromMilliseconds(100);
312 profile.sampling_period = base::TimeDelta::FromMilliseconds(10); 318 profile.sampling_period = base::TimeDelta::FromMilliseconds(10);
313 319
314 CallStackProfileMetricsProvider provider; 320 CallStackProfileMetricsProvider provider;
315 provider.OnRecordingEnabled(); 321 provider.OnRecordingEnabled();
316 AppendProfiles( 322 AppendProfiles(
317 CallStackProfileParams(CallStackProfileParams::PROCESS_STARTUP, 323 CallStackProfileParams(CallStackProfileParams::BROWSER_PROCESS,
324 CallStackProfileParams::UI_THREAD,
325 CallStackProfileParams::PROCESS_STARTUP,
318 CallStackProfileParams::MAY_SHUFFLE), 326 CallStackProfileParams::MAY_SHUFFLE),
319 std::vector<Profile>(1, profile)); 327 std::vector<Profile>(1, profile));
320 ChromeUserMetricsExtension uma_proto; 328 ChromeUserMetricsExtension uma_proto;
321 provider.ProvideGeneralMetrics(&uma_proto); 329 provider.ProvideGeneralMetrics(&uma_proto);
322 330
323 ASSERT_EQ(1, uma_proto.sampled_profile().size()); 331 ASSERT_EQ(1, uma_proto.sampled_profile().size());
324 const SampledProfile& sampled_profile = uma_proto.sampled_profile().Get(0); 332 const SampledProfile& sampled_profile = uma_proto.sampled_profile().Get(0);
325 ASSERT_TRUE(sampled_profile.has_call_stack_profile()); 333 ASSERT_TRUE(sampled_profile.has_call_stack_profile());
326 const CallStackProfile& call_stack_profile = 334 const CallStackProfile& call_stack_profile =
327 sampled_profile.call_stack_profile(); 335 sampled_profile.call_stack_profile();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 Sample& sample = profile.samples.back(); 395 Sample& sample = profile.samples.back();
388 sample.insert(sample.end(), &sample_frames[i][0], 396 sample.insert(sample.end(), &sample_frames[i][0],
389 &sample_frames[i][0] + arraysize(sample_frames[i])); 397 &sample_frames[i][0] + arraysize(sample_frames[i]));
390 } 398 }
391 399
392 profile.profile_duration = base::TimeDelta::FromMilliseconds(100); 400 profile.profile_duration = base::TimeDelta::FromMilliseconds(100);
393 profile.sampling_period = base::TimeDelta::FromMilliseconds(10); 401 profile.sampling_period = base::TimeDelta::FromMilliseconds(10);
394 402
395 CallStackProfileMetricsProvider provider; 403 CallStackProfileMetricsProvider provider;
396 provider.OnRecordingEnabled(); 404 provider.OnRecordingEnabled();
397 AppendProfiles(CallStackProfileParams(CallStackProfileParams::PROCESS_STARTUP, 405 AppendProfiles(CallStackProfileParams(CallStackProfileParams::BROWSER_PROCESS,
406 CallStackProfileParams::UI_THREAD,
407 CallStackProfileParams::PROCESS_STARTUP,
398 CallStackProfileParams::PRESERVE_ORDER), 408 CallStackProfileParams::PRESERVE_ORDER),
399 std::vector<Profile>(1, profile)); 409 std::vector<Profile>(1, profile));
400 ChromeUserMetricsExtension uma_proto; 410 ChromeUserMetricsExtension uma_proto;
401 provider.ProvideGeneralMetrics(&uma_proto); 411 provider.ProvideGeneralMetrics(&uma_proto);
402 412
403 ASSERT_EQ(1, uma_proto.sampled_profile().size()); 413 ASSERT_EQ(1, uma_proto.sampled_profile().size());
404 const SampledProfile& sampled_profile = uma_proto.sampled_profile().Get(0); 414 const SampledProfile& sampled_profile = uma_proto.sampled_profile().Get(0);
405 ASSERT_TRUE(sampled_profile.has_call_stack_profile()); 415 ASSERT_TRUE(sampled_profile.has_call_stack_profile());
406 const CallStackProfile& call_stack_profile = 416 const CallStackProfile& call_stack_profile =
407 sampled_profile.call_stack_profile(); 417 sampled_profile.call_stack_profile();
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 Profile profile; 450 Profile profile;
441 451
442 profile.samples.push_back(Sample(1, frame)); 452 profile.samples.push_back(Sample(1, frame));
443 453
444 profile.profile_duration = base::TimeDelta::FromMilliseconds(100); 454 profile.profile_duration = base::TimeDelta::FromMilliseconds(100);
445 profile.sampling_period = base::TimeDelta::FromMilliseconds(10); 455 profile.sampling_period = base::TimeDelta::FromMilliseconds(10);
446 456
447 CallStackProfileMetricsProvider provider; 457 CallStackProfileMetricsProvider provider;
448 provider.OnRecordingEnabled(); 458 provider.OnRecordingEnabled();
449 AppendProfiles( 459 AppendProfiles(
450 CallStackProfileParams(CallStackProfileParams::PROCESS_STARTUP, 460 CallStackProfileParams(CallStackProfileParams::BROWSER_PROCESS,
461 CallStackProfileParams::UI_THREAD,
462 CallStackProfileParams::PROCESS_STARTUP,
451 CallStackProfileParams::MAY_SHUFFLE), 463 CallStackProfileParams::MAY_SHUFFLE),
452 std::vector<Profile>(1, profile)); 464 std::vector<Profile>(1, profile));
453 ChromeUserMetricsExtension uma_proto; 465 ChromeUserMetricsExtension uma_proto;
454 provider.ProvideGeneralMetrics(&uma_proto); 466 provider.ProvideGeneralMetrics(&uma_proto);
455 467
456 ASSERT_EQ(1, uma_proto.sampled_profile().size()); 468 ASSERT_EQ(1, uma_proto.sampled_profile().size());
457 const SampledProfile& sampled_profile = uma_proto.sampled_profile().Get(0); 469 const SampledProfile& sampled_profile = uma_proto.sampled_profile().Get(0);
458 ASSERT_TRUE(sampled_profile.has_call_stack_profile()); 470 ASSERT_TRUE(sampled_profile.has_call_stack_profile());
459 const CallStackProfile& call_stack_profile = 471 const CallStackProfile& call_stack_profile =
460 sampled_profile.call_stack_profile(); 472 sampled_profile.call_stack_profile();
(...skipping 17 matching lines...) Expand all
478 Profile profile; 490 Profile profile;
479 profile.samples.push_back( 491 profile.samples.push_back(
480 Sample(1, Frame(0x1000, Frame::kUnknownModuleIndex))); 492 Sample(1, Frame(0x1000, Frame::kUnknownModuleIndex)));
481 493
482 profile.profile_duration = base::TimeDelta::FromMilliseconds(100); 494 profile.profile_duration = base::TimeDelta::FromMilliseconds(100);
483 // Use the sampling period to distinguish the two profiles. 495 // Use the sampling period to distinguish the two profiles.
484 profile.sampling_period = base::TimeDelta::FromMilliseconds(i); 496 profile.sampling_period = base::TimeDelta::FromMilliseconds(i);
485 497
486 provider.OnRecordingEnabled(); 498 provider.OnRecordingEnabled();
487 AppendProfiles( 499 AppendProfiles(
488 CallStackProfileParams(CallStackProfileParams::PROCESS_STARTUP, 500 CallStackProfileParams(CallStackProfileParams::BROWSER_PROCESS,
501 CallStackProfileParams::UI_THREAD,
502 CallStackProfileParams::PROCESS_STARTUP,
489 CallStackProfileParams::MAY_SHUFFLE), 503 CallStackProfileParams::MAY_SHUFFLE),
490 std::vector<Profile>(1, profile)); 504 std::vector<Profile>(1, profile));
491 ChromeUserMetricsExtension uma_proto; 505 ChromeUserMetricsExtension uma_proto;
492 provider.ProvideGeneralMetrics(&uma_proto); 506 provider.ProvideGeneralMetrics(&uma_proto);
493 507
494 ASSERT_EQ(1, uma_proto.sampled_profile().size()); 508 ASSERT_EQ(1, uma_proto.sampled_profile().size());
495 const SampledProfile& sampled_profile = uma_proto.sampled_profile().Get(0); 509 const SampledProfile& sampled_profile = uma_proto.sampled_profile().Get(0);
496 ASSERT_TRUE(sampled_profile.has_call_stack_profile()); 510 ASSERT_TRUE(sampled_profile.has_call_stack_profile());
497 const CallStackProfile& call_stack_profile = 511 const CallStackProfile& call_stack_profile =
498 sampled_profile.call_stack_profile(); 512 sampled_profile.call_stack_profile();
499 ASSERT_TRUE(call_stack_profile.has_sampling_period_ms()); 513 ASSERT_TRUE(call_stack_profile.has_sampling_period_ms());
500 EXPECT_EQ(i, call_stack_profile.sampling_period_ms()); 514 EXPECT_EQ(i, call_stack_profile.sampling_period_ms());
501 } 515 }
502 } 516 }
503 517
504 // Checks that pending profiles are provided to ProvideGeneralMetrics 518 // Checks that pending profiles are provided to ProvideGeneralMetrics
505 // when collected before CallStackProfileMetricsProvider is instantiated. 519 // when collected before CallStackProfileMetricsProvider is instantiated.
506 TEST_F(CallStackProfileMetricsProviderTest, 520 TEST_F(CallStackProfileMetricsProviderTest,
507 ProfilesProvidedWhenCollectedBeforeInstantiation) { 521 ProfilesProvidedWhenCollectedBeforeInstantiation) {
508 Profile profile; 522 Profile profile;
509 profile.samples.push_back( 523 profile.samples.push_back(
510 Sample(1, Frame(0x1000, Frame::kUnknownModuleIndex))); 524 Sample(1, Frame(0x1000, Frame::kUnknownModuleIndex)));
511 525
512 profile.profile_duration = base::TimeDelta::FromMilliseconds(100); 526 profile.profile_duration = base::TimeDelta::FromMilliseconds(100);
513 profile.sampling_period = base::TimeDelta::FromMilliseconds(10); 527 profile.sampling_period = base::TimeDelta::FromMilliseconds(10);
514 528
515 AppendProfiles( 529 AppendProfiles(
516 CallStackProfileParams(CallStackProfileParams::PROCESS_STARTUP, 530 CallStackProfileParams(CallStackProfileParams::BROWSER_PROCESS,
531 CallStackProfileParams::UI_THREAD,
532 CallStackProfileParams::PROCESS_STARTUP,
517 CallStackProfileParams::MAY_SHUFFLE), 533 CallStackProfileParams::MAY_SHUFFLE),
518 std::vector<Profile>(1, profile)); 534 std::vector<Profile>(1, profile));
519 535
520 CallStackProfileMetricsProvider provider; 536 CallStackProfileMetricsProvider provider;
521 provider.OnRecordingEnabled(); 537 provider.OnRecordingEnabled();
522 ChromeUserMetricsExtension uma_proto; 538 ChromeUserMetricsExtension uma_proto;
523 provider.ProvideGeneralMetrics(&uma_proto); 539 provider.ProvideGeneralMetrics(&uma_proto);
524 540
525 EXPECT_EQ(1, uma_proto.sampled_profile_size()); 541 EXPECT_EQ(1, uma_proto.sampled_profile_size());
526 } 542 }
527 543
528 // Checks that pending profiles are not provided to ProvideGeneralMetrics 544 // Checks that pending profiles are not provided to ProvideGeneralMetrics
529 // while recording is disabled. 545 // while recording is disabled.
530 TEST_F(CallStackProfileMetricsProviderTest, ProfilesNotProvidedWhileDisabled) { 546 TEST_F(CallStackProfileMetricsProviderTest, ProfilesNotProvidedWhileDisabled) {
531 Profile profile; 547 Profile profile;
532 profile.samples.push_back( 548 profile.samples.push_back(
533 Sample(1, Frame(0x1000, Frame::kUnknownModuleIndex))); 549 Sample(1, Frame(0x1000, Frame::kUnknownModuleIndex)));
534 550
535 profile.profile_duration = base::TimeDelta::FromMilliseconds(100); 551 profile.profile_duration = base::TimeDelta::FromMilliseconds(100);
536 profile.sampling_period = base::TimeDelta::FromMilliseconds(10); 552 profile.sampling_period = base::TimeDelta::FromMilliseconds(10);
537 553
538 CallStackProfileMetricsProvider provider; 554 CallStackProfileMetricsProvider provider;
539 provider.OnRecordingDisabled(); 555 provider.OnRecordingDisabled();
540 AppendProfiles( 556 AppendProfiles(
541 CallStackProfileParams(CallStackProfileParams::PROCESS_STARTUP, 557 CallStackProfileParams(CallStackProfileParams::BROWSER_PROCESS,
558 CallStackProfileParams::UI_THREAD,
559 CallStackProfileParams::PROCESS_STARTUP,
542 CallStackProfileParams::MAY_SHUFFLE), 560 CallStackProfileParams::MAY_SHUFFLE),
543 std::vector<Profile>(1, profile)); 561 std::vector<Profile>(1, profile));
544 ChromeUserMetricsExtension uma_proto; 562 ChromeUserMetricsExtension uma_proto;
545 provider.ProvideGeneralMetrics(&uma_proto); 563 provider.ProvideGeneralMetrics(&uma_proto);
546 564
547 EXPECT_EQ(0, uma_proto.sampled_profile_size()); 565 EXPECT_EQ(0, uma_proto.sampled_profile_size());
548 } 566 }
549 567
550 // Checks that pending profiles are not provided to ProvideGeneralMetrics 568 // Checks that pending profiles are not provided to ProvideGeneralMetrics
551 // if recording is disabled while profiling. 569 // if recording is disabled while profiling.
552 TEST_F(CallStackProfileMetricsProviderTest, 570 TEST_F(CallStackProfileMetricsProviderTest,
553 ProfilesNotProvidedAfterChangeToDisabled) { 571 ProfilesNotProvidedAfterChangeToDisabled) {
554 Profile profile; 572 Profile profile;
555 profile.samples.push_back( 573 profile.samples.push_back(
556 Sample(1, Frame(0x1000, Frame::kUnknownModuleIndex))); 574 Sample(1, Frame(0x1000, Frame::kUnknownModuleIndex)));
557 575
558 profile.profile_duration = base::TimeDelta::FromMilliseconds(100); 576 profile.profile_duration = base::TimeDelta::FromMilliseconds(100);
559 profile.sampling_period = base::TimeDelta::FromMilliseconds(10); 577 profile.sampling_period = base::TimeDelta::FromMilliseconds(10);
560 578
561 CallStackProfileMetricsProvider provider; 579 CallStackProfileMetricsProvider provider;
562 provider.OnRecordingEnabled(); 580 provider.OnRecordingEnabled();
563 base::StackSamplingProfiler::CompletedCallback callback = 581 base::StackSamplingProfiler::CompletedCallback callback =
564 CallStackProfileMetricsProvider::GetProfilerCallback( 582 CallStackProfileMetricsProvider::GetProfilerCallback(
565 CallStackProfileParams(CallStackProfileParams::PROCESS_STARTUP, 583 CallStackProfileParams(CallStackProfileParams::BROWSER_PROCESS,
584 CallStackProfileParams::UI_THREAD,
585 CallStackProfileParams::PROCESS_STARTUP,
566 CallStackProfileParams::MAY_SHUFFLE)); 586 CallStackProfileParams::MAY_SHUFFLE));
567 587
568 provider.OnRecordingDisabled(); 588 provider.OnRecordingDisabled();
569 callback.Run(std::vector<Profile>(1, profile)); 589 callback.Run(std::vector<Profile>(1, profile));
570 ChromeUserMetricsExtension uma_proto; 590 ChromeUserMetricsExtension uma_proto;
571 provider.ProvideGeneralMetrics(&uma_proto); 591 provider.ProvideGeneralMetrics(&uma_proto);
572 592
573 EXPECT_EQ(0, uma_proto.sampled_profile_size()); 593 EXPECT_EQ(0, uma_proto.sampled_profile_size());
574 } 594 }
575 595
576 // Checks that pending profiles are not provided to ProvideGeneralMetrics if 596 // Checks that pending profiles are not provided to ProvideGeneralMetrics if
577 // recording is enabled, but then disabled and reenabled while profiling. 597 // recording is enabled, but then disabled and reenabled while profiling.
578 TEST_F(CallStackProfileMetricsProviderTest, 598 TEST_F(CallStackProfileMetricsProviderTest,
579 ProfilesNotProvidedAfterChangeToDisabledThenEnabled) { 599 ProfilesNotProvidedAfterChangeToDisabledThenEnabled) {
580 Profile profile; 600 Profile profile;
581 profile.samples.push_back( 601 profile.samples.push_back(
582 Sample(1, Frame(0x1000, Frame::kUnknownModuleIndex))); 602 Sample(1, Frame(0x1000, Frame::kUnknownModuleIndex)));
583 603
584 profile.profile_duration = base::TimeDelta::FromMilliseconds(100); 604 profile.profile_duration = base::TimeDelta::FromMilliseconds(100);
585 profile.sampling_period = base::TimeDelta::FromMilliseconds(10); 605 profile.sampling_period = base::TimeDelta::FromMilliseconds(10);
586 606
587 CallStackProfileMetricsProvider provider; 607 CallStackProfileMetricsProvider provider;
588 provider.OnRecordingEnabled(); 608 provider.OnRecordingEnabled();
589 base::StackSamplingProfiler::CompletedCallback callback = 609 base::StackSamplingProfiler::CompletedCallback callback =
590 CallStackProfileMetricsProvider::GetProfilerCallback( 610 CallStackProfileMetricsProvider::GetProfilerCallback(
591 CallStackProfileParams(CallStackProfileParams::PROCESS_STARTUP, 611 CallStackProfileParams(CallStackProfileParams::BROWSER_PROCESS,
612 CallStackProfileParams::UI_THREAD,
613 CallStackProfileParams::PROCESS_STARTUP,
592 CallStackProfileParams::MAY_SHUFFLE)); 614 CallStackProfileParams::MAY_SHUFFLE));
593 615
594 provider.OnRecordingDisabled(); 616 provider.OnRecordingDisabled();
595 provider.OnRecordingEnabled(); 617 provider.OnRecordingEnabled();
596 callback.Run(std::vector<Profile>(1, profile)); 618 callback.Run(std::vector<Profile>(1, profile));
597 ChromeUserMetricsExtension uma_proto; 619 ChromeUserMetricsExtension uma_proto;
598 provider.ProvideGeneralMetrics(&uma_proto); 620 provider.ProvideGeneralMetrics(&uma_proto);
599 621
600 EXPECT_EQ(0, uma_proto.sampled_profile_size()); 622 EXPECT_EQ(0, uma_proto.sampled_profile_size());
601 } 623 }
602 624
603 // Checks that pending profiles are not provided to ProvideGeneralMetrics 625 // Checks that pending profiles are not provided to ProvideGeneralMetrics
604 // if recording is disabled, but then enabled while profiling. 626 // if recording is disabled, but then enabled while profiling.
605 TEST_F(CallStackProfileMetricsProviderTest, 627 TEST_F(CallStackProfileMetricsProviderTest,
606 ProfilesNotProvidedAfterChangeFromDisabled) { 628 ProfilesNotProvidedAfterChangeFromDisabled) {
607 Profile profile; 629 Profile profile;
608 profile.samples.push_back( 630 profile.samples.push_back(
609 Sample(1, Frame(0x1000, Frame::kUnknownModuleIndex))); 631 Sample(1, Frame(0x1000, Frame::kUnknownModuleIndex)));
610 632
611 profile.profile_duration = base::TimeDelta::FromMilliseconds(100); 633 profile.profile_duration = base::TimeDelta::FromMilliseconds(100);
612 profile.sampling_period = base::TimeDelta::FromMilliseconds(10); 634 profile.sampling_period = base::TimeDelta::FromMilliseconds(10);
613 635
614 CallStackProfileMetricsProvider provider; 636 CallStackProfileMetricsProvider provider;
615 provider.OnRecordingDisabled(); 637 provider.OnRecordingDisabled();
616 base::StackSamplingProfiler::CompletedCallback callback = 638 base::StackSamplingProfiler::CompletedCallback callback =
617 CallStackProfileMetricsProvider::GetProfilerCallback( 639 CallStackProfileMetricsProvider::GetProfilerCallback(
618 CallStackProfileParams(CallStackProfileParams::PROCESS_STARTUP, 640 CallStackProfileParams(CallStackProfileParams::BROWSER_PROCESS,
641 CallStackProfileParams::UI_THREAD,
642 CallStackProfileParams::PROCESS_STARTUP,
619 CallStackProfileParams::MAY_SHUFFLE)); 643 CallStackProfileParams::MAY_SHUFFLE));
620 644
621 provider.OnRecordingEnabled(); 645 provider.OnRecordingEnabled();
622 callback.Run(std::vector<Profile>(1, profile)); 646 callback.Run(std::vector<Profile>(1, profile));
623 ChromeUserMetricsExtension uma_proto; 647 ChromeUserMetricsExtension uma_proto;
624 provider.ProvideGeneralMetrics(&uma_proto); 648 provider.ProvideGeneralMetrics(&uma_proto);
625 649
626 EXPECT_EQ(0, uma_proto.sampled_profile_size()); 650 EXPECT_EQ(0, uma_proto.sampled_profile_size());
627 } 651 }
628 652
629 } // namespace metrics 653 } // namespace metrics
OLDNEW
« no previous file with comments | « components/metrics/call_stack_profile_metrics_provider.cc ('k') | components/metrics/call_stack_profile_params.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698