Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: chrome/browser/ui/webui/about_ui.cc

Issue 2558043007: Fix free memory calculation. (Closed)
Patch Set: Fix integer overflow in unittest. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/ui/webui/about_ui.h" 5 #include "chrome/browser/ui/webui/about_ui.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 12 matching lines...) Expand all
23 #include "base/macros.h" 23 #include "base/macros.h"
24 #include "base/memory/singleton.h" 24 #include "base/memory/singleton.h"
25 #include "base/metrics/statistics_recorder.h" 25 #include "base/metrics/statistics_recorder.h"
26 #include "base/process/process_metrics.h" 26 #include "base/process/process_metrics.h"
27 #include "base/strings/string_number_conversions.h" 27 #include "base/strings/string_number_conversions.h"
28 #include "base/strings/string_piece.h" 28 #include "base/strings/string_piece.h"
29 #include "base/strings/string_split.h" 29 #include "base/strings/string_split.h"
30 #include "base/strings/string_util.h" 30 #include "base/strings/string_util.h"
31 #include "base/strings/stringprintf.h" 31 #include "base/strings/stringprintf.h"
32 #include "base/strings/utf_string_conversions.h" 32 #include "base/strings/utf_string_conversions.h"
33 #include "base/sys_info.h"
33 #include "base/task_scheduler/post_task.h" 34 #include "base/task_scheduler/post_task.h"
34 #include "base/threading/thread.h" 35 #include "base/threading/thread.h"
35 #include "base/values.h" 36 #include "base/values.h"
36 #include "build/build_config.h" 37 #include "build/build_config.h"
37 #include "chrome/browser/about_flags.h" 38 #include "chrome/browser/about_flags.h"
38 #include "chrome/browser/browser_process.h" 39 #include "chrome/browser/browser_process.h"
39 #include "chrome/browser/defaults.h" 40 #include "chrome/browser/defaults.h"
40 #include "chrome/browser/memory/tab_manager.h" 41 #include "chrome/browser/memory/tab_manager.h"
41 #include "chrome/browser/memory/tab_stats.h" 42 #include "chrome/browser/memory/tab_stats.h"
42 #include "chrome/browser/net/predictor.h" 43 #include "chrome/browser/net/predictor.h"
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 kAboutDiscardsRunCommand)); 546 kAboutDiscardsRunCommand));
546 547
547 base::SystemMemoryInfoKB meminfo; 548 base::SystemMemoryInfoKB meminfo;
548 base::GetSystemMemoryInfo(&meminfo); 549 base::GetSystemMemoryInfo(&meminfo);
549 output.append("<h3>System memory information in MB</h3>"); 550 output.append("<h3>System memory information in MB</h3>");
550 output.append("<table>"); 551 output.append("<table>");
551 // Start with summary statistics. 552 // Start with summary statistics.
552 output.append(AddStringRow( 553 output.append(AddStringRow(
553 "Total", base::IntToString(meminfo.total / 1024))); 554 "Total", base::IntToString(meminfo.total / 1024)));
554 output.append(AddStringRow( 555 output.append(AddStringRow(
555 "Free", base::IntToString(meminfo.free / 1024))); 556 "Free",
557 base::IntToString(base::SysInfo::AmountOfAvailablePhysicalMemory() /
558 1024 / 1024)));
556 #if defined(OS_CHROMEOS) 559 #if defined(OS_CHROMEOS)
557 int mem_allocated_kb = meminfo.active_anon + meminfo.inactive_anon; 560 int mem_allocated_kb = meminfo.active_anon + meminfo.inactive_anon;
558 #if defined(ARCH_CPU_ARM_FAMILY) 561 #if defined(ARCH_CPU_ARM_FAMILY)
559 // ARM counts allocated graphics memory separately from anonymous. 562 // ARM counts allocated graphics memory separately from anonymous.
560 if (meminfo.gem_size != -1) 563 if (meminfo.gem_size != -1)
561 mem_allocated_kb += meminfo.gem_size / 1024; 564 mem_allocated_kb += meminfo.gem_size / 1024;
562 #endif 565 #endif
563 output.append(AddStringRow( 566 output.append(AddStringRow(
564 "Allocated", base::IntToString(mem_allocated_kb / 1024))); 567 "Allocated", base::IntToString(mem_allocated_kb / 1024)));
565 // Add some space, then detailed numbers. 568 // Add some space, then detailed numbers.
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
863 Profile* profile = Profile::FromWebUI(web_ui); 866 Profile* profile = Profile::FromWebUI(web_ui);
864 867
865 #if !defined(OS_ANDROID) 868 #if !defined(OS_ANDROID)
866 // Set up the chrome://theme/ source. 869 // Set up the chrome://theme/ source.
867 ThemeSource* theme = new ThemeSource(profile); 870 ThemeSource* theme = new ThemeSource(profile);
868 content::URLDataSource::Add(profile, theme); 871 content::URLDataSource::Add(profile, theme);
869 #endif 872 #endif
870 873
871 content::URLDataSource::Add(profile, new AboutUIHTMLSource(name, profile)); 874 content::URLDataSource::Add(profile, new AboutUIHTMLSource(name, profile));
872 } 875 }
OLDNEW
« no previous file with comments | « base/sys_info_win.cc ('k') | components/memory_pressure/direct_memory_pressure_calculator_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698