| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 <set> | 7 #include <set> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "app/l10n_util.h" | 10 #include "app/l10n_util.h" |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/file_path.h" | 12 #include "base/file_path.h" |
| 13 #include "base/file_version_info.h" | 13 #include "base/file_version_info.h" |
| 14 #include "base/mac_util.h" | 14 #include "base/mac_util.h" |
| 15 #include "base/string_util.h" | 15 #include "base/string_util.h" |
| 16 #include "base/process_util.h" | 16 #include "base/process_util.h" |
| 17 #include "base/thread.h" | 17 #include "base/thread.h" |
| 18 #include "chrome/app/chrome_version_info.h" | |
| 19 #include "chrome/browser/browser_child_process_host.h" | 18 #include "chrome/browser/browser_child_process_host.h" |
| 20 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
| 21 #include "chrome/browser/chrome_thread.h" | 20 #include "chrome/browser/chrome_thread.h" |
| 22 #include "chrome/browser/process_info_snapshot.h" | 21 #include "chrome/browser/process_info_snapshot.h" |
| 23 #include "chrome/browser/renderer_host/backing_store_manager.h" | 22 #include "chrome/browser/renderer_host/backing_store_manager.h" |
| 24 #include "chrome/browser/renderer_host/render_process_host.h" | 23 #include "chrome/browser/renderer_host/render_process_host.h" |
| 25 #include "chrome/browser/tab_contents/navigation_entry.h" | 24 #include "chrome/browser/tab_contents/navigation_entry.h" |
| 26 #include "chrome/browser/tab_contents/tab_contents.h" | 25 #include "chrome/browser/tab_contents/tab_contents.h" |
| 27 #include "chrome/common/chrome_constants.h" | 26 #include "chrome/common/chrome_constants.h" |
| 27 #include "chrome/common/chrome_version_info.h" |
| 28 #include "chrome/common/url_constants.h" | 28 #include "chrome/common/url_constants.h" |
| 29 #include "grit/chromium_strings.h" | 29 #include "grit/chromium_strings.h" |
| 30 | 30 |
| 31 // TODO(viettrungluu): Many of the TODOs below are subsumed by a general need to | 31 // TODO(viettrungluu): Many of the TODOs below are subsumed by a general need to |
| 32 // refactor the about:memory code (not just on Mac, but probably on other | 32 // refactor the about:memory code (not just on Mac, but probably on other |
| 33 // platforms as well). I've filed crbug.com/25456. | 33 // platforms as well). I've filed crbug.com/25456. |
| 34 | 34 |
| 35 class RenderViewHostDelegate; | 35 class RenderViewHostDelegate; |
| 36 | 36 |
| 37 // Known browsers which we collect details for. |CHROME_BROWSER| *must* be the | 37 // Known browsers which we collect details for. |CHROME_BROWSER| *must* be the |
| (...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 const std::vector<ProcessMemoryInformation>& child_info, | 191 const std::vector<ProcessMemoryInformation>& child_info, |
| 192 base::ProcessId pid, | 192 base::ProcessId pid, |
| 193 const ProcessInfoSnapshot& process_info) { | 193 const ProcessInfoSnapshot& process_info) { |
| 194 ProcessMemoryInformation info; | 194 ProcessMemoryInformation info; |
| 195 info.pid = pid; | 195 info.pid = pid; |
| 196 if (info.pid == base::GetCurrentProcId()) | 196 if (info.pid == base::GetCurrentProcId()) |
| 197 info.type = ChildProcessInfo::BROWSER_PROCESS; | 197 info.type = ChildProcessInfo::BROWSER_PROCESS; |
| 198 else | 198 else |
| 199 info.type = ChildProcessInfo::UNKNOWN_PROCESS; | 199 info.type = ChildProcessInfo::UNKNOWN_PROCESS; |
| 200 | 200 |
| 201 scoped_ptr<FileVersionInfo> version_info( | 201 scoped_ptr<FileVersionInfo> version_info(chrome::GetChromeVersionInfo()); |
| 202 chrome_app::GetChromeVersionInfo()); | |
| 203 if (version_info.get()) { | 202 if (version_info.get()) { |
| 204 info.product_name = version_info->product_name(); | 203 info.product_name = version_info->product_name(); |
| 205 info.version = version_info->product_version(); | 204 info.version = version_info->product_version(); |
| 206 } else { | 205 } else { |
| 207 info.product_name = process_data_[CHROME_BROWSER].name; | 206 info.product_name = process_data_[CHROME_BROWSER].name; |
| 208 info.version = L""; | 207 info.version = L""; |
| 209 } | 208 } |
| 210 | 209 |
| 211 // Check if this is one of the child processes whose data we collected | 210 // Check if this is one of the child processes whose data we collected |
| 212 // on the IO thread, and if so copy over that data. | 211 // on the IO thread, and if so copy over that data. |
| 213 for (size_t child = 0; child < child_info.size(); child++) { | 212 for (size_t child = 0; child < child_info.size(); child++) { |
| 214 if (child_info[child].pid == info.pid) { | 213 if (child_info[child].pid == info.pid) { |
| 215 info.titles = child_info[child].titles; | 214 info.titles = child_info[child].titles; |
| 216 info.type = child_info[child].type; | 215 info.type = child_info[child].type; |
| 217 break; | 216 break; |
| 218 } | 217 } |
| 219 } | 218 } |
| 220 | 219 |
| 221 // Memory info. | 220 // Memory info. |
| 222 process_info.GetCommittedKBytesOfPID(info.pid, &info.committed); | 221 process_info.GetCommittedKBytesOfPID(info.pid, &info.committed); |
| 223 process_info.GetWorkingSetKBytesOfPID(info.pid, &info.working_set); | 222 process_info.GetWorkingSetKBytesOfPID(info.pid, &info.working_set); |
| 224 | 223 |
| 225 // Add the process info to our list. | 224 // Add the process info to our list. |
| 226 process_data_[CHROME_BROWSER].processes.push_back(info); | 225 process_data_[CHROME_BROWSER].processes.push_back(info); |
| 227 } | 226 } |
| OLD | NEW |