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

Unified Diff: components/memory_coordinator/common/client_registry.h

Issue 2144163002: Extract client handing from ChildMemoryCoordinatorImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mc-2-notify
Patch Set: rebase Created 4 years, 5 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: components/memory_coordinator/common/client_registry.h
diff --git a/components/memory_coordinator/common/client_registry.h b/components/memory_coordinator/common/client_registry.h
new file mode 100644
index 0000000000000000000000000000000000000000..593b9fa8faab816dfdc594c58b167e4b4089c2ae
--- /dev/null
+++ b/components/memory_coordinator/common/client_registry.h
@@ -0,0 +1,34 @@
+// 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.
+
+#ifndef COMPONENTS_MEMORY_COORDINATOR_COMMON_CLIENT_REGISTRY_H_
+#define COMPONENTS_MEMORY_COORDINATOR_COMMON_CLIENT_REGISTRY_H_
+
+#include "base/observer_list_threadsafe.h"
+#include "components/memory_coordinator/common/memory_coordinator_client.h"
+
+namespace memory_coordinator {
+
+// ClientRegistry is a base class of process-specific memory coordinator
+// and provides ways to register/unregister MemoryCoordinatorClients.
+class ClientRegistry {
+ public:
+ ClientRegistry();
+ virtual ~ClientRegistry();
+
+ // Registers/unregisters a client. Does not take ownership of client.
+ void RegisterClient(MemoryCoordinatorClient* client);
+ void UnregisterClient(MemoryCoordinatorClient* client);
+
+ protected:
+ using ClientList = base::ObserverListThreadSafe<MemoryCoordinatorClient>;
+ ClientList* clients() { return clients_.get(); }
+
+ private:
+ scoped_refptr<ClientList> clients_;
+};
+
+} // namespace memory_coordinator
+
+#endif // COMPONENTS_MEMORY_COORDINATOR_COMMON_CLIENT_REGISTRY_H_
« no previous file with comments | « components/memory_coordinator/common/BUILD.gn ('k') | components/memory_coordinator/common/client_registry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698