Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Unified Diff: services/resource_coordinator/memory/coordinator/coordinator_impl.cc

Issue 2738093003: Revert of memory-infra: Finish moving to Mojo (2nd attempt) (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: services/resource_coordinator/memory/coordinator/coordinator_impl.cc
diff --git a/services/resource_coordinator/memory/coordinator/coordinator_impl.cc b/services/resource_coordinator/memory/coordinator/coordinator_impl.cc
index 081db1714915be3a30a15a93d5018628004e483c..5c133f803c472c845b70ba40936c9706365beaa7 100644
--- a/services/resource_coordinator/memory/coordinator/coordinator_impl.cc
+++ b/services/resource_coordinator/memory/coordinator/coordinator_impl.cc
@@ -4,41 +4,40 @@
#include "services/resource_coordinator/memory/coordinator/coordinator_impl.h"
-#include "base/bind.h"
#include "base/bind_helpers.h"
+#include "base/lazy_instance.h"
#include "base/location.h"
#include "base/logging.h"
#include "base/memory/ref_counted.h"
-#include "base/single_thread_task_runner.h"
-#include "base/threading/platform_thread.h"
+#include "base/threading/thread_task_runner_handle.h"
#include "base/trace_event/memory_dump_manager.h"
#include "base/trace_event/memory_dump_request_args.h"
-#include "services/resource_coordinator/public/cpp/memory/memory_dump_manager_delegate_impl.h"
#include "services/resource_coordinator/public/interfaces/memory/memory_instrumentation.mojom.h"
namespace memory_instrumentation {
+namespace {
+
+base::LazyInstance<CoordinatorImpl>::Leaky g_coordinator =
+ LAZY_INSTANCE_INITIALIZER;
+
+} // namespace
+
// static
CoordinatorImpl* CoordinatorImpl::GetInstance() {
- static CoordinatorImpl* instance = new CoordinatorImpl(true);
- DCHECK(instance->initialize_memory_dump_manager());
- return instance;
+ return g_coordinator.Pointer();
}
-CoordinatorImpl::CoordinatorImpl(bool initialize_memory_dump_manager)
- : failed_memory_dump_count_(0),
- initialize_memory_dump_manager_(initialize_memory_dump_manager) {
- if (initialize_memory_dump_manager) {
- MemoryDumpManagerDelegateImpl::Config config(this);
- MemoryDumpManagerDelegateImpl::Create(config);
- }
-}
+// TODO(chiniforooshan): Initialize the global MemoryDumpManager instance here.
+// This is how the global MemoryDumpManager gets a reference to the delegate on
+// the service (read the browser) process for service process memory dumps. This
+// can be done when the delegate implementation is landed.
+CoordinatorImpl::CoordinatorImpl() : failed_memory_dump_count_(0) {}
CoordinatorImpl::~CoordinatorImpl() {}
void CoordinatorImpl::BindCoordinatorRequest(
mojom::CoordinatorRequest request) {
- DCHECK(thread_checker_.CalledOnValidThread());
bindings_.AddBinding(this, std::move(request));
}
@@ -53,6 +52,7 @@
const base::trace_event::MemoryDumpRequestArgs& args,
const RequestGlobalMemoryDumpCallback& callback) {
DCHECK(thread_checker_.CalledOnValidThread());
+
bool another_dump_already_in_progress = !queued_memory_dump_requests_.empty();
// If this is a periodic memory dump request and there already is another
@@ -88,6 +88,7 @@
void CoordinatorImpl::RegisterProcessLocalDumpManager(
mojom::ProcessLocalDumpManagerPtr process_manager) {
DCHECK(thread_checker_.CalledOnValidThread());
+
process_manager.set_connection_error_handler(
base::Bind(&CoordinatorImpl::UnregisterProcessLocalDumpManager,
base::Unretained(this), process_manager.get()));
@@ -100,8 +101,7 @@
void CoordinatorImpl::UnregisterProcessLocalDumpManager(
mojom::ProcessLocalDumpManager* process_manager) {
- size_t num_deleted = process_managers_.erase(process_manager);
- DCHECK(num_deleted == 1);
+ DCHECK(process_managers_.erase(process_manager) == 1);
// Check if we are waiting for an ack from this process-local manager.
if (pending_process_managers_.find(process_manager) !=

Powered by Google App Engine
This is Rietveld 408576698