OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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 <stddef.h> | 5 #include <stddef.h> |
6 | 6 |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/memory/ref_counted_memory.h" | 8 #include "base/memory/ref_counted_memory.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/trace_event/trace_buffer.h" | 10 #include "base/trace_event/trace_buffer.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 } | 30 } |
31 | 31 |
32 void TearDown() override { | 32 void TearDown() override { |
33 sampling_profiler_.reset(); | 33 sampling_profiler_.reset(); |
34 RenderViewTest::TearDown(); | 34 RenderViewTest::TearDown(); |
35 } | 35 } |
36 | 36 |
37 void KickV8() { ExecuteJavaScriptForTests("1"); } | 37 void KickV8() { ExecuteJavaScriptForTests("1"); } |
38 | 38 |
39 void SyncFlush(TraceLog* trace_log) { | 39 void SyncFlush(TraceLog* trace_log) { |
40 base::WaitableEvent flush_complete_event(false, false); | 40 base::WaitableEvent flush_complete_event( |
| 41 base::WaitableEvent::ResetPolicy::AUTOMATIC, |
| 42 base::WaitableEvent::InitialState::NOT_SIGNALED); |
41 trace_log->Flush( | 43 trace_log->Flush( |
42 base::Bind(&V8SamplingProfilerTest::OnTraceDataCollected, | 44 base::Bind(&V8SamplingProfilerTest::OnTraceDataCollected, |
43 base::Unretained(static_cast<V8SamplingProfilerTest*>(this)), | 45 base::Unretained(static_cast<V8SamplingProfilerTest*>(this)), |
44 base::Unretained(&flush_complete_event))); | 46 base::Unretained(&flush_complete_event))); |
45 base::RunLoop().RunUntilIdle(); | 47 base::RunLoop().RunUntilIdle(); |
46 flush_complete_event.Wait(); | 48 flush_complete_event.Wait(); |
47 } | 49 } |
48 | 50 |
49 void OnTraceDataCollected( | 51 void OnTraceDataCollected( |
50 base::WaitableEvent* flush_complete_event, | 52 base::WaitableEvent* flush_complete_event, |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 } | 143 } |
142 | 144 |
143 TEST_F(V8SamplingProfilerTest, V8SamplingSamplesCollected) { | 145 TEST_F(V8SamplingProfilerTest, V8SamplingSamplesCollected) { |
144 CollectTrace(0, 1); | 146 CollectTrace(0, 1); |
145 int sample_events_count = CountEvents("V8Sample"); | 147 int sample_events_count = CountEvents("V8Sample"); |
146 CHECK_LT(0, sample_events_count); | 148 CHECK_LT(0, sample_events_count); |
147 base::RunLoop().RunUntilIdle(); | 149 base::RunLoop().RunUntilIdle(); |
148 } | 150 } |
149 | 151 |
150 } // namespace content | 152 } // namespace content |
OLD | NEW |