blob: 0efa4ff1a2f431abbd9d269d6cbe4aada3cc7af1 [file] [log] [blame]
Gordon Guan96c21ee2019-11-06 15:05:391// Copyright 2019 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
Lei Zhang6f1953f2021-04-16 18:11:545#include "content/renderer/discardable_memory_utils.h"
6
Gordon Guan96c21ee2019-11-06 15:05:397#include <utility>
8
Gordon Guanf2f7a8402019-11-27 18:26:449#include "base/memory/discardable_memory.h"
Gordon Guan96c21ee2019-11-06 15:05:3910#include "content/child/child_process.h"
11#include "content/child/child_thread_impl.h"
Gordon Guan96c21ee2019-11-06 15:05:3912
13namespace content {
14
Thiabaud Engelbrechtc4c42392020-12-01 18:24:3915scoped_refptr<discardable_memory::ClientDiscardableSharedMemoryManager>
Gordon Guan96c21ee2019-11-06 15:05:3916CreateDiscardableMemoryAllocator() {
Gordon Guan96c21ee2019-11-06 15:05:3917 DVLOG(1) << "Using shared memory for discardable memory";
18
19 mojo::PendingRemote<discardable_memory::mojom::DiscardableSharedMemoryManager>
20 manager_remote;
21 ChildThread::Get()->BindHostReceiver(
22 manager_remote.InitWithNewPipeAndPassReceiver());
Thiabaud Engelbrechtc4c42392020-12-01 18:24:3923 return base::MakeRefCounted<
Gordon Guan96c21ee2019-11-06 15:05:3924 discardable_memory::ClientDiscardableSharedMemoryManager>(
Benoit Lizecabd94bf2020-12-11 11:08:5525 std::move(manager_remote), ChildProcess::current()->io_task_runner());
Gordon Guan96c21ee2019-11-06 15:05:3926}
27
28} // namespace content