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

Unified Diff: base/memory/memory_coordinator_client_registry.cc

Issue 2311723002: Move memory_coordinator_client and its registry to base/memory (Closed)
Patch Set: Merge TrimMemory with OnMemoryPressure Created 4 years, 3 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: base/memory/memory_coordinator_client_registry.cc
diff --git a/base/memory/memory_coordinator_client_registry.cc b/base/memory/memory_coordinator_client_registry.cc
new file mode 100644
index 0000000000000000000000000000000000000000..59cd8ac135e57451b5c0d613de597879468e39fb
--- /dev/null
+++ b/base/memory/memory_coordinator_client_registry.cc
@@ -0,0 +1,32 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/memory/memory_coordinator_client_registry.h"
+
+namespace base {
+
+// static
+MemoryCoordinatorClientRegistry*
+MemoryCoordinatorClientRegistry::GetInstance() {
+ return Singleton<
+ MemoryCoordinatorClientRegistry,
+ LeakySingletonTraits<MemoryCoordinatorClientRegistry>>::get();
+}
+
+MemoryCoordinatorClientRegistry::MemoryCoordinatorClientRegistry()
+ : clients_(new ClientList) {}
dcheng 2016/09/08 21:28:26 Why do we need to store this in a scoped_refptr?
bashi 2016/09/08 23:00:08 ObserverListThreadSafe is RefCountedThreadSafe. Ca
dcheng 2016/09/09 03:02:04 Ah, I see... it's thread-safe so it can PostTask a
+
+MemoryCoordinatorClientRegistry::~MemoryCoordinatorClientRegistry() {}
+
+void MemoryCoordinatorClientRegistry::Register(
+ MemoryCoordinatorClient* client) {
+ clients_->AddObserver(client);
+}
+
+void MemoryCoordinatorClientRegistry::Unregister(
+ MemoryCoordinatorClient* client) {
+ clients_->RemoveObserver(client);
+}
+
+} // namespace base

Powered by Google App Engine
This is Rietveld 408576698