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

Unified Diff: components/memory_coordinator/browser/memory_coordinator.cc

Issue 2094583002: Add MemoryCoordinator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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/browser/memory_coordinator.cc
diff --git a/components/memory_coordinator/browser/memory_coordinator.cc b/components/memory_coordinator/browser/memory_coordinator.cc
new file mode 100644
index 0000000000000000000000000000000000000000..101426f828009212bbe48d04334377d3dc63eeb0
--- /dev/null
+++ b/components/memory_coordinator/browser/memory_coordinator.cc
@@ -0,0 +1,56 @@
+// 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 "components/memory_coordinator/browser/memory_coordinator.h"
+
+namespace memory_coordinator {
+
+// 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 implementations:
+
+ 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);
+};
+
+MemoryCoordinator::MemoryCoordinator() {}
+
+MemoryCoordinator::~MemoryCoordinator() {}
+
+void MemoryCoordinator::CreateHandle(
+ int render_process_id,
+ mojom::MemoryCoordinatorHandleRequest request) {
+ auto handle = new MemoryCoordinatorHandleImpl(std::move(request));
+ handle->binding().set_connection_error_handler(
+ base::Bind(&MemoryCoordinator::OnConnectionError, base::Unretained(this),
+ render_process_id));
+ children_[render_process_id].reset(handle);
+}
+
+size_t MemoryCoordinator::NumChildrenForTesting() {
+ return children_.size();
+}
+
+void MemoryCoordinator::OnConnectionError(int render_process_id) {
+ children_.erase(render_process_id);
+}
+
+} // namespace memory_coordinator
« no previous file with comments | « components/memory_coordinator/browser/memory_coordinator.h ('k') | components/memory_coordinator/child/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698