Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/memory_details.h" | 5 #include "chrome/browser/memory_details.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/file_version_info.h" | 14 #include "base/file_version_info.h" |
| 15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
| 16 #include "base/mac/foundation_util.h" | 16 #include "base/mac/foundation_util.h" |
| 17 #include "base/mac/mac_util.h" | |
| 17 #include "base/process/process_iterator.h" | 18 #include "base/process/process_iterator.h" |
| 18 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
| 19 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
| 20 #include "base/threading/thread.h" | 21 #include "base/threading/thread.h" |
| 21 #include "base/threading/thread_restrictions.h" | 22 #include "base/threading/thread_restrictions.h" |
| 22 #include "chrome/common/chrome_constants.h" | 23 #include "chrome/common/chrome_constants.h" |
| 23 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" |
| 24 #include "chrome/grit/chromium_strings.h" | 25 #include "chrome/grit/chromium_strings.h" |
| 25 #include "components/version_info/version_info.h" | 26 #include "components/version_info/version_info.h" |
| 26 #include "content/public/browser/browser_child_process_host.h" | 27 #include "content/public/browser/browser_child_process_host.h" |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 55 info.titles = child.titles; | 56 info.titles = child.titles; |
| 56 info.process_type = child.process_type; | 57 info.process_type = child.process_type; |
| 57 break; | 58 break; |
| 58 } | 59 } |
| 59 } | 60 } |
| 60 | 61 |
| 61 std::unique_ptr<base::ProcessMetrics> metrics = | 62 std::unique_ptr<base::ProcessMetrics> metrics = |
| 62 base::ProcessMetrics::CreateProcessMetrics( | 63 base::ProcessMetrics::CreateProcessMetrics( |
| 63 pid, content::BrowserChildProcessHost::GetPortProvider()); | 64 pid, content::BrowserChildProcessHost::GetPortProvider()); |
| 64 metrics->GetCommittedAndWorkingSetKBytes(&info.committed, &info.working_set); | 65 metrics->GetCommittedAndWorkingSetKBytes(&info.committed, &info.working_set); |
| 65 info.phys_footprint = metrics->GetTaskVMInfo().phys_footprint; | 66 base::ProcessMetrics::TaskVMInfo vm_info = metrics->GetTaskVMInfo(); |
| 67 info.phys_footprint = vm_info.phys_footprint; | |
| 68 | |
| 69 // TODO(erikchen): Remove this temporary estimate for private memory once the | |
| 70 // memory infra service emits the same metric. https://crbug.com/720541. | |
| 71 if (base::mac::IsAtLeastOS10_12()) { | |
| 72 info.private_memory_footprint = vm_info.phys_footprint; | |
|
Nico
2017/05/11 20:12:59
are you sure that you want to send differently com
erikchen
2017/05/11 21:02:22
Yup. The first API is strictly better, but not ava
| |
| 73 } else { | |
| 74 info.private_memory_footprint = vm_info.internal + vm_info.compressed; | |
| 75 } | |
| 66 | 76 |
| 67 processes->push_back(info); | 77 processes->push_back(info); |
| 68 } | 78 } |
| 69 | 79 |
| 70 } // namespace | 80 } // namespace |
| 71 | 81 |
| 72 MemoryDetails::MemoryDetails() { | 82 MemoryDetails::MemoryDetails() { |
| 73 const base::FilePath browser_process_path = | 83 const base::FilePath browser_process_path = |
| 74 base::GetProcessExecutablePath(base::GetCurrentProcessHandle()); | 84 base::GetProcessExecutablePath(base::GetCurrentProcessHandle()); |
| 75 | 85 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 | 132 |
| 123 // Collect data about Chrome/Chromium. | 133 // Collect data about Chrome/Chromium. |
| 124 for (const base::ProcessId& pid : all_pids) | 134 for (const base::ProcessId& pid : all_pids) |
| 125 CollectProcessDataForChromeProcess(child_info, pid, chrome_processes); | 135 CollectProcessDataForChromeProcess(child_info, pid, chrome_processes); |
| 126 | 136 |
| 127 // Finally return to the browser thread. | 137 // Finally return to the browser thread. |
| 128 BrowserThread::PostTask( | 138 BrowserThread::PostTask( |
| 129 BrowserThread::UI, FROM_HERE, | 139 BrowserThread::UI, FROM_HERE, |
| 130 base::Bind(&MemoryDetails::CollectChildInfoOnUIThread, this)); | 140 base::Bind(&MemoryDetails::CollectChildInfoOnUIThread, this)); |
| 131 } | 141 } |
| OLD | NEW |