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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "base/thread_task_runner_handle.h" | 8 #include "base/thread_task_runner_handle.h" |
9 #include "base/trace_event/memory_dump_manager.h" | 9 #include "base/trace_event/memory_dump_manager.h" |
10 #include "base/trace_event/memory_dump_provider.h" | 10 #include "base/trace_event/memory_dump_provider.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 // creating memory dumps. | 31 // creating memory dumps. |
32 class MockDumpProvider : public base::trace_event::MemoryDumpProvider { | 32 class MockDumpProvider : public base::trace_event::MemoryDumpProvider { |
33 public: | 33 public: |
34 MOCK_METHOD2(OnMemoryDump, bool(const MemoryDumpArgs& args, | 34 MOCK_METHOD2(OnMemoryDump, bool(const MemoryDumpArgs& args, |
35 ProcessMemoryDump* pmd)); | 35 ProcessMemoryDump* pmd)); |
36 }; | 36 }; |
37 | 37 |
38 class MemoryTracingTest : public ContentBrowserTest { | 38 class MemoryTracingTest : public ContentBrowserTest { |
39 public: | 39 public: |
40 void DoRequestGlobalDump(const base::trace_event::MemoryDumpCallback& cb) { | 40 void DoRequestGlobalDump(const base::trace_event::MemoryDumpCallback& cb) { |
41 MemoryDumpArgs dump_args = { MemoryDumpArgs::LevelOfDetail::HIGH }; | |
42 MemoryDumpManager::GetInstance()->RequestGlobalDump( | 41 MemoryDumpManager::GetInstance()->RequestGlobalDump( |
43 MemoryDumpType::EXPLICITLY_TRIGGERED, dump_args, cb); | 42 MemoryDumpType::EXPLICITLY_TRIGGERED, |
| 43 base::trace_event::MemoryDumpLevelOfDetail::DETAILED, cb); |
44 } | 44 } |
45 | 45 |
46 // Used as callback argument for MemoryDumpManager::RequestGlobalDump(): | 46 // Used as callback argument for MemoryDumpManager::RequestGlobalDump(): |
47 void OnGlobalMemoryDumpDone( | 47 void OnGlobalMemoryDumpDone( |
48 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 48 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
49 base::Closure closure, | 49 base::Closure closure, |
50 uint64 dump_guid, | 50 uint64 dump_guid, |
51 bool success) { | 51 bool success) { |
52 // Make sure we run the RunLoop closure on the same thread that originated | 52 // Make sure we run the RunLoop closure on the same thread that originated |
53 // the run loop (which is the IN_PROC_BROWSER_TEST_F main thread). | 53 // the run loop (which is the IN_PROC_BROWSER_TEST_F main thread). |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 | 213 |
214 EnableMemoryTracing(); | 214 EnableMemoryTracing(); |
215 RequestGlobalDumpAndWait(false /* from_renderer_thread */); | 215 RequestGlobalDumpAndWait(false /* from_renderer_thread */); |
216 EXPECT_EQ(1u, callback_call_count_); | 216 EXPECT_EQ(1u, callback_call_count_); |
217 EXPECT_NE(0u, last_callback_dump_guid_); | 217 EXPECT_NE(0u, last_callback_dump_guid_); |
218 EXPECT_TRUE(last_callback_success_); | 218 EXPECT_TRUE(last_callback_success_); |
219 DisableTracing(); | 219 DisableTracing(); |
220 } | 220 } |
221 | 221 |
222 } // namespace content | 222 } // namespace content |
OLD | NEW |