| 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 "build/build_config.h" | |
| 9 #include "components/tracing/child_trace_message_filter.h" | 8 #include "components/tracing/child_trace_message_filter.h" |
| 10 #include "components/tracing/process_metrics_memory_dump_provider.h" | |
| 11 | 9 |
| 12 namespace tracing { | 10 namespace tracing { |
| 13 | 11 |
| 14 namespace { | 12 namespace { |
| 15 void AbortDumpRequest(const base::trace_event::MemoryDumpRequestArgs& args, | 13 void AbortDumpRequest(const base::trace_event::MemoryDumpRequestArgs& args, |
| 16 const base::trace_event::MemoryDumpCallback& callback) { | 14 const base::trace_event::MemoryDumpCallback& callback) { |
| 17 if (!callback.is_null()) | 15 if (!callback.is_null()) |
| 18 callback.Run(args.dump_guid, false /* success */); | 16 callback.Run(args.dump_guid, false /* success */); |
| 19 } | 17 } |
| 20 } // namespace | 18 } // namespace |
| (...skipping 23 matching lines...) Expand all Loading... |
| 44 ctmf_ = ctmf; | 42 ctmf_ = ctmf; |
| 45 | 43 |
| 46 { | 44 { |
| 47 base::AutoLock lock(lock_); | 45 base::AutoLock lock(lock_); |
| 48 ctmf_task_runner_ = task_runner; | 46 ctmf_task_runner_ = task_runner; |
| 49 } | 47 } |
| 50 | 48 |
| 51 if (ctmf) { | 49 if (ctmf) { |
| 52 base::trace_event::MemoryDumpManager::GetInstance()->Initialize( | 50 base::trace_event::MemoryDumpManager::GetInstance()->Initialize( |
| 53 this /* delegate */, false /* is_coordinator */); | 51 this /* delegate */, false /* is_coordinator */); |
| 54 | |
| 55 #if !defined(OS_LINUX) && !defined(OS_NACL) | |
| 56 // On linux the browser process takes care of dumping process metrics. | |
| 57 // The child process is not allowed to do so due to BPF sandbox. | |
| 58 tracing::ProcessMetricsMemoryDumpProvider::RegisterForProcess( | |
| 59 base::kNullProcessId); | |
| 60 #endif | |
| 61 } | 52 } |
| 62 } | 53 } |
| 63 | 54 |
| 64 // Invoked in child processes by the MemoryDumpManager. | 55 // Invoked in child processes by the MemoryDumpManager. |
| 65 void ChildMemoryDumpManagerDelegateImpl::RequestGlobalMemoryDump( | 56 void ChildMemoryDumpManagerDelegateImpl::RequestGlobalMemoryDump( |
| 66 const base::trace_event::MemoryDumpRequestArgs& args, | 57 const base::trace_event::MemoryDumpRequestArgs& args, |
| 67 const base::trace_event::MemoryDumpCallback& callback) { | 58 const base::trace_event::MemoryDumpCallback& callback) { |
| 68 // RequestGlobalMemoryDump can be called on any thread, cannot access | 59 // RequestGlobalMemoryDump can be called on any thread, cannot access |
| 69 // ctmf_task_runner_ as it could be racy. | 60 // ctmf_task_runner_ as it could be racy. |
| 70 scoped_refptr<base::SingleThreadTaskRunner> ctmf_task_runner; | 61 scoped_refptr<base::SingleThreadTaskRunner> ctmf_task_runner; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 97 | 88 |
| 98 // Send the request up to the browser process' MessageDumpmanager. | 89 // Send the request up to the browser process' MessageDumpmanager. |
| 99 ctmf_->SendGlobalMemoryDumpRequest(args, callback); | 90 ctmf_->SendGlobalMemoryDumpRequest(args, callback); |
| 100 } | 91 } |
| 101 | 92 |
| 102 uint64_t ChildMemoryDumpManagerDelegateImpl::GetTracingProcessId() const { | 93 uint64_t ChildMemoryDumpManagerDelegateImpl::GetTracingProcessId() const { |
| 103 return tracing_process_id_; | 94 return tracing_process_id_; |
| 104 } | 95 } |
| 105 | 96 |
| 106 } // namespace tracing | 97 } // namespace tracing |
| OLD | NEW |