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

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: . 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
« webkit/glue/memory_usage.h ('K') | « webkit/glue/webkit_glue.gypi ('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 17 matching lines...) Expand all
38 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginListBuilder. h" 34 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginListBuilder. h"
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"
44 #include "webkit/glue/memory_usage.h"
48 #include "webkit/glue/touch_fling_gesture_curve.h" 45 #include "webkit/glue/touch_fling_gesture_curve.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 673 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 // The default port provider is sufficient to get data for the current 742 // The default port provider is sufficient to get data for the current
750 // process. 743 // process.
751 ProcessMetrics::CreateProcessMetrics(base::GetCurrentProcessHandle(), 744 ProcessMetrics::CreateProcessMetrics(base::GetCurrentProcessHandle(),
752 NULL)); 745 NULL));
753 #else 746 #else
754 return scoped_ptr<ProcessMetrics>( 747 return scoped_ptr<ProcessMetrics>(
755 ProcessMetrics::CreateProcessMetrics(base::GetCurrentProcessHandle())); 748 ProcessMetrics::CreateProcessMetrics(base::GetCurrentProcessHandle()));
756 #endif 749 #endif
757 } 750 }
758 751
759 #if defined(OS_LINUX) || defined(OS_ANDROID)
760 static size_t memoryUsageMB() {
761 struct mallinfo minfo = mallinfo();
762 uint64_t mem_usage =
763 #if defined(USE_TCMALLOC)
764 minfo.uordblks
765 #else
766 (minfo.hblkhd + minfo.arena)
767 #endif
768 >> 20;
769
770 v8::HeapStatistics stat;
771 v8::V8::GetHeapStatistics(&stat);
772 return mem_usage + (static_cast<uint64_t>(stat.total_heap_size()) >> 20);
773 }
774 #elif defined(OS_MACOSX)
775 static size_t memoryUsageMB() {
776 return CurrentProcessMetrics()->GetWorkingSetSize() >> 20;
777 }
778 #else
779 static size_t memoryUsageMB() {
780 return CurrentProcessMetrics()->GetPagefileUsage() >> 20;
781 }
782 #endif
783
784 static size_t getMemoryUsageMB(bool bypass_cache) { 752 static size_t getMemoryUsageMB(bool bypass_cache) {
785 size_t current_mem_usage = 0; 753 size_t current_mem_usage = 0;
786 MemoryUsageCache* mem_usage_cache_singleton = MemoryUsageCache::GetInstance(); 754 MemoryUsageCache* mem_usage_cache_singleton = MemoryUsageCache::GetInstance();
787 if (!bypass_cache && 755 if (!bypass_cache &&
788 mem_usage_cache_singleton->IsCachedValueValid(&current_mem_usage)) 756 mem_usage_cache_singleton->IsCachedValueValid(&current_mem_usage))
789 return current_mem_usage; 757 return current_mem_usage;
790 758
791 current_mem_usage = memoryUsageMB(); 759 current_mem_usage = memoryUsageKB() >> 10;
792 mem_usage_cache_singleton->SetMemoryValue(current_mem_usage); 760 mem_usage_cache_singleton->SetMemoryValue(current_mem_usage);
793 return current_mem_usage; 761 return current_mem_usage;
794 } 762 }
795 763
796 size_t WebKitPlatformSupportImpl::memoryUsageMB() { 764 size_t WebKitPlatformSupportImpl::memoryUsageMB() {
797 return getMemoryUsageMB(false); 765 return getMemoryUsageMB(false);
798 } 766 }
799 767
800 size_t WebKitPlatformSupportImpl::actualMemoryUsageMB() { 768 size_t WebKitPlatformSupportImpl::actualMemoryUsageMB() {
801 return getMemoryUsageMB(true); 769 return getMemoryUsageMB(true);
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
876 #endif 844 #endif
877 845
878 if (device_source == WebKit::WebGestureEvent::Touchscreen) 846 if (device_source == WebKit::WebGestureEvent::Touchscreen)
879 return TouchFlingGestureCurve::CreateForTouchScreen(velocity, 847 return TouchFlingGestureCurve::CreateForTouchScreen(velocity,
880 cumulative_scroll); 848 cumulative_scroll);
881 849
882 return TouchFlingGestureCurve::CreateForTouchPad(velocity, cumulative_scroll); 850 return TouchFlingGestureCurve::CreateForTouchPad(velocity, cumulative_scroll);
883 } 851 }
884 852
885 } // namespace webkit_glue 853 } // namespace webkit_glue
OLDNEW
« webkit/glue/memory_usage.h ('K') | « webkit/glue/webkit_glue.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698