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

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

Issue 2927593002: Make stack sampling profiler sample beyond startup. (Closed)
Patch Set: Remove debug log statements. Created 3 years, 5 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/child_call_stack_profile_collector.h" 5 #include "components/metrics/child_call_stack_profile_collector.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 12 matching lines...) Expand all
23 23
24 24
25 } // namespace 25 } // namespace
26 26
27 class ChildCallStackProfileCollectorTest : public testing::Test { 27 class ChildCallStackProfileCollectorTest : public testing::Test {
28 protected: 28 protected:
29 class Receiver : public mojom::CallStackProfileCollector { 29 class Receiver : public mojom::CallStackProfileCollector {
30 public: 30 public:
31 using CallStackProfile = base::StackSamplingProfiler::CallStackProfile; 31 using CallStackProfile = base::StackSamplingProfiler::CallStackProfile;
32 32
33 Receiver(mojom::CallStackProfileCollectorRequest request) 33 explicit Receiver(mojom::CallStackProfileCollectorRequest request)
34 : binding_(this, std::move(request)) {} 34 : binding_(this, std::move(request)) {}
35 ~Receiver() override {} 35 ~Receiver() override {}
36 36
37 void Collect(const CallStackProfileParams& params, 37 void Collect(const CallStackProfileParams& params,
38 base::TimeTicks start_timestamp, 38 base::TimeTicks start_timestamp,
39 std::vector<CallStackProfile> profiles) override { 39 std::vector<CallStackProfile> profiles) override {
40 this->profiles.push_back(ChildCallStackProfileCollector::ProfilesState( 40 this->profiles.push_back(ChildCallStackProfileCollector::ProfilesState(
41 params, 41 params,
42 start_timestamp, 42 start_timestamp,
43 std::move(profiles))); 43 std::move(profiles)));
(...skipping 22 matching lines...) Expand all
66 const std::vector<ChildCallStackProfileCollector::ProfilesState>& 66 const std::vector<ChildCallStackProfileCollector::ProfilesState>&
67 profiles() const { 67 profiles() const {
68 return child_collector_.profiles_; 68 return child_collector_.profiles_;
69 } 69 }
70 70
71 base::MessageLoop loop_; 71 base::MessageLoop loop_;
72 mojom::CallStackProfileCollectorPtr receiver_; 72 mojom::CallStackProfileCollectorPtr receiver_;
73 std::unique_ptr<Receiver> receiver_impl_; 73 std::unique_ptr<Receiver> receiver_impl_;
74 ChildCallStackProfileCollector child_collector_; 74 ChildCallStackProfileCollector child_collector_;
75 75
76 private:
76 DISALLOW_COPY_AND_ASSIGN(ChildCallStackProfileCollectorTest); 77 DISALLOW_COPY_AND_ASSIGN(ChildCallStackProfileCollectorTest);
77 }; 78 };
78 79
79 // Test the behavior when an interface is provided. 80 // Test the behavior when an interface is provided.
80 TEST_F(ChildCallStackProfileCollectorTest, InterfaceProvided) { 81 TEST_F(ChildCallStackProfileCollectorTest, InterfaceProvided) {
81 EXPECT_EQ(0u, profiles().size()); 82 EXPECT_EQ(0u, profiles().size());
82 83
83 // Add profiles before providing the interface. 84 // Add profiles before providing the interface.
84 CollectEmptyProfiles( 85 CollectEmptyProfiles(
85 CallStackProfileParams(CallStackProfileParams::BROWSER_PROCESS, 86 CallStackProfileParams(CallStackProfileParams::BROWSER_PROCESS,
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 CollectEmptyProfiles( 169 CollectEmptyProfiles(
169 CallStackProfileParams(CallStackProfileParams::GPU_PROCESS, 170 CallStackProfileParams(CallStackProfileParams::GPU_PROCESS,
170 CallStackProfileParams::GPU_MAIN_THREAD, 171 CallStackProfileParams::GPU_MAIN_THREAD,
171 CallStackProfileParams::THREAD_HUNG, 172 CallStackProfileParams::THREAD_HUNG,
172 CallStackProfileParams::PRESERVE_ORDER), 173 CallStackProfileParams::PRESERVE_ORDER),
173 1); 174 1);
174 EXPECT_EQ(0u, profiles().size()); 175 EXPECT_EQ(0u, profiles().size());
175 } 176 }
176 177
177 } // namespace metrics 178 } // namespace metrics
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698