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

Side by Side Diff: webkit/glue/webkitplatformsupport_impl.cc

Issue 11829032: Add a histogram for renderer memory usage. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: moar build fixes Created 7 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « webkit/glue/webkit_glue.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "webkit/glue/webkitplatformsupport_impl.h" 5 #include "webkit/glue/webkitplatformsupport_impl.h"
6 6
7 #if defined(OS_LINUX)
8 #include <malloc.h>
9 #endif
10
11 #include <math.h> 7 #include <math.h>
12 8
13 #include <vector> 9 #include <vector>
14 10
15 #include "base/allocator/allocator_extension.h" 11 #include "base/allocator/allocator_extension.h"
16 #include "base/bind.h" 12 #include "base/bind.h"
17 #include "base/debug/trace_event.h" 13 #include "base/debug/trace_event.h"
18 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
19 #include "base/memory/singleton.h" 15 #include "base/memory/singleton.h"
20 #include "base/message_loop.h" 16 #include "base/message_loop.h"
(...skipping 18 matching lines...) Expand all
39 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h" 35 #include "third_party/WebKit/Source/WebKit/chromium/public/WebScreenInfo.h"
40 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCookie.h" 36 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebCookie.h"
41 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebData.h" 37 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebData.h"
42 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" 38 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
43 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h" 39 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebURL.h"
44 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" 40 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h"
45 #include "ui/base/layout.h" 41 #include "ui/base/layout.h"
46 #include "webkit/base/file_path_string_conversions.h" 42 #include "webkit/base/file_path_string_conversions.h"
47 #include "webkit/compositor_bindings/web_compositor_support_impl.h" 43 #include "webkit/compositor_bindings/web_compositor_support_impl.h"
48 #include "webkit/glue/touch_fling_gesture_curve.h" 44 #include "webkit/glue/touch_fling_gesture_curve.h"
45 #include "webkit/glue/webkit_glue.h"
49 #include "webkit/glue/websocketstreamhandle_impl.h" 46 #include "webkit/glue/websocketstreamhandle_impl.h"
50 #include "webkit/glue/webthread_impl.h" 47 #include "webkit/glue/webthread_impl.h"
51 #include "webkit/glue/weburlloader_impl.h" 48 #include "webkit/glue/weburlloader_impl.h"
52 #include "webkit/glue/worker_task_runner.h" 49 #include "webkit/glue/worker_task_runner.h"
53 #include "webkit/media/audio_decoder.h" 50 #include "webkit/media/audio_decoder.h"
54 #include "webkit/plugins/npapi/plugin_instance.h" 51 #include "webkit/plugins/npapi/plugin_instance.h"
55 #include "webkit/plugins/webplugininfo.h" 52 #include "webkit/plugins/webplugininfo.h"
56 #include "webkit/user_agent/user_agent.h" 53 #include "webkit/user_agent/user_agent.h"
57 54
58 #if defined(OS_ANDROID) 55 #if defined(OS_ANDROID)
59 #include "webkit/glue/fling_animator_impl_android.h" 56 #include "webkit/glue/fling_animator_impl_android.h"
60 #endif 57 #endif
61 58
62 #if defined(OS_LINUX)
63 #include "v8/include/v8.h"
64 #endif
65
66 using WebKit::WebAudioBus; 59 using WebKit::WebAudioBus;
67 using WebKit::WebCookie; 60 using WebKit::WebCookie;
68 using WebKit::WebData; 61 using WebKit::WebData;
69 using WebKit::WebLocalizedString; 62 using WebKit::WebLocalizedString;
70 using WebKit::WebPluginListBuilder; 63 using WebKit::WebPluginListBuilder;
71 using WebKit::WebString; 64 using WebKit::WebString;
72 using WebKit::WebSocketStreamHandle; 65 using WebKit::WebSocketStreamHandle;
73 using WebKit::WebThemeEngine; 66 using WebKit::WebThemeEngine;
74 using WebKit::WebURL; 67 using WebKit::WebURL;
75 using WebKit::WebURLLoader; 68 using WebKit::WebURLLoader;
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 // The default port provider is sufficient to get data for the current 820 // The default port provider is sufficient to get data for the current
828 // process. 821 // process.
829 ProcessMetrics::CreateProcessMetrics(base::GetCurrentProcessHandle(), 822 ProcessMetrics::CreateProcessMetrics(base::GetCurrentProcessHandle(),
830 NULL)); 823 NULL));
831 #else 824 #else
832 return scoped_ptr<ProcessMetrics>( 825 return scoped_ptr<ProcessMetrics>(
833 ProcessMetrics::CreateProcessMetrics(base::GetCurrentProcessHandle())); 826 ProcessMetrics::CreateProcessMetrics(base::GetCurrentProcessHandle()));
834 #endif 827 #endif
835 } 828 }
836 829
837 #if defined(OS_LINUX) || defined(OS_ANDROID)
838 static size_t memoryUsageMB() {
839 struct mallinfo minfo = mallinfo();
840 uint64_t mem_usage =
841 #if defined(USE_TCMALLOC)
842 minfo.uordblks
843 #else
844 (minfo.hblkhd + minfo.arena)
845 #endif
846 >> 20;
847
848 v8::HeapStatistics stat;
849 v8::V8::GetHeapStatistics(&stat);
850 return mem_usage + (static_cast<uint64_t>(stat.total_heap_size()) >> 20);
851 }
852 #elif defined(OS_MACOSX)
853 static size_t memoryUsageMB() {
854 return CurrentProcessMetrics()->GetWorkingSetSize() >> 20;
855 }
856 #else
857 static size_t memoryUsageMB() {
858 return CurrentProcessMetrics()->GetPagefileUsage() >> 20;
859 }
860 #endif
861
862 static size_t getMemoryUsageMB(bool bypass_cache) { 830 static size_t getMemoryUsageMB(bool bypass_cache) {
863 size_t current_mem_usage = 0; 831 size_t current_mem_usage = 0;
864 MemoryUsageCache* mem_usage_cache_singleton = MemoryUsageCache::GetInstance(); 832 MemoryUsageCache* mem_usage_cache_singleton = MemoryUsageCache::GetInstance();
865 if (!bypass_cache && 833 if (!bypass_cache &&
866 mem_usage_cache_singleton->IsCachedValueValid(&current_mem_usage)) 834 mem_usage_cache_singleton->IsCachedValueValid(&current_mem_usage))
867 return current_mem_usage; 835 return current_mem_usage;
868 836
869 current_mem_usage = memoryUsageMB(); 837 current_mem_usage = MemoryUsageKB() >> 10;
870 mem_usage_cache_singleton->SetMemoryValue(current_mem_usage); 838 mem_usage_cache_singleton->SetMemoryValue(current_mem_usage);
871 return current_mem_usage; 839 return current_mem_usage;
872 } 840 }
873 841
874 size_t WebKitPlatformSupportImpl::memoryUsageMB() { 842 size_t WebKitPlatformSupportImpl::memoryUsageMB() {
875 return getMemoryUsageMB(false); 843 return getMemoryUsageMB(false);
876 } 844 }
877 845
878 size_t WebKitPlatformSupportImpl::actualMemoryUsageMB() { 846 size_t WebKitPlatformSupportImpl::actualMemoryUsageMB() {
879 return getMemoryUsageMB(true); 847 return getMemoryUsageMB(true);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 #endif 922 #endif
955 923
956 if (device_source == WebKit::WebGestureEvent::Touchscreen) 924 if (device_source == WebKit::WebGestureEvent::Touchscreen)
957 return TouchFlingGestureCurve::CreateForTouchScreen(velocity, 925 return TouchFlingGestureCurve::CreateForTouchScreen(velocity,
958 cumulative_scroll); 926 cumulative_scroll);
959 927
960 return TouchFlingGestureCurve::CreateForTouchPad(velocity, cumulative_scroll); 928 return TouchFlingGestureCurve::CreateForTouchPad(velocity, cumulative_scroll);
961 } 929 }
962 930
963 } // namespace webkit_glue 931 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « webkit/glue/webkit_glue.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698