| 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 "components/tracing/child_trace_message_filter.h" | 8 #include "components/tracing/child_trace_message_filter.h" |
| 9 | 9 |
| 10 namespace tracing { | 10 namespace tracing { |
| 11 | 11 |
| 12 // static | 12 // static |
| 13 ChildMemoryDumpManagerDelegateImpl* | 13 ChildMemoryDumpManagerDelegateImpl* |
| 14 ChildMemoryDumpManagerDelegateImpl::GetInstance() { | 14 ChildMemoryDumpManagerDelegateImpl::GetInstance() { |
| 15 return Singleton< | 15 return Singleton< |
| 16 ChildMemoryDumpManagerDelegateImpl, | 16 ChildMemoryDumpManagerDelegateImpl, |
| 17 LeakySingletonTraits<ChildMemoryDumpManagerDelegateImpl>>::get(); | 17 LeakySingletonTraits<ChildMemoryDumpManagerDelegateImpl>>::get(); |
| 18 } | 18 } |
| 19 | 19 |
| 20 ChildMemoryDumpManagerDelegateImpl::ChildMemoryDumpManagerDelegateImpl() | 20 ChildMemoryDumpManagerDelegateImpl::ChildMemoryDumpManagerDelegateImpl() |
| 21 : ctmf_(nullptr), | 21 : ctmf_(nullptr), |
| 22 tracing_process_id_( | 22 tracing_process_id_( |
| 23 base::trace_event::MemoryDumpManager::kInvalidTracingProcessId) { | 23 base::trace_event::MemoryDumpManager::kInvalidTracingProcessId) { |
| 24 base::trace_event::MemoryDumpManager::GetInstance()->SetDelegate(this); | 24 base::trace_event::MemoryDumpManager::GetInstance()->Initialize( |
| 25 this /* delegate */, false /* is_coordinator */); |
| 25 } | 26 } |
| 26 | 27 |
| 27 ChildMemoryDumpManagerDelegateImpl::~ChildMemoryDumpManagerDelegateImpl() { | 28 ChildMemoryDumpManagerDelegateImpl::~ChildMemoryDumpManagerDelegateImpl() {} |
| 28 } | |
| 29 | 29 |
| 30 void ChildMemoryDumpManagerDelegateImpl::SetChildTraceMessageFilter( | 30 void ChildMemoryDumpManagerDelegateImpl::SetChildTraceMessageFilter( |
| 31 ChildTraceMessageFilter* ctmf) { | 31 ChildTraceMessageFilter* ctmf) { |
| 32 // Check that we are either registering the CTMF or tearing it down, but not | 32 // Check that we are either registering the CTMF or tearing it down, but not |
| 33 // replacing a valid instance with another one (should never happen). | 33 // replacing a valid instance with another one (should never happen). |
| 34 DCHECK(ctmf_ == nullptr || (ctmf == nullptr && ctmf_task_runner_ != nullptr)); | 34 DCHECK(ctmf_ == nullptr || (ctmf == nullptr && ctmf_task_runner_ != nullptr)); |
| 35 ctmf_ = ctmf; | 35 ctmf_ = ctmf; |
| 36 ctmf_task_runner_ = ctmf ? (ctmf->ipc_task_runner()) : nullptr; | 36 ctmf_task_runner_ = ctmf ? (ctmf->ipc_task_runner()) : nullptr; |
| 37 } | 37 } |
| 38 | 38 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 63 if (!ctmf_) { | 63 if (!ctmf_) { |
| 64 if (!callback.is_null()) | 64 if (!callback.is_null()) |
| 65 callback.Run(args.dump_guid, false /* success */); | 65 callback.Run(args.dump_guid, false /* success */); |
| 66 return; | 66 return; |
| 67 } | 67 } |
| 68 | 68 |
| 69 // Send the request up to the browser process' MessageDumpmanager. | 69 // Send the request up to the browser process' MessageDumpmanager. |
| 70 ctmf_->SendGlobalMemoryDumpRequest(args, callback); | 70 ctmf_->SendGlobalMemoryDumpRequest(args, callback); |
| 71 } | 71 } |
| 72 | 72 |
| 73 bool ChildMemoryDumpManagerDelegateImpl::IsCoordinatorProcess() const { | |
| 74 return false; | |
| 75 } | |
| 76 | |
| 77 uint64 ChildMemoryDumpManagerDelegateImpl::GetTracingProcessId() const { | 73 uint64 ChildMemoryDumpManagerDelegateImpl::GetTracingProcessId() const { |
| 78 return tracing_process_id_; | 74 return tracing_process_id_; |
| 79 } | 75 } |
| 80 | 76 |
| 81 } // namespace tracing | 77 } // namespace tracing |
| OLD | NEW |