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

Unified Diff: components/memory_coordinator/child/child_memory_coordinator_impl.h

Issue 2260433006: Add delegate and factory function for ChildMemoryCoordinator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: export Created 4 years, 4 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/child/child_memory_coordinator_impl.h
diff --git a/components/memory_coordinator/child/child_memory_coordinator_impl.h b/components/memory_coordinator/child/child_memory_coordinator_impl.h
index f8bc01ddea635818ef384d4ba2d96282f83eba89..6e71d20b3b81aac0792d39d86053cfa6753cb6e4 100644
--- a/components/memory_coordinator/child/child_memory_coordinator_impl.h
+++ b/components/memory_coordinator/child/child_memory_coordinator_impl.h
@@ -8,6 +8,7 @@
#include "base/compiler_specific.h"
#include "components/memory_coordinator/common/client_registry.h"
#include "components/memory_coordinator/common/memory_coordinator_client.h"
+#include "components/memory_coordinator/common/memory_coordinator_export.h"
#include "components/memory_coordinator/common/memory_coordinator_features.h"
#include "components/memory_coordinator/public/interfaces/child_memory_coordinator.mojom.h"
#include "components/memory_coordinator/public/interfaces/memory_coordinator.mojom.h"
@@ -15,6 +16,14 @@
namespace memory_coordinator {
+class MEMORY_COORDINATOR_EXPORT ChildMemoryCoordinatorDelegate {
+ public:
+ virtual ~ChildMemoryCoordinatorDelegate() {}
+
+ // Called when the system requests immediate actions to free memory.
+ virtual void OnTrimMemoryImmediately() = 0;
+};
+
// ChildMemoryCoordinatorImpl is the implementation of ChildMemoryCoordinator.
// It lives in child processes and is responsible for dispatching memory events
// to its clients.
@@ -22,21 +31,32 @@ class MEMORY_COORDINATOR_EXPORT ChildMemoryCoordinatorImpl
: public ClientRegistry,
NON_EXPORTED_BASE(public mojom::ChildMemoryCoordinator) {
public:
- explicit ChildMemoryCoordinatorImpl(mojom::MemoryCoordinatorHandlePtr parent);
+ explicit ChildMemoryCoordinatorImpl(mojom::MemoryCoordinatorHandlePtr parent,
+ ChildMemoryCoordinatorDelegate* delegate);
~ChildMemoryCoordinatorImpl() override;
// mojom::ChildMemoryCoordinator implementations:
void OnStateChange(mojom::MemoryState state) override;
+ protected:
+ ChildMemoryCoordinatorDelegate* delegate() { return delegate_; }
+
private:
friend class ChildMemoryCoordinatorImplTest;
mojo::Binding<mojom::ChildMemoryCoordinator> binding_;
mojom::MemoryCoordinatorHandlePtr parent_;
+ ChildMemoryCoordinatorDelegate* delegate_;
DISALLOW_COPY_AND_ASSIGN(ChildMemoryCoordinatorImpl);
};
-} // namespace content
+// Factory function for creating a ChildMemoryCoordinator for the current
+// platform. Doesn't take the ownership of |delegate|.
+MEMORY_COORDINATOR_EXPORT std::unique_ptr<ChildMemoryCoordinatorImpl>
+CreateChildMemoryCoordinator(mojom::MemoryCoordinatorHandlePtr parent,
+ ChildMemoryCoordinatorDelegate* delegate);
+
+} // namespace memory_coordinator
#endif // COMPONENTS_MEMORY_COORDINATOR_CHILD_CHILD_MEMORY_COORDINATOR_IMPL_H_
« no previous file with comments | « components/memory_coordinator/child/BUILD.gn ('k') | components/memory_coordinator/child/child_memory_coordinator_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698