| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
| 8 #include "base/file_version_info.h" | 8 #include "base/file_version_info.h" |
| 9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 DCHECK(ui_loop_ != g_browser_process->io_thread()->message_loop()); | 42 DCHECK(ui_loop_ != g_browser_process->io_thread()->message_loop()); |
| 43 DCHECK(ui_loop_ != g_browser_process->file_thread()->message_loop()); | 43 DCHECK(ui_loop_ != g_browser_process->file_thread()->message_loop()); |
| 44 | 44 |
| 45 // In order to process this request, we need to use the plugin information. | 45 // In order to process this request, we need to use the plugin information. |
| 46 // However, plugin process information is only available from the IO thread. | 46 // However, plugin process information is only available from the IO thread. |
| 47 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, | 47 g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE, |
| 48 NewRunnableMethod(this, &MemoryDetails::CollectChildInfoOnIOThread)); | 48 NewRunnableMethod(this, &MemoryDetails::CollectChildInfoOnIOThread)); |
| 49 } | 49 } |
| 50 | 50 |
| 51 void MemoryDetails::CollectChildInfoOnIOThread() { | 51 void MemoryDetails::CollectChildInfoOnIOThread() { |
| 52 DCHECK(MessageLoop::current() == | 52 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO)); |
| 53 ChromeThread::GetMessageLoop(ChromeThread::IO)); | |
| 54 | 53 |
| 55 std::vector<ProcessMemoryInformation> child_info; | 54 std::vector<ProcessMemoryInformation> child_info; |
| 56 | 55 |
| 57 // Collect the list of child processes. | 56 // Collect the list of child processes. |
| 58 for (ChildProcessHost::Iterator iter; !iter.Done(); ++iter) { | 57 for (ChildProcessHost::Iterator iter; !iter.Done(); ++iter) { |
| 59 ProcessMemoryInformation info; | 58 ProcessMemoryInformation info; |
| 60 info.pid = base::GetProcId(iter->handle()); | 59 info.pid = base::GetProcId(iter->handle()); |
| 61 if (!info.pid) | 60 if (!info.pid) |
| 62 continue; | 61 continue; |
| 63 | 62 |
| 64 info.type = iter->type(); | 63 info.type = iter->type(); |
| 65 info.titles.push_back(iter->name()); | 64 info.titles.push_back(iter->name()); |
| 66 child_info.push_back(info); | 65 child_info.push_back(info); |
| 67 } | 66 } |
| 68 | 67 |
| 69 // Now go do expensive memory lookups from the file thread. | 68 // Now go do expensive memory lookups from the file thread. |
| 70 ChromeThread::GetMessageLoop(ChromeThread::FILE)->PostTask(FROM_HERE, | 69 ChromeThread::PostTask( |
| 70 ChromeThread::FILE, FROM_HERE, |
| 71 NewRunnableMethod(this, &MemoryDetails::CollectProcessData, child_info)); | 71 NewRunnableMethod(this, &MemoryDetails::CollectProcessData, child_info)); |
| 72 } | 72 } |
| 73 | 73 |
| 74 void MemoryDetails::CollectChildInfoOnUIThread() { | 74 void MemoryDetails::CollectChildInfoOnUIThread() { |
| 75 DCHECK(MessageLoop::current() == ui_loop_); | 75 DCHECK(MessageLoop::current() == ui_loop_); |
| 76 | 76 |
| 77 #if defined(OS_LINUX) | 77 #if defined(OS_LINUX) |
| 78 const pid_t zygote_pid = Singleton<ZygoteHost>()->pid(); | 78 const pid_t zygote_pid = Singleton<ZygoteHost>()->pid(); |
| 79 const pid_t sandbox_helper_pid = Singleton<RenderSandboxHostLinux>()->pid(); | 79 const pid_t sandbox_helper_pid = Singleton<RenderSandboxHostLinux>()->pid(); |
| 80 #endif | 80 #endif |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 BackingStoreManager::MemorySize() / 1024); | 217 BackingStoreManager::MemorySize() / 1024); |
| 218 | 218 |
| 219 UMA_HISTOGRAM_COUNTS_100("Memory.ProcessCount", | 219 UMA_HISTOGRAM_COUNTS_100("Memory.ProcessCount", |
| 220 static_cast<int>(browser.processes.size())); | 220 static_cast<int>(browser.processes.size())); |
| 221 UMA_HISTOGRAM_COUNTS_100("Memory.PluginProcessCount", plugin_count); | 221 UMA_HISTOGRAM_COUNTS_100("Memory.PluginProcessCount", plugin_count); |
| 222 UMA_HISTOGRAM_COUNTS_100("Memory.WorkerProcessCount", worker_count); | 222 UMA_HISTOGRAM_COUNTS_100("Memory.WorkerProcessCount", worker_count); |
| 223 | 223 |
| 224 int total_sample = static_cast<int>(aggregate_memory / 1000); | 224 int total_sample = static_cast<int>(aggregate_memory / 1000); |
| 225 UMA_HISTOGRAM_MEMORY_MB("Memory.Total", total_sample); | 225 UMA_HISTOGRAM_MEMORY_MB("Memory.Total", total_sample); |
| 226 } | 226 } |
| OLD | NEW |