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