Index: content/browser/memory/memory_coordinator.h |
diff --git a/content/browser/memory/memory_coordinator.h b/content/browser/memory/memory_coordinator.h |
index f674ef5b48ce950e5c442c24e73aef850940251d..47d695b570df3ef6a0b22cb717c610dd0d5b099d 100644 |
--- a/content/browser/memory/memory_coordinator.h |
+++ b/content/browser/memory/memory_coordinator.h |
@@ -6,7 +6,6 @@ |
#define CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_H_ |
#include "base/memory/memory_coordinator_client_registry.h" |
-#include "base/memory/singleton.h" |
#include "base/process/process_handle.h" |
#include "content/common/content_export.h" |
#include "content/common/memory_coordinator.mojom.h" |
@@ -24,7 +23,7 @@ class MemoryCoordinatorHandleImpl; |
// child processes based on its best knowledge of the memory usage. |
class CONTENT_EXPORT MemoryCoordinator { |
public: |
- ~MemoryCoordinator(); |
+ virtual ~MemoryCoordinator(); |
// Singleton factory/accessor. |
static MemoryCoordinator* GetInstance(); |
@@ -59,14 +58,6 @@ class CONTENT_EXPORT MemoryCoordinator { |
// for testing. |
void OnConnectionError(int render_process_id); |
- private: |
- friend struct base::DefaultSingletonTraits<MemoryCoordinator>; |
- |
- // Helper function of CreateHandle and AddChildForTesting. |
- void CreateChildInfoMapEntry( |
- int render_process_id, |
- std::unique_ptr<MemoryCoordinatorHandleImpl> handle); |
- |
// Stores information about any known child processes. |
struct ChildInfo { |
// This object must be compatible with STL containers. |
@@ -81,6 +72,17 @@ class CONTENT_EXPORT MemoryCoordinator { |
// A map from process ID (RenderProcessHost::GetID()) to child process info. |
using ChildInfoMap = std::map<int, ChildInfo>; |
+ ChildInfoMap& children() { return children_; } |
+ |
+ virtual void OnChildAdded() {} |
+ virtual void OnChildRemoved() {} |
chrisha
2016/09/30 02:57:20
Why are these needed? The Impl should be able to i
|
+ |
+private: |
+ // Helper function of CreateHandle and AddChildForTesting. |
+ void CreateChildInfoMapEntry( |
+ int render_process_id, |
+ std::unique_ptr<MemoryCoordinatorHandleImpl> handle); |
+ |
// Tracks child processes. An entry is added when a renderer connects to |
// MemoryCoordinator and removed automatically when an underlying binding is |
// disconnected. |
@@ -89,6 +91,26 @@ class CONTENT_EXPORT MemoryCoordinator { |
DISALLOW_COPY_AND_ASSIGN(MemoryCoordinator); |
}; |
+// The implementation of MemoryCoordinatorHandle. See memory_coordinator.mojom |
+// for the role of this class. |
+class MemoryCoordinatorHandleImpl : public mojom::MemoryCoordinatorHandle { |
chrisha
2016/09/30 02:57:20
Why do we need to expose this impl detail?
|
+ public: |
+ MemoryCoordinatorHandleImpl(mojom::MemoryCoordinatorHandleRequest request); |
+ ~MemoryCoordinatorHandleImpl() override; |
+ |
+ // mojom::MemoryCoordinatorHandle: |
+ void AddChild(mojom::ChildMemoryCoordinatorPtr child) override; |
+ |
+ mojom::ChildMemoryCoordinatorPtr& child() { return child_; } |
+ mojo::Binding<mojom::MemoryCoordinatorHandle>& binding() { return binding_; } |
+ |
+ private: |
+ mojom::ChildMemoryCoordinatorPtr child_; |
+ mojo::Binding<mojom::MemoryCoordinatorHandle> binding_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(MemoryCoordinatorHandleImpl); |
+}; |
+ |
} // namespace content |
#endif // CONTENT_BROWSER_MEMORY_MEMORY_COORDINATOR_H_ |