Gordon Guan | 96c21ee | 2019-11-06 15:05:39 | [diff] [blame] | 1 | // 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 Zhang | 6f1953f | 2021-04-16 18:11:54 | [diff] [blame] | 5 | #include "content/renderer/discardable_memory_utils.h" |
| 6 | |
Gordon Guan | 96c21ee | 2019-11-06 15:05:39 | [diff] [blame] | 7 | #include <utility> |
| 8 | |
Gordon Guan | f2f7a840 | 2019-11-27 18:26:44 | [diff] [blame] | 9 | #include "base/memory/discardable_memory.h" |
Gordon Guan | 96c21ee | 2019-11-06 15:05:39 | [diff] [blame] | 10 | #include "content/child/child_process.h" |
| 11 | #include "content/child/child_thread_impl.h" |
Gordon Guan | 96c21ee | 2019-11-06 15:05:39 | [diff] [blame] | 12 | |
| 13 | namespace content { |
| 14 | |
Thiabaud Engelbrecht | c4c4239 | 2020-12-01 18:24:39 | [diff] [blame] | 15 | scoped_refptr<discardable_memory::ClientDiscardableSharedMemoryManager> |
Gordon Guan | 96c21ee | 2019-11-06 15:05:39 | [diff] [blame] | 16 | CreateDiscardableMemoryAllocator() { |
Gordon Guan | 96c21ee | 2019-11-06 15:05:39 | [diff] [blame] | 17 | 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 Engelbrecht | c4c4239 | 2020-12-01 18:24:39 | [diff] [blame] | 23 | return base::MakeRefCounted< |
Gordon Guan | 96c21ee | 2019-11-06 15:05:39 | [diff] [blame] | 24 | discardable_memory::ClientDiscardableSharedMemoryManager>( |
Benoit Lize | cabd94bf | 2020-12-11 11:08:55 | [diff] [blame] | 25 | std::move(manager_remote), ChildProcess::current()->io_task_runner()); |
Gordon Guan | 96c21ee | 2019-11-06 15:05:39 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | } // namespace content |