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

Side by Side Diff: components/memory_coordinator/browser/memory_coordinator.cc

Issue 2143353004: Revert of Add MemoryCoordinator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "components/memory_coordinator/browser/memory_coordinator.h"
6
7 namespace memory_coordinator {
8
9 // The implementation of MemoryCoordinatorHandle. See memory_coordinator.mojom
10 // for the role of this class.
11 class MemoryCoordinatorHandleImpl : public mojom::MemoryCoordinatorHandle {
12 public:
13 MemoryCoordinatorHandleImpl(mojom::MemoryCoordinatorHandleRequest request)
14 : binding_(this, std::move(request)) {
15 }
16
17 // mojom::MemoryCoordinatorHandle implementations:
18
19 void AddChild(mojom::ChildMemoryCoordinatorPtr child) override {
20 DCHECK(!child_.is_bound());
21 child_ = std::move(child);
22 }
23
24 mojom::ChildMemoryCoordinatorPtr& child() { return child_; }
25 mojo::Binding<mojom::MemoryCoordinatorHandle>& binding() { return binding_; }
26
27 private:
28 mojom::ChildMemoryCoordinatorPtr child_;
29 mojo::Binding<mojom::MemoryCoordinatorHandle> binding_;
30
31 DISALLOW_COPY_AND_ASSIGN(MemoryCoordinatorHandleImpl);
32 };
33
34 MemoryCoordinator::MemoryCoordinator() {}
35
36 MemoryCoordinator::~MemoryCoordinator() {}
37
38 void MemoryCoordinator::CreateHandle(
39 int render_process_id,
40 mojom::MemoryCoordinatorHandleRequest request) {
41 auto handle = new MemoryCoordinatorHandleImpl(std::move(request));
42 handle->binding().set_connection_error_handler(
43 base::Bind(&MemoryCoordinator::OnConnectionError, base::Unretained(this),
44 render_process_id));
45 children_[render_process_id].reset(handle);
46 }
47
48 size_t MemoryCoordinator::NumChildrenForTesting() {
49 return children_.size();
50 }
51
52 void MemoryCoordinator::OnConnectionError(int render_process_id) {
53 children_.erase(render_process_id);
54 }
55
56 } // namespace memory_coordinator
OLDNEW
« 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