| 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 24 matching lines...) Expand all Loading... |
| 35 // A mock dump provider, used to check that dump requests actually end up | 35 // A mock dump provider, used to check that dump requests actually end up |
| 36 // creating memory dumps. | 36 // creating memory dumps. |
| 37 class MockDumpProvider : public base::trace_event::MemoryDumpProvider { | 37 class MockDumpProvider : public base::trace_event::MemoryDumpProvider { |
| 38 public: | 38 public: |
| 39 MOCK_METHOD2(OnMemoryDump, bool(const MemoryDumpArgs& args, | 39 MOCK_METHOD2(OnMemoryDump, bool(const MemoryDumpArgs& args, |
| 40 ProcessMemoryDump* pmd)); | 40 ProcessMemoryDump* pmd)); |
| 41 }; | 41 }; |
| 42 | 42 |
| 43 class MemoryTracingTest : public ContentBrowserTest { | 43 class MemoryTracingTest : public ContentBrowserTest { |
| 44 public: | 44 public: |
| 45 void DoRequestGlobalDump(const MemoryDumpType& dump_type, | 45 void DoRequestGlobalDump( |
| 46 const MemoryDumpLevelOfDetail& level_of_detail, | 46 const MemoryDumpType& dump_type, |
| 47 const base::trace_event::MemoryDumpCallback& cb) { | 47 const MemoryDumpLevelOfDetail& level_of_detail, |
| 48 const base::trace_event::GlobalMemoryDumpCallback& cb) { |
| 48 MemoryDumpManager::GetInstance()->RequestGlobalDump(dump_type, | 49 MemoryDumpManager::GetInstance()->RequestGlobalDump(dump_type, |
| 49 level_of_detail, cb); | 50 level_of_detail, cb); |
| 50 } | 51 } |
| 51 | 52 |
| 52 // Used as callback argument for MemoryDumpManager::RequestGlobalDump(): | 53 // Used as callback argument for MemoryDumpManager::RequestGlobalDump(): |
| 53 void OnGlobalMemoryDumpDone( | 54 void OnGlobalMemoryDumpDone( |
| 54 scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 55 scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| 55 base::Closure closure, | 56 base::Closure closure, |
| 56 uint32_t request_index, | 57 uint32_t request_index, |
| 57 uint64_t dump_guid, | 58 uint64_t dump_guid, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 71 if (!closure.is_null()) | 72 if (!closure.is_null()) |
| 72 closure.Run(); | 73 closure.Run(); |
| 73 } | 74 } |
| 74 | 75 |
| 75 void RequestGlobalDumpWithClosure( | 76 void RequestGlobalDumpWithClosure( |
| 76 bool from_renderer_thread, | 77 bool from_renderer_thread, |
| 77 const MemoryDumpType& dump_type, | 78 const MemoryDumpType& dump_type, |
| 78 const MemoryDumpLevelOfDetail& level_of_detail, | 79 const MemoryDumpLevelOfDetail& level_of_detail, |
| 79 const base::Closure& closure) { | 80 const base::Closure& closure) { |
| 80 uint32_t request_index = next_request_index_++; | 81 uint32_t request_index = next_request_index_++; |
| 81 base::trace_event::MemoryDumpCallback callback = base::Bind( | 82 base::trace_event::GlobalMemoryDumpCallback callback = base::Bind( |
| 82 &MemoryTracingTest::OnGlobalMemoryDumpDone, base::Unretained(this), | 83 &MemoryTracingTest::OnGlobalMemoryDumpDone, base::Unretained(this), |
| 83 base::ThreadTaskRunnerHandle::Get(), closure, request_index); | 84 base::ThreadTaskRunnerHandle::Get(), closure, request_index); |
| 84 if (from_renderer_thread) { | 85 if (from_renderer_thread) { |
| 85 PostTaskToInProcessRendererAndWait(base::Bind( | 86 PostTaskToInProcessRendererAndWait(base::Bind( |
| 86 &MemoryTracingTest::DoRequestGlobalDump, base::Unretained(this), | 87 &MemoryTracingTest::DoRequestGlobalDump, base::Unretained(this), |
| 87 dump_type, level_of_detail, callback)); | 88 dump_type, level_of_detail, callback)); |
| 88 } else { | 89 } else { |
| 89 DoRequestGlobalDump(dump_type, level_of_detail, callback); | 90 DoRequestGlobalDump(dump_type, level_of_detail, callback); |
| 90 } | 91 } |
| 91 } | 92 } |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 EXPECT_CALL(*this, OnMemoryDumpDone(_, true /* success */)); | 318 EXPECT_CALL(*this, OnMemoryDumpDone(_, true /* success */)); |
| 318 | 319 |
| 319 EnableMemoryTracing(); | 320 EnableMemoryTracing(); |
| 320 RequestGlobalDumpAndWait(false /* from_renderer_thread */, | 321 RequestGlobalDumpAndWait(false /* from_renderer_thread */, |
| 321 MemoryDumpType::EXPLICITLY_TRIGGERED, | 322 MemoryDumpType::EXPLICITLY_TRIGGERED, |
| 322 MemoryDumpLevelOfDetail::DETAILED); | 323 MemoryDumpLevelOfDetail::DETAILED); |
| 323 DisableTracing(); | 324 DisableTracing(); |
| 324 } | 325 } |
| 325 | 326 |
| 326 } // namespace content | 327 } // namespace content |
| OLD | NEW |