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 "services/resource_coordinator/public/cpp/memory/memory_dump_manager_de
legate_impl.h" | 16 #include "services/resource_coordinator/public/cpp/memory/process_local_dump_man
ager_impl.h" |
17 #include "services/resource_coordinator/public/interfaces/memory/constants.mojom
.h" | 17 #include "services/resource_coordinator/public/interfaces/memory/constants.mojom
.h" |
18 #include "services/resource_coordinator/public/interfaces/memory/memory_instrume
ntation.mojom.h" | 18 #include "services/resource_coordinator/public/interfaces/memory/memory_instrume
ntation.mojom.h" |
19 | 19 |
20 namespace { | 20 namespace { |
21 | 21 |
22 memory_instrumentation::CoordinatorImpl* g_coordinator_impl; | 22 memory_instrumentation::CoordinatorImpl* g_coordinator_impl; |
23 | 23 |
24 } // namespace | 24 } // namespace |
25 | 25 |
26 namespace memory_instrumentation { | 26 namespace memory_instrumentation { |
27 | 27 |
28 // static | 28 // static |
29 CoordinatorImpl* CoordinatorImpl::GetInstance() { | 29 CoordinatorImpl* CoordinatorImpl::GetInstance() { |
30 return g_coordinator_impl; | 30 return g_coordinator_impl; |
31 } | 31 } |
32 | 32 |
33 CoordinatorImpl::CoordinatorImpl(bool initialize_memory_dump_manager) | 33 CoordinatorImpl::CoordinatorImpl(bool initialize_memory_dump_manager) |
34 : failed_memory_dump_count_(0), | 34 : failed_memory_dump_count_(0), |
35 initialize_memory_dump_manager_(initialize_memory_dump_manager) { | 35 initialize_memory_dump_manager_(initialize_memory_dump_manager) { |
36 if (initialize_memory_dump_manager) { | 36 if (initialize_memory_dump_manager) { |
37 MemoryDumpManagerDelegateImpl::Config config(this); | 37 ProcessLocalDumpManagerImpl::CreateInstance( |
38 auto delegate = base::MakeUnique<MemoryDumpManagerDelegateImpl>(config); | 38 ProcessLocalDumpManagerImpl::Config(this)); |
39 base::trace_event::MemoryDumpManager::GetInstance()->set_tracing_process_id( | 39 base::trace_event::MemoryDumpManager::GetInstance()->set_tracing_process_id( |
40 mojom::kServiceTracingProcessId); | 40 mojom::kServiceTracingProcessId); |
41 base::trace_event::MemoryDumpManager::GetInstance()->Initialize( | |
42 std::move(delegate)); | |
43 } | 41 } |
44 g_coordinator_impl = this; | 42 g_coordinator_impl = this; |
45 } | 43 } |
46 | 44 |
47 CoordinatorImpl::~CoordinatorImpl() { | 45 CoordinatorImpl::~CoordinatorImpl() { |
48 g_coordinator_impl = nullptr; | 46 g_coordinator_impl = nullptr; |
49 } | 47 } |
50 | 48 |
51 void CoordinatorImpl::BindCoordinatorRequest( | 49 void CoordinatorImpl::BindCoordinatorRequest( |
52 mojom::CoordinatorRequest request) { | 50 mojom::CoordinatorRequest request) { |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 // Schedule the next queued dump (if applicable). | 184 // Schedule the next queued dump (if applicable). |
187 if (!queued_memory_dump_requests_.empty()) { | 185 if (!queued_memory_dump_requests_.empty()) { |
188 base::ThreadTaskRunnerHandle::Get()->PostTask( | 186 base::ThreadTaskRunnerHandle::Get()->PostTask( |
189 FROM_HERE, | 187 FROM_HERE, |
190 base::Bind(&CoordinatorImpl::PerformNextQueuedGlobalMemoryDump, | 188 base::Bind(&CoordinatorImpl::PerformNextQueuedGlobalMemoryDump, |
191 base::Unretained(this))); | 189 base::Unretained(this))); |
192 } | 190 } |
193 } | 191 } |
194 | 192 |
195 } // namespace memory_instrumentation | 193 } // namespace memory_instrumentation |
OLD | NEW |