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

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

Issue 9669039: Provide access to process private and shared memory size from WebKit code (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Addressed Tony's comments Created 8 years, 6 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
« no previous file with comments | « webkit/glue/webkitplatformsupport_impl.h ('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) 7 #if defined(OS_LINUX)
8 #include <malloc.h> 8 #include <malloc.h>
9 #endif 9 #endif
10 10
(...skipping 651 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 return 0; 662 return 0;
663 } 663 }
664 664
665 WebKit::WebString WebKitPlatformSupportImpl::signedPublicKeyAndChallengeString( 665 WebKit::WebString WebKitPlatformSupportImpl::signedPublicKeyAndChallengeString(
666 unsigned key_size_index, 666 unsigned key_size_index,
667 const WebKit::WebString& challenge, 667 const WebKit::WebString& challenge,
668 const WebKit::WebURL& url) { 668 const WebKit::WebURL& url) {
669 return WebKit::WebString(""); 669 return WebKit::WebString("");
670 } 670 }
671 671
672 static base::ProcessMetrics* CurrentProcessMetrics() {
673 using base::ProcessMetrics;
674 #if defined(OS_MACOSX)
675 static ProcessMetrics* process_metrics =
676 // The default port provider is sufficient to get data for the current
677 // process.
678 ProcessMetrics::CreateProcessMetrics(base::GetCurrentProcessHandle(),
679 NULL);
680 #else
681 static ProcessMetrics* process_metrics =
682 ProcessMetrics::CreateProcessMetrics(base::GetCurrentProcessHandle());
683 #endif
684 DCHECK(process_metrics);
685 return process_metrics;
686 }
687
672 #if defined(OS_LINUX) || defined(OS_ANDROID) 688 #if defined(OS_LINUX) || defined(OS_ANDROID)
673 static size_t memoryUsageMB() { 689 static size_t memoryUsageMB() {
674 struct mallinfo minfo = mallinfo(); 690 struct mallinfo minfo = mallinfo();
675 uint64_t mem_usage = 691 uint64_t mem_usage =
676 #if defined(USE_TCMALLOC) 692 #if defined(USE_TCMALLOC)
677 minfo.uordblks 693 minfo.uordblks
678 #else 694 #else
679 (minfo.hblkhd + minfo.arena) 695 (minfo.hblkhd + minfo.arena)
680 #endif 696 #endif
681 >> 20; 697 >> 20;
682 698
683 v8::HeapStatistics stat; 699 v8::HeapStatistics stat;
684 v8::V8::GetHeapStatistics(&stat); 700 v8::V8::GetHeapStatistics(&stat);
685 return mem_usage + (static_cast<uint64_t>(stat.total_heap_size()) >> 20); 701 return mem_usage + (static_cast<uint64_t>(stat.total_heap_size()) >> 20);
686 } 702 }
687 #elif defined(OS_MACOSX)
688 static size_t memoryUsageMB() {
689 using base::ProcessMetrics;
690 static ProcessMetrics* process_metrics =
691 // The default port provider is sufficient to get data for the current
692 // process.
693 ProcessMetrics::CreateProcessMetrics(base::GetCurrentProcessHandle(),
694 NULL);
695 DCHECK(process_metrics);
696 return process_metrics->GetWorkingSetSize() >> 20;
ulan 2012/09/21 13:30:08 Just noticed that this is missing in the current T
yurys 2012/09/21 13:52:12 Looks like GetWorkingSetSize was deleted by mistak
697 }
698 #else 703 #else
699 static size_t memoryUsageMB() { 704 static size_t memoryUsageMB() {
700 using base::ProcessMetrics; 705 return CurrentProcessMetrics()->GetPagefileUsage() >> 20;
701 static ProcessMetrics* process_metrics =
702 ProcessMetrics::CreateProcessMetrics(base::GetCurrentProcessHandle());
703 DCHECK(process_metrics);
704 return process_metrics->GetPagefileUsage() >> 20;
705 } 706 }
706 #endif 707 #endif
707 708
708 static size_t getMemoryUsageMB(bool bypass_cache) { 709 static size_t getMemoryUsageMB(bool bypass_cache) {
709 size_t current_mem_usage = 0; 710 size_t current_mem_usage = 0;
710 MemoryUsageCache* mem_usage_cache_singleton = MemoryUsageCache::GetInstance(); 711 MemoryUsageCache* mem_usage_cache_singleton = MemoryUsageCache::GetInstance();
711 if (!bypass_cache && 712 if (!bypass_cache &&
712 mem_usage_cache_singleton->IsCachedValueValid(&current_mem_usage)) 713 mem_usage_cache_singleton->IsCachedValueValid(&current_mem_usage))
713 return current_mem_usage; 714 return current_mem_usage;
714 715
(...skipping 26 matching lines...) Expand all
741 size_t WebKitPlatformSupportImpl::highUsageDeltaMB() { 742 size_t WebKitPlatformSupportImpl::highUsageDeltaMB() {
742 // If memory usage is above highMemoryUsageMB() and memory usage increased by 743 // If memory usage is above highMemoryUsageMB() and memory usage increased by
743 // more than highUsageDeltaMB() since the last GC, then force GC. 744 // more than highUsageDeltaMB() since the last GC, then force GC.
744 // Note that this limit should be greater than the amount of memory for V8 745 // Note that this limit should be greater than the amount of memory for V8
745 // internal data structures that are released on GC and reallocated during JS 746 // internal data structures that are released on GC and reallocated during JS
746 // execution (about 8MB). Otherwise, it will cause too aggressive GCs. 747 // execution (about 8MB). Otherwise, it will cause too aggressive GCs.
747 return base::SysInfo::DalvikHeapSizeMB() / 8; 748 return base::SysInfo::DalvikHeapSizeMB() / 8;
748 } 749 }
749 #endif 750 #endif
750 751
752 bool WebKitPlatformSupportImpl::processMemorySizesInBytes(
753 size_t* private_bytes,
754 size_t* shared_bytes) {
755 return CurrentProcessMetrics()->GetMemoryBytes(private_bytes, shared_bytes);
756 }
757
751 void WebKitPlatformSupportImpl::SuspendSharedTimer() { 758 void WebKitPlatformSupportImpl::SuspendSharedTimer() {
752 ++shared_timer_suspended_; 759 ++shared_timer_suspended_;
753 } 760 }
754 761
755 void WebKitPlatformSupportImpl::ResumeSharedTimer() { 762 void WebKitPlatformSupportImpl::ResumeSharedTimer() {
756 // The shared timer may have fired or been adjusted while we were suspended. 763 // The shared timer may have fired or been adjusted while we were suspended.
757 if (--shared_timer_suspended_ == 0 && !shared_timer_.IsRunning()) { 764 if (--shared_timer_suspended_ == 0 && !shared_timer_.IsRunning()) {
758 setSharedTimerFireInterval( 765 setSharedTimerFireInterval(
759 shared_timer_fire_time_ - monotonicallyIncreasingTime()); 766 shared_timer_fire_time_ - monotonicallyIncreasingTime());
760 } 767 }
(...skipping 12 matching lines...) Expand all
773 worker_task_runner->OnWorkerRunLoopStarted(runLoop); 780 worker_task_runner->OnWorkerRunLoopStarted(runLoop);
774 } 781 }
775 782
776 void WebKitPlatformSupportImpl::didStopWorkerRunLoop( 783 void WebKitPlatformSupportImpl::didStopWorkerRunLoop(
777 const WebKit::WebWorkerRunLoop& runLoop) { 784 const WebKit::WebWorkerRunLoop& runLoop) {
778 WorkerTaskRunner* worker_task_runner = WorkerTaskRunner::Instance(); 785 WorkerTaskRunner* worker_task_runner = WorkerTaskRunner::Instance();
779 worker_task_runner->OnWorkerRunLoopStopped(runLoop); 786 worker_task_runner->OnWorkerRunLoopStopped(runLoop);
780 } 787 }
781 788
782 } // namespace webkit_glue 789 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « webkit/glue/webkitplatformsupport_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698