| 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" |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 TabContents* contents = NULL; | 225 TabContents* contents = NULL; |
| 226 if (host->delegate()) | 226 if (host->delegate()) |
| 227 contents = host->delegate()->GetAsTabContents(); | 227 contents = host->delegate()->GetAsTabContents(); |
| 228 if (!contents) | 228 if (!contents) |
| 229 continue; | 229 continue; |
| 230 std::wstring title = UTF16ToWideHack(contents->GetTitle()); | 230 std::wstring title = UTF16ToWideHack(contents->GetTitle()); |
| 231 if (!title.length()) | 231 if (!title.length()) |
| 232 title = L"Untitled"; | 232 title = L"Untitled"; |
| 233 process.titles.push_back(title); | 233 process.titles.push_back(title); |
| 234 | 234 |
| 235 // We need to check the pending entry as well as the display_url to | 235 // We need to check the pending entry as well as the virtual_url to |
| 236 // see if it's an about:memory URL (we don't want to count these in the | 236 // see if it's an about:memory URL (we don't want to count these in the |
| 237 // total memory usage of the browser). | 237 // total memory usage of the browser). |
| 238 // | 238 // |
| 239 // When we reach here, about:memory will be the pending entry since we | 239 // When we reach here, about:memory will be the pending entry since we |
| 240 // haven't responded with any data such that it would be committed. If | 240 // haven't responded with any data such that it would be committed. If |
| 241 // you have another about:memory tab open (which would be committed), | 241 // you have another about:memory tab open (which would be committed), |
| 242 // we don't want to count it either, so we also check the last committed | 242 // we don't want to count it either, so we also check the last committed |
| 243 // entry. | 243 // entry. |
| 244 // | 244 // |
| 245 // Either the pending or last committed entries can be NULL. | 245 // Either the pending or last committed entries can be NULL. |
| 246 const NavigationEntry* pending_entry = | 246 const NavigationEntry* pending_entry = |
| 247 contents->controller().pending_entry(); | 247 contents->controller().pending_entry(); |
| 248 const NavigationEntry* last_committed_entry = | 248 const NavigationEntry* last_committed_entry = |
| 249 contents->controller().GetLastCommittedEntry(); | 249 contents->controller().GetLastCommittedEntry(); |
| 250 if ((last_committed_entry && | 250 if ((last_committed_entry && |
| 251 LowerCaseEqualsASCII(last_committed_entry->display_url().spec(), | 251 LowerCaseEqualsASCII(last_committed_entry->virtual_url().spec(), |
| 252 chrome::kAboutMemoryURL)) || | 252 chrome::kAboutMemoryURL)) || |
| 253 (pending_entry && | 253 (pending_entry && |
| 254 LowerCaseEqualsASCII(pending_entry->display_url().spec(), | 254 LowerCaseEqualsASCII(pending_entry->virtual_url().spec(), |
| 255 chrome::kAboutMemoryURL))) | 255 chrome::kAboutMemoryURL))) |
| 256 process.is_diagnostics = true; | 256 process.is_diagnostics = true; |
| 257 } | 257 } |
| 258 } | 258 } |
| 259 } | 259 } |
| 260 | 260 |
| 261 // Get rid of other Chrome processes that are from a different profile. | 261 // Get rid of other Chrome processes that are from a different profile. |
| 262 for (size_t index = 0; index < process_data_[CHROME_BROWSER].processes.size(); | 262 for (size_t index = 0; index < process_data_[CHROME_BROWSER].processes.size(); |
| 263 index++) { | 263 index++) { |
| 264 if (process_data_[CHROME_BROWSER].processes[index].type == | 264 if (process_data_[CHROME_BROWSER].processes[index].type == |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 } | 304 } |
| 305 | 305 |
| 306 UMA_HISTOGRAM_COUNTS_100("Memory.ProcessCount", | 306 UMA_HISTOGRAM_COUNTS_100("Memory.ProcessCount", |
| 307 static_cast<int>(browser.processes.size())); | 307 static_cast<int>(browser.processes.size())); |
| 308 UMA_HISTOGRAM_COUNTS_100("Memory.PluginProcessCount", plugin_count); | 308 UMA_HISTOGRAM_COUNTS_100("Memory.PluginProcessCount", plugin_count); |
| 309 UMA_HISTOGRAM_COUNTS_100("Memory.WorkerProcessCount", worker_count); | 309 UMA_HISTOGRAM_COUNTS_100("Memory.WorkerProcessCount", worker_count); |
| 310 | 310 |
| 311 int total_sample = static_cast<int>(aggregate_memory / 1000); | 311 int total_sample = static_cast<int>(aggregate_memory / 1000); |
| 312 UMA_HISTOGRAM_MEMORY_MB("Memory.Total", total_sample); | 312 UMA_HISTOGRAM_MEMORY_MB("Memory.Total", total_sample); |
| 313 } | 313 } |
| OLD | NEW |