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

Side by Side Diff: ios/chrome/browser/memory/memory_metrics.cc

Issue 1861593005: Convert //ios from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase? Created 4 years, 8 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ios/chrome/browser/memory/memory_metrics.h" 5 #include "ios/chrome/browser/memory/memory_metrics.h"
6 6
7 #include <mach/mach.h> 7 #include <mach/mach.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
11 #include <memory>
12
11 #include "base/logging.h" 13 #include "base/logging.h"
12 #include "base/mac/scoped_mach_port.h" 14 #include "base/mac/scoped_mach_port.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/process/process_handle.h" 15 #include "base/process/process_handle.h"
15 #include "base/process/process_metrics.h" 16 #include "base/process/process_metrics.h"
16 #include "build/build_config.h" 17 #include "build/build_config.h"
17 18
18 #ifdef ARCH_CPU_64_BITS 19 #ifdef ARCH_CPU_64_BITS
19 #define cr_vm_region vm_region_64 20 #define cr_vm_region vm_region_64
20 #else 21 #else
21 #define cr_vm_region vm_region 22 #define cr_vm_region vm_region
22 #endif 23 #endif
23 24
(...skipping 16 matching lines...) Expand all
40 host.get(), HOST_VM_INFO, reinterpret_cast<host_info_t>(&vmstat), &count); 41 host.get(), HOST_VM_INFO, reinterpret_cast<host_info_t>(&vmstat), &count);
41 if (result != KERN_SUCCESS) { 42 if (result != KERN_SUCCESS) {
42 LOG(ERROR) << "Calling host_statistics failed."; 43 LOG(ERROR) << "Calling host_statistics failed.";
43 return 0; 44 return 0;
44 } 45 }
45 return vmstat.free_count * kVMPageSize; 46 return vmstat.free_count * kVMPageSize;
46 } 47 }
47 48
48 uint64_t GetRealMemoryUsedInBytes() { 49 uint64_t GetRealMemoryUsedInBytes() {
49 base::ProcessHandle process_handle = base::GetCurrentProcessHandle(); 50 base::ProcessHandle process_handle = base::GetCurrentProcessHandle();
50 scoped_ptr<base::ProcessMetrics> process_metrics( 51 std::unique_ptr<base::ProcessMetrics> process_metrics(
51 base::ProcessMetrics::CreateProcessMetrics(process_handle)); 52 base::ProcessMetrics::CreateProcessMetrics(process_handle));
52 return static_cast<uint64_t>(process_metrics->GetWorkingSetSize()); 53 return static_cast<uint64_t>(process_metrics->GetWorkingSetSize());
53 } 54 }
54 55
55 uint64_t GetDirtyVMBytes() { 56 uint64_t GetDirtyVMBytes() {
56 // Iterate over all VM regions and sum their dirty pages. 57 // Iterate over all VM regions and sum their dirty pages.
57 unsigned int total_dirty_pages = 0; 58 unsigned int total_dirty_pages = 0;
58 vm_size_t vm_size = 0; 59 vm_size_t vm_size = 0;
59 kern_return_t result; 60 kern_return_t result;
60 for (vm_address_t address = MACH_VM_MIN_ADDRESS;; address += vm_size) { 61 for (vm_address_t address = MACH_VM_MIN_ADDRESS;; address += vm_size) {
(...skipping 24 matching lines...) Expand all
85 reinterpret_cast<task_info_t>(&task_vm_info), &count); 86 reinterpret_cast<task_info_t>(&task_vm_info), &count);
86 if (result != KERN_SUCCESS) { 87 if (result != KERN_SUCCESS) {
87 LOG(ERROR) << "Calling task_info failed."; 88 LOG(ERROR) << "Calling task_info failed.";
88 return 0; 89 return 0;
89 } 90 }
90 91
91 return static_cast<uint64_t>(task_vm_info.internal); 92 return static_cast<uint64_t>(task_vm_info.internal);
92 } 93 }
93 94
94 } // namespace memory_util 95 } // namespace memory_util
OLDNEW
« no previous file with comments | « ios/chrome/browser/memory/memory_debugger.mm ('k') | ios/chrome/browser/metrics/ios_chrome_metrics_service_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698