Commit 664fb691 authored by erikchen's avatar erikchen Committed by Commit Bot

Clean up profiling service.

Remove some unneeded code.

Change-Id: I47a8535189da8ebbe67853e3bae6f0cfb8cf11e6
Reviewed-on: https://chromium-review.googlesource.com/897898Reviewed-by: default avatarKen Rockot <rockot@chromium.org>
Commit-Queue: Erik Chen <erikchen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#534134}
parent def62d54
......@@ -10,10 +10,11 @@
#include "services/resource_coordinator/public/cpp/resource_coordinator_features.h"
#include "services/resource_coordinator/public/interfaces/memory_instrumentation/memory_instrumentation.mojom.h"
#include "services/resource_coordinator/public/interfaces/service_constants.mojom.h"
#include "services/service_manager/public/cpp/service_context.h"
namespace profiling {
ProfilingService::ProfilingService() : weak_factory_(this) {}
ProfilingService::ProfilingService() : binding_(this), weak_factory_(this) {}
ProfilingService::~ProfilingService() {}
......@@ -22,11 +23,8 @@ std::unique_ptr<service_manager::Service> ProfilingService::CreateService() {
}
void ProfilingService::OnStart() {
ref_factory_.reset(new service_manager::ServiceContextRefFactory(base::Bind(
&ProfilingService::MaybeRequestQuitDelayed, weak_factory_.GetWeakPtr())));
registry_.AddInterface(
base::Bind(&ProfilingService::OnProfilingServiceRequest,
base::Unretained(this), ref_factory_.get()));
registry_.AddInterface(base::Bind(
&ProfilingService::OnProfilingServiceRequest, base::Unretained(this)));
}
void ProfilingService::OnBindInterface(
......@@ -34,31 +32,11 @@ void ProfilingService::OnBindInterface(
const std::string& interface_name,
mojo::ScopedMessagePipeHandle interface_pipe) {
registry_.BindInterface(interface_name, std::move(interface_pipe));
// TODO(ajwong): Maybe signal shutdown when all interfaces are closed? What
// does ServiceManager actually do?
}
void ProfilingService::MaybeRequestQuitDelayed() {
// TODO(ajwong): What does this and the MaybeRequestQuit() function actually
// do? This is just cargo-culted from another mojo service.
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE,
base::Bind(&ProfilingService::MaybeRequestQuit,
weak_factory_.GetWeakPtr()),
base::TimeDelta::FromSeconds(5));
}
void ProfilingService::MaybeRequestQuit() {
DCHECK(ref_factory_);
if (ref_factory_->HasNoRefs())
context()->CreateQuitClosure().Run();
}
void ProfilingService::OnProfilingServiceRequest(
service_manager::ServiceContextRefFactory* ref_factory,
mojom::ProfilingServiceRequest request) {
binding_set_.AddBinding(this, std::move(request));
binding_.Bind(std::move(request));
}
void ProfilingService::AddProfilingClient(
......
......@@ -8,11 +8,10 @@
#include "base/memory/weak_ptr.h"
#include "chrome/common/profiling/profiling_service.mojom.h"
#include "chrome/profiling/memlog_connection_manager.h"
#include "mojo/public/cpp/bindings/binding_set.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "services/resource_coordinator/public/interfaces/memory_instrumentation/memory_instrumentation.mojom.h"
#include "services/service_manager/public/cpp/binder_registry.h"
#include "services/service_manager/public/cpp/service_context.h"
#include "services/service_manager/public/cpp/service_context_ref.h"
#include "services/service_manager/public/cpp/service.h"
namespace profiling {
......@@ -54,13 +53,7 @@ class ProfilingService : public service_manager::Service,
void GetProfiledPids(GetProfiledPidsCallback callback) override;
private:
void MaybeRequestQuitDelayed();
void MaybeRequestQuit();
// Uses |binding_set_| to resolve |request| allowing for on instance of
// MemlogImpl to serve all interface bindings.
void OnProfilingServiceRequest(
service_manager::ServiceContextRefFactory* ref_factory,
mojom::ProfilingServiceRequest request);
void OnGetVmRegionsCompleteForDumpProcessesForTracing(
......@@ -70,10 +63,8 @@ class ProfilingService : public service_manager::Service,
bool success,
memory_instrumentation::mojom::GlobalMemoryDumpPtr dump);
// State needed to manage service lifecycle and lifecycle of bound clients.
std::unique_ptr<service_manager::ServiceContextRefFactory> ref_factory_;
service_manager::BinderRegistry registry_;
mojo::BindingSet<mojom::ProfilingService> binding_set_;
mojo::Binding<mojom::ProfilingService> binding_;
memory_instrumentation::mojom::HeapProfilerHelperPtr helper_;
MemlogConnectionManager connection_manager_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment