1 // Copyright 2017 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 "services/resource_coordinator/public/cpp/memory_instrumentation/os_metrics.h" 6 7 #include "build/build_config.h" 8 9 namespace memory_instrumentation { 10 11 // static FillProcessMemoryMaps(base::ProcessId pid,mojom::MemoryMapOption mmap_option,mojom::RawOSMemDump * dump)12bool OSMetrics::FillProcessMemoryMaps(base::ProcessId pid, 13 mojom::MemoryMapOption mmap_option, 14 mojom::RawOSMemDump* dump) { 15 DCHECK_NE(mmap_option, mojom::MemoryMapOption::NONE); 16 17 std::vector<mojom::VmRegionPtr> results; 18 19 #if defined(OS_MAC) 20 // On macOS, fetching all memory maps is very slow. See 21 // https://crbug.com/826913 and https://crbug.com/1035401. 22 results = GetProcessModules(pid); 23 #else 24 results = GetProcessMemoryMaps(pid); 25 26 #endif 27 28 if (results.empty()) 29 return false; 30 31 dump->memory_maps = std::move(results); 32 33 return true; 34 } 35 36 } // namespace memory_instrumentation 37