| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #include <psapi.h> | 6 #include <psapi.h> |
| 7 | 7 |
| 8 #include "app/l10n_util.h" | 8 #include "app/l10n_util.h" |
| 9 #include "base/file_version_info.h" | 9 #include "base/file_version_info.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| 11 #include "chrome/browser/browser_process.h" | |
| 12 #include "chrome/browser/chrome_thread.h" | 11 #include "chrome/browser/chrome_thread.h" |
| 13 #include "chrome/browser/renderer_host/backing_store_manager.h" | 12 #include "chrome/browser/renderer_host/backing_store_manager.h" |
| 14 #include "chrome/browser/renderer_host/render_process_host.h" | 13 #include "chrome/browser/renderer_host/render_process_host.h" |
| 15 #include "chrome/browser/tab_contents/navigation_entry.h" | 14 #include "chrome/browser/tab_contents/navigation_entry.h" |
| 16 #include "chrome/browser/tab_contents/tab_contents.h" | 15 #include "chrome/browser/tab_contents/tab_contents.h" |
| 17 #include "chrome/common/child_process_host.h" | 16 #include "chrome/common/child_process_host.h" |
| 18 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
| 19 #include "grit/chromium_strings.h" | 18 #include "grit/chromium_strings.h" |
| 20 | 19 |
| 21 // Known browsers which we collect details for. | 20 // Known browsers which we collect details for. |
| 22 enum { | 21 enum { |
| 23 CHROME_BROWSER = 0, | 22 CHROME_BROWSER = 0, |
| 24 IE_BROWSER, | 23 IE_BROWSER, |
| 25 FIREFOX_BROWSER, | 24 FIREFOX_BROWSER, |
| 26 OPERA_BROWSER, | 25 OPERA_BROWSER, |
| 27 SAFARI_BROWSER, | 26 SAFARI_BROWSER, |
| 28 IE_64BIT_BROWSER, | 27 IE_64BIT_BROWSER, |
| 29 KONQUEROR_BROWSER, | 28 KONQUEROR_BROWSER, |
| 30 MAX_BROWSERS | 29 MAX_BROWSERS |
| 31 } BrowserProcess; | 30 } BrowserProcess; |
| 32 | 31 |
| 33 // Template of static data we use for finding browser process information. | 32 // Template of static data we use for finding browser process information. |
| 34 // These entries must match the ordering for MemoryDetails::BrowserProcess. | 33 // These entries must match the ordering for MemoryDetails::BrowserProcess. |
| 35 static ProcessData g_process_template[MAX_BROWSERS]; | 34 static ProcessData g_process_template[MAX_BROWSERS]; |
| 36 | 35 |
| 37 MemoryDetails::MemoryDetails() | 36 MemoryDetails::MemoryDetails() { |
| 38 : ui_loop_(NULL) { | |
| 39 static const std::wstring google_browser_name = | 37 static const std::wstring google_browser_name = |
| 40 l10n_util::GetString(IDS_PRODUCT_NAME); | 38 l10n_util::GetString(IDS_PRODUCT_NAME); |
| 41 ProcessData g_process_template[MAX_BROWSERS] = { | 39 ProcessData g_process_template[MAX_BROWSERS] = { |
| 42 { google_browser_name.c_str(), L"chrome.exe", }, | 40 { google_browser_name.c_str(), L"chrome.exe", }, |
| 43 { L"IE", L"iexplore.exe", }, | 41 { L"IE", L"iexplore.exe", }, |
| 44 { L"Firefox", L"firefox.exe", }, | 42 { L"Firefox", L"firefox.exe", }, |
| 45 { L"Opera", L"opera.exe", }, | 43 { L"Opera", L"opera.exe", }, |
| 46 { L"Safari", L"safari.exe", }, | 44 { L"Safari", L"safari.exe", }, |
| 47 { L"IE (64bit)", L"iexplore.exe", }, | 45 { L"IE (64bit)", L"iexplore.exe", }, |
| 48 { L"Konqueror", L"konqueror.exe", }, | 46 { L"Konqueror", L"konqueror.exe", }, |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 } | 141 } |
| 144 } | 142 } |
| 145 | 143 |
| 146 // Add the process info to our list. | 144 // Add the process info to our list. |
| 147 process_data_[index2].processes.push_back(info); | 145 process_data_[index2].processes.push_back(info); |
| 148 break; | 146 break; |
| 149 } | 147 } |
| 150 } while (::Process32Next(snapshot, &process_entry)); | 148 } while (::Process32Next(snapshot, &process_entry)); |
| 151 | 149 |
| 152 // Finally return to the browser thread. | 150 // Finally return to the browser thread. |
| 153 ui_loop_->PostTask(FROM_HERE, | 151 ChromeThread::PostTask( |
| 152 ChromeThread::UI, FROM_HERE, |
| 154 NewRunnableMethod(this, &MemoryDetails::CollectChildInfoOnUIThread)); | 153 NewRunnableMethod(this, &MemoryDetails::CollectChildInfoOnUIThread)); |
| 155 } | 154 } |
| OLD | NEW |