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 "components/tracing/child_memory_dump_manager_delegate_impl.h" | 5 #include "components/tracing/child_memory_dump_manager_delegate_impl.h" |
6 | 6 |
7 #include "base/single_thread_task_runner.h" | 7 #include "base/single_thread_task_runner.h" |
| 8 #include "base/trace_event/process_memory_maps_dump_provider.h" |
| 9 #include "base/trace_event/process_memory_totals_dump_provider.h" |
8 #include "components/tracing/child_trace_message_filter.h" | 10 #include "components/tracing/child_trace_message_filter.h" |
9 | 11 |
10 namespace tracing { | 12 namespace tracing { |
11 | 13 |
12 namespace { | 14 namespace { |
13 void AbortDumpRequest(const base::trace_event::MemoryDumpRequestArgs& args, | 15 void AbortDumpRequest(const base::trace_event::MemoryDumpRequestArgs& args, |
14 const base::trace_event::MemoryDumpCallback& callback) { | 16 const base::trace_event::MemoryDumpCallback& callback) { |
15 if (!callback.is_null()) | 17 if (!callback.is_null()) |
16 callback.Run(args.dump_guid, false /* success */); | 18 callback.Run(args.dump_guid, false /* success */); |
17 } | 19 } |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 | 85 |
84 // The ChildTraceMessageFilter could have been destroyed while hopping on the | 86 // The ChildTraceMessageFilter could have been destroyed while hopping on the |
85 // right thread. If this is the case, bail out. | 87 // right thread. If this is the case, bail out. |
86 if (!ctmf_) | 88 if (!ctmf_) |
87 return AbortDumpRequest(args, callback); | 89 return AbortDumpRequest(args, callback); |
88 | 90 |
89 // Send the request up to the browser process' MessageDumpmanager. | 91 // Send the request up to the browser process' MessageDumpmanager. |
90 ctmf_->SendGlobalMemoryDumpRequest(args, callback); | 92 ctmf_->SendGlobalMemoryDumpRequest(args, callback); |
91 } | 93 } |
92 | 94 |
| 95 void ChildMemoryDumpManagerDelegateImpl::SetMemoryTracingInfo( |
| 96 const TracingMsg_MemoryTracingInfo& memory_tracing_info) { |
| 97 // Checks if id is not reset to different one. |
| 98 DCHECK_IMPLIES( |
| 99 tracing_process_id_ != |
| 100 base::trace_event::MemoryDumpManager::kInvalidTracingProcessId, |
| 101 memory_tracing_info.tracing_process_id == tracing_process_id_); |
| 102 tracing_process_id_ = memory_tracing_info.tracing_process_id; |
| 103 |
| 104 #if defined(OS_LINUX) |
| 105 base::trace_event::ProcessMemoryMapsDumpProvider::GetInstance() |
| 106 ->set_smaps_file(fdopen(IPC::PlatformFileForTransitToPlatformFile( |
| 107 memory_tracing_info.smaps_fd), |
| 108 "r")); |
| 109 base::trace_event::ProcessMemoryTotalsDumpProvider::GetInstance() |
| 110 ->set_proc_status_fd(IPC::PlatformFileForTransitToPlatformFile( |
| 111 memory_tracing_info.status_fd)); |
| 112 #endif |
| 113 } |
| 114 |
| 115 void ChildMemoryDumpManagerDelegateImpl::ResetMemoryTracingInfo() { |
| 116 #if defined(OS_LINUX) |
| 117 tracing_process_id_ = |
| 118 base::trace_event::MemoryDumpManager::kInvalidTracingProcessId; |
| 119 base::trace_event::ProcessMemoryMapsDumpProvider::GetInstance() |
| 120 ->set_smaps_file(nullptr); |
| 121 base::trace_event::ProcessMemoryTotalsDumpProvider::GetInstance() |
| 122 ->reset_proc_status_fd(); |
| 123 #endif |
| 124 } |
| 125 |
93 uint64 ChildMemoryDumpManagerDelegateImpl::GetTracingProcessId() const { | 126 uint64 ChildMemoryDumpManagerDelegateImpl::GetTracingProcessId() const { |
94 return tracing_process_id_; | 127 return tracing_process_id_; |
95 } | 128 } |
96 | 129 |
97 } // namespace tracing | 130 } // namespace tracing |
OLD | NEW |