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

Unified Diff: content/browser/memory/memory_coordinator.cc

Issue 2374343002: Add MemoryCoordinatorImpl (Closed)
Patch Set: 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: content/browser/memory/memory_coordinator.cc
diff --git a/content/browser/memory/memory_coordinator.cc b/content/browser/memory/memory_coordinator.cc
index 52ee2ece71f8a47def79edd5401bd9c791680b49..adb8057c57177b664e7fd41dcffe44aeee910397 100644
--- a/content/browser/memory/memory_coordinator.cc
+++ b/content/browser/memory/memory_coordinator.cc
@@ -5,42 +5,9 @@
#include "content/browser/memory/memory_coordinator.h"
#include "base/memory/memory_coordinator_client_registry.h"
-#include "content/public/common/content_features.h"
namespace content {
-// The implementation of MemoryCoordinatorHandle. See memory_coordinator.mojom
-// for the role of this class.
-class MemoryCoordinatorHandleImpl : public mojom::MemoryCoordinatorHandle {
- public:
- MemoryCoordinatorHandleImpl(mojom::MemoryCoordinatorHandleRequest request)
- : binding_(this, std::move(request)) {
- }
-
- // mojom::MemoryCoordinatorHandle:
- void AddChild(mojom::ChildMemoryCoordinatorPtr child) override {
- DCHECK(!child_.is_bound());
- child_ = std::move(child);
- }
-
- 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);
-};
-
-// static
-MemoryCoordinator* MemoryCoordinator::GetInstance() {
- if (!base::FeatureList::IsEnabled(features::kMemoryCoordinator))
- return nullptr;
- return base::Singleton<MemoryCoordinator,
- base::LeakySingletonTraits<MemoryCoordinator>>::get();
-}
-
MemoryCoordinator::MemoryCoordinator() {}
MemoryCoordinator::~MemoryCoordinator() {}
@@ -101,6 +68,7 @@ void MemoryCoordinator::AddChildForTesting(
void MemoryCoordinator::OnConnectionError(int render_process_id) {
children_.erase(render_process_id);
+ OnChildRemoved();
}
void MemoryCoordinator::CreateChildInfoMapEntry(
@@ -112,6 +80,7 @@ void MemoryCoordinator::CreateChildInfoMapEntry(
// child processes, allowing them to be launched in a restricted state.
child_info.memory_state = mojom::MemoryState::NORMAL;
child_info.handle = std::move(handle);
+ OnChildAdded();
}
MemoryCoordinator::ChildInfo::ChildInfo() {}
@@ -122,4 +91,16 @@ MemoryCoordinator::ChildInfo::ChildInfo(const ChildInfo& rhs) {
MemoryCoordinator::ChildInfo::~ChildInfo() {}
+MemoryCoordinatorHandleImpl::MemoryCoordinatorHandleImpl(
+ mojom::MemoryCoordinatorHandleRequest request)
+ : binding_(this, std::move(request)) {}
+
+MemoryCoordinatorHandleImpl::~MemoryCoordinatorHandleImpl() {}
+
+void MemoryCoordinatorHandleImpl::AddChild(
+ mojom::ChildMemoryCoordinatorPtr child) {
+ DCHECK(!child_.is_bound());
+ child_ = std::move(child);
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698