| 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" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 PostTaskToInProcessRendererAndWait(base::Bind( | 84 PostTaskToInProcessRendererAndWait(base::Bind( |
| 85 &MemoryTracingTest::DoRequestGlobalDump, base::Unretained(this), | 85 &MemoryTracingTest::DoRequestGlobalDump, base::Unretained(this), |
| 86 dump_type, level_of_detail, callback)); | 86 dump_type, level_of_detail, callback)); |
| 87 } else { | 87 } else { |
| 88 DoRequestGlobalDump(dump_type, level_of_detail, callback); | 88 DoRequestGlobalDump(dump_type, level_of_detail, callback); |
| 89 } | 89 } |
| 90 } | 90 } |
| 91 | 91 |
| 92 protected: | 92 protected: |
| 93 void SetUp() override { | 93 void SetUp() override { |
| 94 fprintf(stderr, "SetUp\n"); |
| 94 next_request_index_ = 0; | 95 next_request_index_ = 0; |
| 95 | 96 |
| 96 mock_dump_provider_.reset(new MockDumpProvider()); | 97 mock_dump_provider_.reset(new MockDumpProvider()); |
| 97 MemoryDumpManager::GetInstance()->RegisterDumpProvider( | 98 MemoryDumpManager::GetInstance()->RegisterDumpProvider( |
| 98 mock_dump_provider_.get(), "MockDumpProvider", nullptr); | 99 mock_dump_provider_.get(), "MockDumpProvider", nullptr); |
| 99 MemoryDumpManager::GetInstance() | 100 MemoryDumpManager::GetInstance() |
| 100 ->set_dumper_registrations_ignored_for_testing(false); | 101 ->set_dumper_registrations_ignored_for_testing(false); |
| 101 ContentBrowserTest::SetUp(); | 102 ContentBrowserTest::SetUp(); |
| 102 } | 103 } |
| 103 | 104 |
| 104 void TearDown() override { | 105 void TearDown() override { |
| 106 fprintf(stderr, "TearDown\n"); |
| 105 MemoryDumpManager::GetInstance()->UnregisterDumpProvider( | 107 MemoryDumpManager::GetInstance()->UnregisterDumpProvider( |
| 106 mock_dump_provider_.get()); | 108 mock_dump_provider_.get()); |
| 107 mock_dump_provider_.reset(); | 109 mock_dump_provider_.reset(); |
| 108 ContentBrowserTest::TearDown(); | 110 ContentBrowserTest::TearDown(); |
| 109 } | 111 } |
| 110 | 112 |
| 111 void EnableMemoryTracing() { | 113 void EnableMemoryTracing() { |
| 112 // Enable tracing without periodic dumps. | 114 // Enable tracing without periodic dumps. |
| 113 base::trace_event::TraceConfig trace_config( | 115 base::trace_event::TraceConfig trace_config( |
| 114 base::trace_event::TraceConfigMemoryTestUtil:: | 116 base::trace_event::TraceConfigMemoryTestUtil:: |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 | 168 |
| 167 void SetUpCommandLine(base::CommandLine* command_line) override { | 169 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 168 command_line->AppendSwitch(switches::kSingleProcess); | 170 command_line->AppendSwitch(switches::kSingleProcess); |
| 169 } | 171 } |
| 170 }; | 172 }; |
| 171 | 173 |
| 172 // Checks that a memory dump initiated from a the main browser thread ends up in | 174 // Checks that a memory dump initiated from a the main browser thread ends up in |
| 173 // a single dump even in single process mode. | 175 // a single dump even in single process mode. |
| 174 IN_PROC_BROWSER_TEST_F(SingleProcessMemoryTracingTest, | 176 IN_PROC_BROWSER_TEST_F(SingleProcessMemoryTracingTest, |
| 175 BrowserInitiatedSingleDump) { | 177 BrowserInitiatedSingleDump) { |
| 178 fprintf(stderr, "test start\n"); |
| 176 Navigate(shell()); | 179 Navigate(shell()); |
| 177 | 180 |
| 178 EXPECT_CALL(*mock_dump_provider_, OnMemoryDump(_,_)).WillOnce(Return(true)); | 181 EXPECT_CALL(*mock_dump_provider_, OnMemoryDump(_,_)).WillOnce(Return(true)); |
| 179 EXPECT_CALL(*this, OnMemoryDumpDone(_, true /* success */)); | 182 EXPECT_CALL(*this, OnMemoryDumpDone(_, true /* success */)); |
| 180 | 183 |
| 181 EnableMemoryTracing(); | 184 EnableMemoryTracing(); |
| 182 RequestGlobalDumpAndWait(false /* from_renderer_thread */, | 185 RequestGlobalDumpAndWait(false /* from_renderer_thread */, |
| 183 MemoryDumpType::EXPLICITLY_TRIGGERED, | 186 MemoryDumpType::EXPLICITLY_TRIGGERED, |
| 184 MemoryDumpLevelOfDetail::DETAILED); | 187 MemoryDumpLevelOfDetail::DETAILED); |
| 185 DisableTracing(); | 188 DisableTracing(); |
| 189 fprintf(stderr, "test finish\n"); |
| 186 } | 190 } |
| 187 | 191 |
| 188 // Checks that a memory dump initiated from a renderer thread ends up in a | 192 // Checks that a memory dump initiated from a renderer thread ends up in a |
| 189 // single dump even in single process mode. | 193 // single dump even in single process mode. |
| 190 IN_PROC_BROWSER_TEST_F(SingleProcessMemoryTracingTest, | 194 IN_PROC_BROWSER_TEST_F(SingleProcessMemoryTracingTest, |
| 191 RendererInitiatedSingleDump) { | 195 RendererInitiatedSingleDump) { |
| 192 Navigate(shell()); | 196 Navigate(shell()); |
| 193 | 197 |
| 194 EXPECT_CALL(*mock_dump_provider_, OnMemoryDump(_,_)).WillOnce(Return(true)); | 198 EXPECT_CALL(*mock_dump_provider_, OnMemoryDump(_,_)).WillOnce(Return(true)); |
| 195 EXPECT_CALL(*this, OnMemoryDumpDone(_, true /* success */)); | 199 EXPECT_CALL(*this, OnMemoryDumpDone(_, true /* success */)); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 309 EXPECT_CALL(*this, OnMemoryDumpDone(_, true /* success */)); | 313 EXPECT_CALL(*this, OnMemoryDumpDone(_, true /* success */)); |
| 310 | 314 |
| 311 EnableMemoryTracing(); | 315 EnableMemoryTracing(); |
| 312 RequestGlobalDumpAndWait(false /* from_renderer_thread */, | 316 RequestGlobalDumpAndWait(false /* from_renderer_thread */, |
| 313 MemoryDumpType::EXPLICITLY_TRIGGERED, | 317 MemoryDumpType::EXPLICITLY_TRIGGERED, |
| 314 MemoryDumpLevelOfDetail::DETAILED); | 318 MemoryDumpLevelOfDetail::DETAILED); |
| 315 DisableTracing(); | 319 DisableTracing(); |
| 316 } | 320 } |
| 317 | 321 |
| 318 } // namespace content | 322 } // namespace content |
| OLD | NEW |