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> |
| 6 |
5 #include "base/bind.h" | 7 #include "base/bind.h" |
6 #include "base/command_line.h" | 8 #include "base/command_line.h" |
7 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
8 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
9 #include "base/trace_event/memory_dump_manager.h" | 11 #include "base/trace_event/memory_dump_manager.h" |
10 #include "base/trace_event/memory_dump_provider.h" | 12 #include "base/trace_event/memory_dump_provider.h" |
11 #include "base/trace_event/memory_dump_request_args.h" | 13 #include "base/trace_event/memory_dump_request_args.h" |
12 #include "base/trace_event/trace_config_memory_test_util.h" | 14 #include "base/trace_event/trace_config_memory_test_util.h" |
13 #include "content/public/browser/tracing_controller.h" | 15 #include "content/public/browser/tracing_controller.h" |
14 #include "content/public/common/content_switches.h" | 16 #include "content/public/common/content_switches.h" |
(...skipping 25 matching lines...) Expand all Loading... |
40 void DoRequestGlobalDump(const base::trace_event::MemoryDumpCallback& cb) { | 42 void DoRequestGlobalDump(const base::trace_event::MemoryDumpCallback& cb) { |
41 MemoryDumpManager::GetInstance()->RequestGlobalDump( | 43 MemoryDumpManager::GetInstance()->RequestGlobalDump( |
42 MemoryDumpType::EXPLICITLY_TRIGGERED, | 44 MemoryDumpType::EXPLICITLY_TRIGGERED, |
43 base::trace_event::MemoryDumpLevelOfDetail::DETAILED, cb); | 45 base::trace_event::MemoryDumpLevelOfDetail::DETAILED, cb); |
44 } | 46 } |
45 | 47 |
46 // Used as callback argument for MemoryDumpManager::RequestGlobalDump(): | 48 // Used as callback argument for MemoryDumpManager::RequestGlobalDump(): |
47 void OnGlobalMemoryDumpDone( | 49 void OnGlobalMemoryDumpDone( |
48 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 50 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
49 base::Closure closure, | 51 base::Closure closure, |
50 uint64 dump_guid, | 52 uint64_t dump_guid, |
51 bool success) { | 53 bool success) { |
52 // Make sure we run the RunLoop closure on the same thread that originated | 54 // 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). | 55 // the run loop (which is the IN_PROC_BROWSER_TEST_F main thread). |
54 if (!task_runner->RunsTasksOnCurrentThread()) { | 56 if (!task_runner->RunsTasksOnCurrentThread()) { |
55 task_runner->PostTask( | 57 task_runner->PostTask( |
56 FROM_HERE, base::Bind(&MemoryTracingTest::OnGlobalMemoryDumpDone, | 58 FROM_HERE, base::Bind(&MemoryTracingTest::OnGlobalMemoryDumpDone, |
57 base::Unretained(this), task_runner, closure, | 59 base::Unretained(this), task_runner, closure, |
58 dump_guid, success)); | 60 dump_guid, success)); |
59 return; | 61 return; |
60 } | 62 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 } | 120 } |
119 run_loop.Run(); | 121 run_loop.Run(); |
120 } | 122 } |
121 | 123 |
122 void Navigate(Shell* shell) { | 124 void Navigate(Shell* shell) { |
123 NavigateToURL(shell, GetTestUrl("", "title.html")); | 125 NavigateToURL(shell, GetTestUrl("", "title.html")); |
124 } | 126 } |
125 | 127 |
126 base::Closure on_memory_dump_complete_closure_; | 128 base::Closure on_memory_dump_complete_closure_; |
127 scoped_ptr<MockDumpProvider> mock_dump_provider_; | 129 scoped_ptr<MockDumpProvider> mock_dump_provider_; |
128 uint32 callback_call_count_; | 130 uint32_t callback_call_count_; |
129 uint64 last_callback_dump_guid_; | 131 uint64_t last_callback_dump_guid_; |
130 bool last_callback_success_; | 132 bool last_callback_success_; |
131 }; | 133 }; |
132 | 134 |
133 // Ignore SingleProcessMemoryTracingTests for Google Chrome builds because | 135 // Ignore SingleProcessMemoryTracingTests for Google Chrome builds because |
134 // single-process is not supported on those builds. | 136 // single-process is not supported on those builds. |
135 #if !defined(GOOGLE_CHROME_BUILD) | 137 #if !defined(GOOGLE_CHROME_BUILD) |
136 | 138 |
137 class SingleProcessMemoryTracingTest : public MemoryTracingTest { | 139 class SingleProcessMemoryTracingTest : public MemoryTracingTest { |
138 public: | 140 public: |
139 SingleProcessMemoryTracingTest() {} | 141 SingleProcessMemoryTracingTest() {} |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 | 223 |
222 EnableMemoryTracing(); | 224 EnableMemoryTracing(); |
223 RequestGlobalDumpAndWait(false /* from_renderer_thread */); | 225 RequestGlobalDumpAndWait(false /* from_renderer_thread */); |
224 EXPECT_EQ(1u, callback_call_count_); | 226 EXPECT_EQ(1u, callback_call_count_); |
225 EXPECT_NE(0u, last_callback_dump_guid_); | 227 EXPECT_NE(0u, last_callback_dump_guid_); |
226 EXPECT_TRUE(last_callback_success_); | 228 EXPECT_TRUE(last_callback_success_); |
227 DisableTracing(); | 229 DisableTracing(); |
228 } | 230 } |
229 | 231 |
230 } // namespace content | 232 } // namespace content |
OLD | NEW |