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 <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback_forward.h" | 8 #include "base/callback_forward.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
11 #include "base/threading/thread_task_runner_handle.h" | 11 #include "base/threading/thread_task_runner_handle.h" |
12 #include "base/trace_event/memory_dump_manager.h" | 12 #include "base/trace_event/memory_dump_manager.h" |
13 #include "base/trace_event/memory_dump_provider.h" | 13 #include "base/trace_event/memory_dump_provider.h" |
14 #include "base/trace_event/memory_dump_request_args.h" | 14 #include "base/trace_event/memory_dump_request_args.h" |
15 #include "base/trace_event/trace_config_memory_test_util.h" | 15 #include "base/trace_event/trace_config_memory_test_util.h" |
16 #include "base/trace_event/trace_log.h" | 16 #include "base/trace_event/trace_log.h" |
17 #include "content/public/browser/tracing_controller.h" | 17 #include "content/public/browser/tracing_controller.h" |
18 #include "content/public/common/content_switches.h" | 18 #include "content/public/common/content_switches.h" |
19 #include "content/public/test/browser_test_utils.h" | 19 #include "content/public/test/browser_test_utils.h" |
20 #include "content/public/test/content_browser_test.h" | 20 #include "content/public/test/content_browser_test.h" |
21 #include "content/public/test/content_browser_test_utils.h" | 21 #include "content/public/test/content_browser_test_utils.h" |
22 #include "content/shell/browser/shell.h" | 22 #include "content/shell/browser/shell.h" |
| 23 #include "services/resource_coordinator/memory/coordinator/coordinator_impl.h" |
23 #include "testing/gmock/include/gmock/gmock.h" | 24 #include "testing/gmock/include/gmock/gmock.h" |
24 | 25 |
25 using base::trace_event::MemoryDumpArgs; | 26 using base::trace_event::MemoryDumpArgs; |
26 using base::trace_event::MemoryDumpLevelOfDetail; | 27 using base::trace_event::MemoryDumpLevelOfDetail; |
27 using base::trace_event::MemoryDumpManager; | 28 using base::trace_event::MemoryDumpManager; |
28 using base::trace_event::MemoryDumpType; | 29 using base::trace_event::MemoryDumpType; |
29 using base::trace_event::ProcessMemoryDump; | 30 using base::trace_event::ProcessMemoryDump; |
30 using testing::_; | 31 using testing::_; |
31 using testing::Return; | 32 using testing::Return; |
32 | 33 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 FAIL() << "Tracing seems to be already enabled. " | 116 FAIL() << "Tracing seems to be already enabled. " |
116 "Very likely this is because the startup tracing file " | 117 "Very likely this is because the startup tracing file " |
117 "has been leaked from a previous test."; | 118 "has been leaked from a previous test."; |
118 } | 119 } |
119 // Enable tracing without periodic dumps. | 120 // Enable tracing without periodic dumps. |
120 base::trace_event::TraceConfig trace_config( | 121 base::trace_event::TraceConfig trace_config( |
121 base::trace_event::TraceConfigMemoryTestUtil:: | 122 base::trace_event::TraceConfigMemoryTestUtil:: |
122 GetTraceConfig_EmptyTriggers()); | 123 GetTraceConfig_EmptyTriggers()); |
123 | 124 |
124 base::RunLoop run_loop; | 125 base::RunLoop run_loop; |
| 126 // Start the Coordinator service. |
| 127 memory_instrumentation::CoordinatorImpl::GetInstance( |
| 128 base::ThreadTaskRunnerHandle::Get().get()); |
125 bool success = TracingController::GetInstance()->StartTracing( | 129 bool success = TracingController::GetInstance()->StartTracing( |
126 trace_config, run_loop.QuitClosure()); | 130 trace_config, run_loop.QuitClosure()); |
127 EXPECT_TRUE(success); | 131 EXPECT_TRUE(success); |
128 run_loop.Run(); | 132 run_loop.Run(); |
129 } | 133 } |
130 | 134 |
131 void DisableTracing() { | 135 void DisableTracing() { |
132 bool success = TracingController::GetInstance()->StopTracing(NULL); | 136 bool success = TracingController::GetInstance()->StopTracing(NULL); |
133 EXPECT_TRUE(success); | 137 EXPECT_TRUE(success); |
134 base::RunLoop().RunUntilIdle(); | 138 base::RunLoop().RunUntilIdle(); |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 EXPECT_CALL(*this, OnMemoryDumpDone(_, true /* success */)); | 320 EXPECT_CALL(*this, OnMemoryDumpDone(_, true /* success */)); |
317 | 321 |
318 EnableMemoryTracing(); | 322 EnableMemoryTracing(); |
319 RequestGlobalDumpAndWait(false /* from_renderer_thread */, | 323 RequestGlobalDumpAndWait(false /* from_renderer_thread */, |
320 MemoryDumpType::EXPLICITLY_TRIGGERED, | 324 MemoryDumpType::EXPLICITLY_TRIGGERED, |
321 MemoryDumpLevelOfDetail::DETAILED); | 325 MemoryDumpLevelOfDetail::DETAILED); |
322 DisableTracing(); | 326 DisableTracing(); |
323 } | 327 } |
324 | 328 |
325 } // namespace content | 329 } // namespace content |
OLD | NEW |