| OLD | NEW |
| 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 <utility> | 10 #include <utility> |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 std::vector<Profile> profiles; | 186 std::vector<Profile> profiles; |
| 187 for (size_t i = 0; i < arraysize(profile_sample_frames); ++i) { | 187 for (size_t i = 0; i < arraysize(profile_sample_frames); ++i) { |
| 188 Profile profile; | 188 Profile profile; |
| 189 profile.modules.insert( | 189 profile.modules.insert( |
| 190 profile.modules.end(), &profile_modules[i][0], | 190 profile.modules.end(), &profile_modules[i][0], |
| 191 &profile_modules[i][0] + arraysize(profile_modules[i])); | 191 &profile_modules[i][0] + arraysize(profile_modules[i])); |
| 192 | 192 |
| 193 for (size_t j = 0; j < arraysize(profile_sample_frames[i]); ++j) { | 193 for (size_t j = 0; j < arraysize(profile_sample_frames[i]); ++j) { |
| 194 profile.samples.push_back(Sample()); | 194 profile.samples.push_back(Sample()); |
| 195 Sample& sample = profile.samples.back(); | 195 Sample& sample = profile.samples.back(); |
| 196 sample.insert(sample.end(), &profile_sample_frames[i][j][0], | 196 sample.frames.insert(sample.frames.end(), &profile_sample_frames[i][j][0], |
| 197 &profile_sample_frames[i][j][0] + | 197 &profile_sample_frames[i][j][0] + |
| 198 arraysize(profile_sample_frames[i][j])); | 198 arraysize(profile_sample_frames[i][j])); |
| 199 } | 199 } |
| 200 | 200 |
| 201 profile.profile_duration = profile_durations[i]; | 201 profile.profile_duration = profile_durations[i]; |
| 202 profile.sampling_period = profile_sampling_periods[i]; | 202 profile.sampling_period = profile_sampling_periods[i]; |
| 203 | 203 |
| 204 profiles.push_back(std::move(profile)); | 204 profiles.push_back(std::move(profile)); |
| 205 } | 205 } |
| 206 | 206 |
| 207 CallStackProfileMetricsProvider provider; | 207 CallStackProfileMetricsProvider provider; |
| 208 provider.OnRecordingEnabled(); | 208 provider.OnRecordingEnabled(); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 { Frame(module_base_address + 0x10, 0) } | 305 { Frame(module_base_address + 0x10, 0) } |
| 306 }; | 306 }; |
| 307 | 307 |
| 308 Profile profile; | 308 Profile profile; |
| 309 profile.modules.insert(profile.modules.end(), &modules[0], | 309 profile.modules.insert(profile.modules.end(), &modules[0], |
| 310 &modules[0] + arraysize(modules)); | 310 &modules[0] + arraysize(modules)); |
| 311 | 311 |
| 312 for (size_t i = 0; i < arraysize(sample_frames); ++i) { | 312 for (size_t i = 0; i < arraysize(sample_frames); ++i) { |
| 313 profile.samples.push_back(Sample()); | 313 profile.samples.push_back(Sample()); |
| 314 Sample& sample = profile.samples.back(); | 314 Sample& sample = profile.samples.back(); |
| 315 sample.insert(sample.end(), &sample_frames[i][0], | 315 sample.frames.insert(sample.frames.end(), &sample_frames[i][0], |
| 316 &sample_frames[i][0] + arraysize(sample_frames[i])); | 316 &sample_frames[i][0] + arraysize(sample_frames[i])); |
| 317 } | 317 } |
| 318 | 318 |
| 319 profile.profile_duration = base::TimeDelta::FromMilliseconds(100); | 319 profile.profile_duration = base::TimeDelta::FromMilliseconds(100); |
| 320 profile.sampling_period = base::TimeDelta::FromMilliseconds(10); | 320 profile.sampling_period = base::TimeDelta::FromMilliseconds(10); |
| 321 Profiles profiles; | 321 Profiles profiles; |
| 322 profiles.push_back(std::move(profile)); | 322 profiles.push_back(std::move(profile)); |
| 323 | 323 |
| 324 CallStackProfileMetricsProvider provider; | 324 CallStackProfileMetricsProvider provider; |
| 325 provider.OnRecordingEnabled(); | 325 provider.OnRecordingEnabled(); |
| 326 AppendProfiles( | 326 AppendProfiles( |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 { Frame(module_base_address + 0x10, 0) } | 390 { Frame(module_base_address + 0x10, 0) } |
| 391 }; | 391 }; |
| 392 | 392 |
| 393 Profile profile; | 393 Profile profile; |
| 394 profile.modules.insert(profile.modules.end(), &modules[0], | 394 profile.modules.insert(profile.modules.end(), &modules[0], |
| 395 &modules[0] + arraysize(modules)); | 395 &modules[0] + arraysize(modules)); |
| 396 | 396 |
| 397 for (size_t i = 0; i < arraysize(sample_frames); ++i) { | 397 for (size_t i = 0; i < arraysize(sample_frames); ++i) { |
| 398 profile.samples.push_back(Sample()); | 398 profile.samples.push_back(Sample()); |
| 399 Sample& sample = profile.samples.back(); | 399 Sample& sample = profile.samples.back(); |
| 400 sample.insert(sample.end(), &sample_frames[i][0], | 400 sample.frames.insert(sample.frames.end(), &sample_frames[i][0], |
| 401 &sample_frames[i][0] + arraysize(sample_frames[i])); | 401 &sample_frames[i][0] + arraysize(sample_frames[i])); |
| 402 } | 402 } |
| 403 | 403 |
| 404 profile.profile_duration = base::TimeDelta::FromMilliseconds(100); | 404 profile.profile_duration = base::TimeDelta::FromMilliseconds(100); |
| 405 profile.sampling_period = base::TimeDelta::FromMilliseconds(10); | 405 profile.sampling_period = base::TimeDelta::FromMilliseconds(10); |
| 406 Profiles profiles; | 406 Profiles profiles; |
| 407 profiles.push_back(std::move(profile)); | 407 profiles.push_back(std::move(profile)); |
| 408 | 408 |
| 409 CallStackProfileMetricsProvider provider; | 409 CallStackProfileMetricsProvider provider; |
| 410 provider.OnRecordingEnabled(); | 410 provider.OnRecordingEnabled(); |
| 411 AppendProfiles(CallStackProfileParams(CallStackProfileParams::BROWSER_PROCESS, | 411 AppendProfiles(CallStackProfileParams(CallStackProfileParams::BROWSER_PROCESS, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 entry.address()); | 444 entry.address()); |
| 445 ASSERT_TRUE(entry.has_module_id_index()); | 445 ASSERT_TRUE(entry.has_module_id_index()); |
| 446 EXPECT_EQ(sample_frames[i][j].module_index, | 446 EXPECT_EQ(sample_frames[i][j].module_index, |
| 447 static_cast<size_t>(entry.module_id_index())); | 447 static_cast<size_t>(entry.module_id_index())); |
| 448 } | 448 } |
| 449 } | 449 } |
| 450 } | 450 } |
| 451 | 451 |
| 452 // Checks that unknown modules produce an empty Entry. | 452 // Checks that unknown modules produce an empty Entry. |
| 453 TEST_F(CallStackProfileMetricsProviderTest, UnknownModule) { | 453 TEST_F(CallStackProfileMetricsProviderTest, UnknownModule) { |
| 454 const Frame frame(0x1000, Frame::kUnknownModuleIndex); | |
| 455 | |
| 456 Profile profile; | 454 Profile profile; |
| 457 | 455 profile.samples.push_back(Sample(Frame(0x1000, Frame::kUnknownModuleIndex))); |
| 458 profile.samples.push_back(Sample(1, frame)); | |
| 459 | |
| 460 profile.profile_duration = base::TimeDelta::FromMilliseconds(100); | 456 profile.profile_duration = base::TimeDelta::FromMilliseconds(100); |
| 461 profile.sampling_period = base::TimeDelta::FromMilliseconds(10); | 457 profile.sampling_period = base::TimeDelta::FromMilliseconds(10); |
| 462 Profiles profiles; | 458 Profiles profiles; |
| 463 profiles.push_back(std::move(profile)); | 459 profiles.push_back(std::move(profile)); |
| 464 | 460 |
| 465 CallStackProfileMetricsProvider provider; | 461 CallStackProfileMetricsProvider provider; |
| 466 provider.OnRecordingEnabled(); | 462 provider.OnRecordingEnabled(); |
| 467 AppendProfiles( | 463 AppendProfiles( |
| 468 CallStackProfileParams(CallStackProfileParams::BROWSER_PROCESS, | 464 CallStackProfileParams(CallStackProfileParams::BROWSER_PROCESS, |
| 469 CallStackProfileParams::UI_THREAD, | 465 CallStackProfileParams::UI_THREAD, |
| (...skipping 20 matching lines...) Expand all Loading... |
| 490 EXPECT_FALSE(entry.has_module_id_index()); | 486 EXPECT_FALSE(entry.has_module_id_index()); |
| 491 } | 487 } |
| 492 | 488 |
| 493 // Checks that pending profiles are only passed back to ProvideGeneralMetrics | 489 // Checks that pending profiles are only passed back to ProvideGeneralMetrics |
| 494 // once. | 490 // once. |
| 495 TEST_F(CallStackProfileMetricsProviderTest, ProfilesProvidedOnlyOnce) { | 491 TEST_F(CallStackProfileMetricsProviderTest, ProfilesProvidedOnlyOnce) { |
| 496 CallStackProfileMetricsProvider provider; | 492 CallStackProfileMetricsProvider provider; |
| 497 for (int i = 0; i < 2; ++i) { | 493 for (int i = 0; i < 2; ++i) { |
| 498 Profile profile; | 494 Profile profile; |
| 499 profile.samples.push_back( | 495 profile.samples.push_back( |
| 500 Sample(1, Frame(0x1000, Frame::kUnknownModuleIndex))); | 496 Sample((Frame(0x1000, Frame::kUnknownModuleIndex)))); |
| 501 | 497 |
| 502 profile.profile_duration = base::TimeDelta::FromMilliseconds(100); | 498 profile.profile_duration = base::TimeDelta::FromMilliseconds(100); |
| 503 // Use the sampling period to distinguish the two profiles. | 499 // Use the sampling period to distinguish the two profiles. |
| 504 profile.sampling_period = base::TimeDelta::FromMilliseconds(i); | 500 profile.sampling_period = base::TimeDelta::FromMilliseconds(i); |
| 505 Profiles profiles; | 501 Profiles profiles; |
| 506 profiles.push_back(std::move(profile)); | 502 profiles.push_back(std::move(profile)); |
| 507 | 503 |
| 508 provider.OnRecordingEnabled(); | 504 provider.OnRecordingEnabled(); |
| 509 AppendProfiles( | 505 AppendProfiles( |
| 510 CallStackProfileParams(CallStackProfileParams::BROWSER_PROCESS, | 506 CallStackProfileParams(CallStackProfileParams::BROWSER_PROCESS, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 523 ASSERT_TRUE(call_stack_profile.has_sampling_period_ms()); | 519 ASSERT_TRUE(call_stack_profile.has_sampling_period_ms()); |
| 524 EXPECT_EQ(i, call_stack_profile.sampling_period_ms()); | 520 EXPECT_EQ(i, call_stack_profile.sampling_period_ms()); |
| 525 } | 521 } |
| 526 } | 522 } |
| 527 | 523 |
| 528 // Checks that pending profiles are provided to ProvideGeneralMetrics | 524 // Checks that pending profiles are provided to ProvideGeneralMetrics |
| 529 // when collected before CallStackProfileMetricsProvider is instantiated. | 525 // when collected before CallStackProfileMetricsProvider is instantiated. |
| 530 TEST_F(CallStackProfileMetricsProviderTest, | 526 TEST_F(CallStackProfileMetricsProviderTest, |
| 531 ProfilesProvidedWhenCollectedBeforeInstantiation) { | 527 ProfilesProvidedWhenCollectedBeforeInstantiation) { |
| 532 Profile profile; | 528 Profile profile; |
| 533 profile.samples.push_back( | 529 profile.samples.push_back(Sample(Frame(0x1000, Frame::kUnknownModuleIndex))); |
| 534 Sample(1, Frame(0x1000, Frame::kUnknownModuleIndex))); | |
| 535 | |
| 536 profile.profile_duration = base::TimeDelta::FromMilliseconds(100); | 530 profile.profile_duration = base::TimeDelta::FromMilliseconds(100); |
| 537 profile.sampling_period = base::TimeDelta::FromMilliseconds(10); | 531 profile.sampling_period = base::TimeDelta::FromMilliseconds(10); |
| 538 Profiles profiles; | 532 Profiles profiles; |
| 539 profiles.push_back(std::move(profile)); | 533 profiles.push_back(std::move(profile)); |
| 540 | 534 |
| 541 AppendProfiles( | 535 AppendProfiles( |
| 542 CallStackProfileParams(CallStackProfileParams::BROWSER_PROCESS, | 536 CallStackProfileParams(CallStackProfileParams::BROWSER_PROCESS, |
| 543 CallStackProfileParams::UI_THREAD, | 537 CallStackProfileParams::UI_THREAD, |
| 544 CallStackProfileParams::PROCESS_STARTUP, | 538 CallStackProfileParams::PROCESS_STARTUP, |
| 545 CallStackProfileParams::MAY_SHUFFLE), | 539 CallStackProfileParams::MAY_SHUFFLE), |
| 546 std::move(profiles)); | 540 std::move(profiles)); |
| 547 | 541 |
| 548 CallStackProfileMetricsProvider provider; | 542 CallStackProfileMetricsProvider provider; |
| 549 provider.OnRecordingEnabled(); | 543 provider.OnRecordingEnabled(); |
| 550 ChromeUserMetricsExtension uma_proto; | 544 ChromeUserMetricsExtension uma_proto; |
| 551 provider.ProvideGeneralMetrics(&uma_proto); | 545 provider.ProvideGeneralMetrics(&uma_proto); |
| 552 | 546 |
| 553 EXPECT_EQ(1, uma_proto.sampled_profile_size()); | 547 EXPECT_EQ(1, uma_proto.sampled_profile_size()); |
| 554 } | 548 } |
| 555 | 549 |
| 556 // Checks that pending profiles are not provided to ProvideGeneralMetrics | 550 // Checks that pending profiles are not provided to ProvideGeneralMetrics |
| 557 // while recording is disabled. | 551 // while recording is disabled. |
| 558 TEST_F(CallStackProfileMetricsProviderTest, ProfilesNotProvidedWhileDisabled) { | 552 TEST_F(CallStackProfileMetricsProviderTest, ProfilesNotProvidedWhileDisabled) { |
| 559 Profile profile; | 553 Profile profile; |
| 560 profile.samples.push_back( | 554 profile.samples.push_back(Sample(Frame(0x1000, Frame::kUnknownModuleIndex))); |
| 561 Sample(1, Frame(0x1000, Frame::kUnknownModuleIndex))); | |
| 562 | |
| 563 profile.profile_duration = base::TimeDelta::FromMilliseconds(100); | 555 profile.profile_duration = base::TimeDelta::FromMilliseconds(100); |
| 564 profile.sampling_period = base::TimeDelta::FromMilliseconds(10); | 556 profile.sampling_period = base::TimeDelta::FromMilliseconds(10); |
| 565 Profiles profiles; | 557 Profiles profiles; |
| 566 profiles.push_back(std::move(profile)); | 558 profiles.push_back(std::move(profile)); |
| 567 | 559 |
| 568 CallStackProfileMetricsProvider provider; | 560 CallStackProfileMetricsProvider provider; |
| 569 provider.OnRecordingDisabled(); | 561 provider.OnRecordingDisabled(); |
| 570 AppendProfiles( | 562 AppendProfiles( |
| 571 CallStackProfileParams(CallStackProfileParams::BROWSER_PROCESS, | 563 CallStackProfileParams(CallStackProfileParams::BROWSER_PROCESS, |
| 572 CallStackProfileParams::UI_THREAD, | 564 CallStackProfileParams::UI_THREAD, |
| 573 CallStackProfileParams::PROCESS_STARTUP, | 565 CallStackProfileParams::PROCESS_STARTUP, |
| 574 CallStackProfileParams::MAY_SHUFFLE), | 566 CallStackProfileParams::MAY_SHUFFLE), |
| 575 std::move(profiles)); | 567 std::move(profiles)); |
| 576 ChromeUserMetricsExtension uma_proto; | 568 ChromeUserMetricsExtension uma_proto; |
| 577 provider.ProvideGeneralMetrics(&uma_proto); | 569 provider.ProvideGeneralMetrics(&uma_proto); |
| 578 | 570 |
| 579 EXPECT_EQ(0, uma_proto.sampled_profile_size()); | 571 EXPECT_EQ(0, uma_proto.sampled_profile_size()); |
| 580 } | 572 } |
| 581 | 573 |
| 582 // Checks that pending profiles are not provided to ProvideGeneralMetrics | 574 // Checks that pending profiles are not provided to ProvideGeneralMetrics |
| 583 // if recording is disabled while profiling. | 575 // if recording is disabled while profiling. |
| 584 TEST_F(CallStackProfileMetricsProviderTest, | 576 TEST_F(CallStackProfileMetricsProviderTest, |
| 585 ProfilesNotProvidedAfterChangeToDisabled) { | 577 ProfilesNotProvidedAfterChangeToDisabled) { |
| 586 Profile profile; | 578 Profile profile; |
| 587 profile.samples.push_back( | 579 profile.samples.push_back(Sample(Frame(0x1000, Frame::kUnknownModuleIndex))); |
| 588 Sample(1, Frame(0x1000, Frame::kUnknownModuleIndex))); | |
| 589 | |
| 590 profile.profile_duration = base::TimeDelta::FromMilliseconds(100); | 580 profile.profile_duration = base::TimeDelta::FromMilliseconds(100); |
| 591 profile.sampling_period = base::TimeDelta::FromMilliseconds(10); | 581 profile.sampling_period = base::TimeDelta::FromMilliseconds(10); |
| 592 | 582 |
| 593 CallStackProfileMetricsProvider provider; | 583 CallStackProfileMetricsProvider provider; |
| 594 provider.OnRecordingEnabled(); | 584 provider.OnRecordingEnabled(); |
| 595 base::StackSamplingProfiler::CompletedCallback callback = | 585 base::StackSamplingProfiler::CompletedCallback callback = |
| 596 CallStackProfileMetricsProvider::GetProfilerCallback( | 586 CallStackProfileMetricsProvider::GetProfilerCallback( |
| 597 CallStackProfileParams(CallStackProfileParams::BROWSER_PROCESS, | 587 CallStackProfileParams(CallStackProfileParams::BROWSER_PROCESS, |
| 598 CallStackProfileParams::UI_THREAD, | 588 CallStackProfileParams::UI_THREAD, |
| 599 CallStackProfileParams::PROCESS_STARTUP, | 589 CallStackProfileParams::PROCESS_STARTUP, |
| 600 CallStackProfileParams::MAY_SHUFFLE)); | 590 CallStackProfileParams::MAY_SHUFFLE)); |
| 601 | 591 |
| 602 provider.OnRecordingDisabled(); | 592 provider.OnRecordingDisabled(); |
| 603 Profiles profiles; | 593 Profiles profiles; |
| 604 profiles.push_back(std::move(profile)); | 594 profiles.push_back(std::move(profile)); |
| 605 callback.Run(std::move(profiles)); | 595 callback.Run(std::move(profiles)); |
| 606 ChromeUserMetricsExtension uma_proto; | 596 ChromeUserMetricsExtension uma_proto; |
| 607 provider.ProvideGeneralMetrics(&uma_proto); | 597 provider.ProvideGeneralMetrics(&uma_proto); |
| 608 | 598 |
| 609 EXPECT_EQ(0, uma_proto.sampled_profile_size()); | 599 EXPECT_EQ(0, uma_proto.sampled_profile_size()); |
| 610 } | 600 } |
| 611 | 601 |
| 612 // Checks that pending profiles are not provided to ProvideGeneralMetrics if | 602 // Checks that pending profiles are not provided to ProvideGeneralMetrics if |
| 613 // recording is enabled, but then disabled and reenabled while profiling. | 603 // recording is enabled, but then disabled and reenabled while profiling. |
| 614 TEST_F(CallStackProfileMetricsProviderTest, | 604 TEST_F(CallStackProfileMetricsProviderTest, |
| 615 ProfilesNotProvidedAfterChangeToDisabledThenEnabled) { | 605 ProfilesNotProvidedAfterChangeToDisabledThenEnabled) { |
| 616 Profile profile; | 606 Profile profile; |
| 617 profile.samples.push_back( | 607 profile.samples.push_back(Sample(Frame(0x1000, Frame::kUnknownModuleIndex))); |
| 618 Sample(1, Frame(0x1000, Frame::kUnknownModuleIndex))); | |
| 619 | |
| 620 profile.profile_duration = base::TimeDelta::FromMilliseconds(100); | 608 profile.profile_duration = base::TimeDelta::FromMilliseconds(100); |
| 621 profile.sampling_period = base::TimeDelta::FromMilliseconds(10); | 609 profile.sampling_period = base::TimeDelta::FromMilliseconds(10); |
| 622 | 610 |
| 623 CallStackProfileMetricsProvider provider; | 611 CallStackProfileMetricsProvider provider; |
| 624 provider.OnRecordingEnabled(); | 612 provider.OnRecordingEnabled(); |
| 625 base::StackSamplingProfiler::CompletedCallback callback = | 613 base::StackSamplingProfiler::CompletedCallback callback = |
| 626 CallStackProfileMetricsProvider::GetProfilerCallback( | 614 CallStackProfileMetricsProvider::GetProfilerCallback( |
| 627 CallStackProfileParams(CallStackProfileParams::BROWSER_PROCESS, | 615 CallStackProfileParams(CallStackProfileParams::BROWSER_PROCESS, |
| 628 CallStackProfileParams::UI_THREAD, | 616 CallStackProfileParams::UI_THREAD, |
| 629 CallStackProfileParams::PROCESS_STARTUP, | 617 CallStackProfileParams::PROCESS_STARTUP, |
| 630 CallStackProfileParams::MAY_SHUFFLE)); | 618 CallStackProfileParams::MAY_SHUFFLE)); |
| 631 | 619 |
| 632 provider.OnRecordingDisabled(); | 620 provider.OnRecordingDisabled(); |
| 633 provider.OnRecordingEnabled(); | 621 provider.OnRecordingEnabled(); |
| 634 Profiles profiles; | 622 Profiles profiles; |
| 635 profiles.push_back(std::move(profile)); | 623 profiles.push_back(std::move(profile)); |
| 636 callback.Run(std::move(profiles)); | 624 callback.Run(std::move(profiles)); |
| 637 ChromeUserMetricsExtension uma_proto; | 625 ChromeUserMetricsExtension uma_proto; |
| 638 provider.ProvideGeneralMetrics(&uma_proto); | 626 provider.ProvideGeneralMetrics(&uma_proto); |
| 639 | 627 |
| 640 EXPECT_EQ(0, uma_proto.sampled_profile_size()); | 628 EXPECT_EQ(0, uma_proto.sampled_profile_size()); |
| 641 } | 629 } |
| 642 | 630 |
| 643 // Checks that pending profiles are not provided to ProvideGeneralMetrics | 631 // Checks that pending profiles are not provided to ProvideGeneralMetrics |
| 644 // if recording is disabled, but then enabled while profiling. | 632 // if recording is disabled, but then enabled while profiling. |
| 645 TEST_F(CallStackProfileMetricsProviderTest, | 633 TEST_F(CallStackProfileMetricsProviderTest, |
| 646 ProfilesNotProvidedAfterChangeFromDisabled) { | 634 ProfilesNotProvidedAfterChangeFromDisabled) { |
| 647 Profile profile; | 635 Profile profile; |
| 648 profile.samples.push_back( | 636 profile.samples.push_back(Sample(Frame(0x1000, Frame::kUnknownModuleIndex))); |
| 649 Sample(1, Frame(0x1000, Frame::kUnknownModuleIndex))); | |
| 650 | |
| 651 profile.profile_duration = base::TimeDelta::FromMilliseconds(100); | 637 profile.profile_duration = base::TimeDelta::FromMilliseconds(100); |
| 652 profile.sampling_period = base::TimeDelta::FromMilliseconds(10); | 638 profile.sampling_period = base::TimeDelta::FromMilliseconds(10); |
| 653 | 639 |
| 654 CallStackProfileMetricsProvider provider; | 640 CallStackProfileMetricsProvider provider; |
| 655 provider.OnRecordingDisabled(); | 641 provider.OnRecordingDisabled(); |
| 656 base::StackSamplingProfiler::CompletedCallback callback = | 642 base::StackSamplingProfiler::CompletedCallback callback = |
| 657 CallStackProfileMetricsProvider::GetProfilerCallback( | 643 CallStackProfileMetricsProvider::GetProfilerCallback( |
| 658 CallStackProfileParams(CallStackProfileParams::BROWSER_PROCESS, | 644 CallStackProfileParams(CallStackProfileParams::BROWSER_PROCESS, |
| 659 CallStackProfileParams::UI_THREAD, | 645 CallStackProfileParams::UI_THREAD, |
| 660 CallStackProfileParams::PROCESS_STARTUP, | 646 CallStackProfileParams::PROCESS_STARTUP, |
| 661 CallStackProfileParams::MAY_SHUFFLE)); | 647 CallStackProfileParams::MAY_SHUFFLE)); |
| 662 | 648 |
| 663 provider.OnRecordingEnabled(); | 649 provider.OnRecordingEnabled(); |
| 664 Profiles profiles; | 650 Profiles profiles; |
| 665 profiles.push_back(std::move(profile)); | 651 profiles.push_back(std::move(profile)); |
| 666 callback.Run(std::move(profiles)); | 652 callback.Run(std::move(profiles)); |
| 667 ChromeUserMetricsExtension uma_proto; | 653 ChromeUserMetricsExtension uma_proto; |
| 668 provider.ProvideGeneralMetrics(&uma_proto); | 654 provider.ProvideGeneralMetrics(&uma_proto); |
| 669 | 655 |
| 670 EXPECT_EQ(0, uma_proto.sampled_profile_size()); | 656 EXPECT_EQ(0, uma_proto.sampled_profile_size()); |
| 671 } | 657 } |
| 672 | 658 |
| 673 } // namespace metrics | 659 } // namespace metrics |
| OLD | NEW |