Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "services/resource_coordinator/memory/coordinator/coordinator_impl.h" | 5 #include "services/resource_coordinator/memory/coordinator/coordinator_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 13 #include "base/threading/platform_thread.h" | 13 #include "base/threading/platform_thread.h" |
| 14 #include "base/trace_event/memory_dump_manager.h" | 14 #include "base/trace_event/memory_dump_manager.h" |
| 15 #include "base/trace_event/memory_dump_request_args.h" | 15 #include "base/trace_event/memory_dump_request_args.h" |
| 16 #include "base/trace_event/memory_tracing_frontend.h" | |
| 16 #include "services/resource_coordinator/public/cpp/memory/memory_dump_manager_de legate_impl.h" | 17 #include "services/resource_coordinator/public/cpp/memory/memory_dump_manager_de legate_impl.h" |
| 17 #include "services/resource_coordinator/public/interfaces/memory/constants.mojom .h" | 18 #include "services/resource_coordinator/public/interfaces/memory/constants.mojom .h" |
| 18 #include "services/resource_coordinator/public/interfaces/memory/memory_instrume ntation.mojom.h" | 19 #include "services/resource_coordinator/public/interfaces/memory/memory_instrume ntation.mojom.h" |
| 19 | 20 |
| 21 using base::trace_event::MemoryDumpManager; | |
| 22 using base::trace_event::MemoryTracingFrontend; | |
| 23 | |
| 20 namespace { | 24 namespace { |
| 21 | 25 |
| 22 memory_instrumentation::CoordinatorImpl* g_coordinator_impl; | 26 memory_instrumentation::CoordinatorImpl* g_coordinator_impl; |
| 23 | 27 |
| 24 } // namespace | 28 } // namespace |
| 25 | 29 |
| 26 namespace memory_instrumentation { | 30 namespace memory_instrumentation { |
| 27 | 31 |
| 28 // static | 32 // static |
| 29 CoordinatorImpl* CoordinatorImpl::GetInstance() { | 33 CoordinatorImpl* CoordinatorImpl::GetInstance() { |
| 30 return g_coordinator_impl; | 34 return g_coordinator_impl; |
| 31 } | 35 } |
| 32 | 36 |
| 33 CoordinatorImpl::CoordinatorImpl(bool initialize_memory_dump_manager) | 37 CoordinatorImpl::CoordinatorImpl(bool initialize_memory_dump_manager) |
| 34 : failed_memory_dump_count_(0), | 38 : failed_memory_dump_count_(0), |
| 35 initialize_memory_dump_manager_(initialize_memory_dump_manager) { | 39 initialize_memory_dump_manager_(initialize_memory_dump_manager) { |
| 36 if (initialize_memory_dump_manager) { | 40 if (initialize_memory_dump_manager) { |
| 37 MemoryDumpManagerDelegateImpl::Config config(this); | 41 MemoryDumpManagerDelegateImpl::Config config(this); |
| 38 auto delegate = base::MakeUnique<MemoryDumpManagerDelegateImpl>(config); | 42 auto delegate = base::MakeUnique<MemoryDumpManagerDelegateImpl>(config); |
| 39 base::trace_event::MemoryDumpManager::GetInstance()->set_tracing_process_id( | 43 MemoryDumpManager::GetInstance()->set_tracing_process_id( |
| 40 mojom::kServiceTracingProcessId); | 44 mojom::kServiceTracingProcessId); |
| 41 base::trace_event::MemoryDumpManager::GetInstance()->Initialize( | 45 MemoryDumpManager::GetInstance()->Initialize(std::move(delegate)); |
| 42 std::move(delegate)); | 46 MemoryTracingFrontend::Initialize(MemoryDumpManager::GetInstance()); |
|
ssid
2017/04/14 23:33:09
Doesn't look like the right place for initializing
hjd
2017/04/19 09:54:56
Moved to be done in MDM init.
| |
| 43 } | 47 } |
| 44 g_coordinator_impl = this; | 48 g_coordinator_impl = this; |
| 45 } | 49 } |
| 46 | 50 |
| 47 CoordinatorImpl::~CoordinatorImpl() { | 51 CoordinatorImpl::~CoordinatorImpl() { |
| 48 g_coordinator_impl = nullptr; | 52 g_coordinator_impl = nullptr; |
| 49 } | 53 } |
| 50 | 54 |
| 51 void CoordinatorImpl::BindCoordinatorRequest( | 55 void CoordinatorImpl::BindCoordinatorRequest( |
| 52 mojom::CoordinatorRequest request) { | 56 mojom::CoordinatorRequest request) { |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 184 // Schedule the next queued dump (if applicable). | 188 // Schedule the next queued dump (if applicable). |
| 185 if (!queued_memory_dump_requests_.empty()) { | 189 if (!queued_memory_dump_requests_.empty()) { |
| 186 base::ThreadTaskRunnerHandle::Get()->PostTask( | 190 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 187 FROM_HERE, | 191 FROM_HERE, |
| 188 base::Bind(&CoordinatorImpl::PerformNextQueuedGlobalMemoryDump, | 192 base::Bind(&CoordinatorImpl::PerformNextQueuedGlobalMemoryDump, |
| 189 base::Unretained(this))); | 193 base::Unretained(this))); |
| 190 } | 194 } |
| 191 } | 195 } |
| 192 | 196 |
| 193 } // namespace memory_instrumentation | 197 } // namespace memory_instrumentation |
| OLD | NEW |