| Index: services/resource_coordinator/public/cpp/memory/memory_dump_manager_delegate_impl.cc
|
| diff --git a/services/resource_coordinator/public/cpp/memory/memory_dump_manager_delegate_impl.cc b/services/resource_coordinator/public/cpp/memory/memory_dump_manager_delegate_impl.cc
|
| index 7072b6775487065afc73b76e77c2a5084d60d0d0..3fa229990e3b67f0ca5d4444b8861e8a427ca334 100644
|
| --- a/services/resource_coordinator/public/cpp/memory/memory_dump_manager_delegate_impl.cc
|
| +++ b/services/resource_coordinator/public/cpp/memory/memory_dump_manager_delegate_impl.cc
|
| @@ -4,6 +4,9 @@
|
|
|
| #include "services/resource_coordinator/public/cpp/memory/memory_dump_manager_delegate_impl.h"
|
|
|
| +#include "base/bind.h"
|
| +#include "base/bind_helpers.h"
|
| +#include "base/single_thread_task_runner.h"
|
| #include "base/trace_event/memory_dump_request_args.h"
|
| #include "mojo/public/cpp/bindings/interface_request.h"
|
| #include "services/resource_coordinator/public/cpp/memory/coordinator.h"
|
| @@ -14,15 +17,17 @@ namespace memory_instrumentation {
|
|
|
| MemoryDumpManagerDelegateImpl::MemoryDumpManagerDelegateImpl(
|
| service_manager::InterfaceProvider* interface_provider)
|
| - : is_coordinator_(false), binding_(this) {
|
| + : is_coordinator_(false), binding_(this), task_runner_(nullptr) {
|
| interface_provider->GetInterface(mojo::MakeRequest(&coordinator_));
|
| coordinator_->RegisterProcessLocalDumpManager(
|
| binding_.CreateInterfacePtrAndBind());
|
| }
|
|
|
| MemoryDumpManagerDelegateImpl::MemoryDumpManagerDelegateImpl(
|
| - Coordinator* coordinator)
|
| - : is_coordinator_(true), binding_(this) {
|
| + Coordinator* coordinator,
|
| + base::SingleThreadTaskRunner* task_runner)
|
| + : is_coordinator_(true), binding_(this), task_runner_(task_runner) {
|
| + DCHECK(task_runner_);
|
| coordinator->BindCoordinatorRequest(mojo::MakeRequest(&coordinator_));
|
| coordinator_->RegisterProcessLocalDumpManager(
|
| binding_.CreateInterfacePtrAndBind());
|
| @@ -43,7 +48,14 @@ void MemoryDumpManagerDelegateImpl::RequestProcessMemoryDump(
|
| void MemoryDumpManagerDelegateImpl::RequestGlobalMemoryDump(
|
| const base::trace_event::MemoryDumpRequestArgs& args,
|
| const base::trace_event::MemoryDumpCallback& callback) {
|
| - coordinator_->RequestGlobalMemoryDump(args, callback);
|
| + if (task_runner_ && !task_runner_->RunsTasksOnCurrentThread()) {
|
| + task_runner_->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&mojom::Coordinator::RequestGlobalMemoryDump,
|
| + base::Unretained(coordinator_.get()), args, callback));
|
| + } else {
|
| + coordinator_->RequestGlobalMemoryDump(args, callback);
|
| + }
|
| }
|
|
|
| } // namespace memory_instrumentation
|
|
|