diff options
author | fdoray <fdoray@chromium.org> | 2015-11-11 17:12:32 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-11-12 01:13:07 +0000 |
commit | 28787424acfc81f458824812a35c67d461b84035 (patch) | |
tree | 4397eac47c27644a7f12e9b773468488f1ca61a6 /content | |
parent | c441f78fcb48ef54a880e32fc2b43996958d3eb9 (diff) | |
download | chromium_src-28787424acfc81f458824812a35c67d461b84035.zip chromium_src-28787424acfc81f458824812a35c67d461b84035.tar.gz chromium_src-28787424acfc81f458824812a35c67d461b84035.tar.bz2 |
Add ProcessMetrics::CreateCurrentProcessMetrics() method.
Code that creates a ProcessMetrics object can be confusing because
ProcessMetrics::CreateProcessMetrics() has a different signature on Mac.
The extra Mac parameter isn't required when creating a ProcessMetrics
object for the current process (which is a common thing to do).
To allow simplification of code that creates a ProcessMetrics object
for the current process, this CL introduces a new
ProcessMetrics::CreateCurrentProcessMetrics() method, which has the
same signature on all platforms.
BUG=553266
Review URL: https://codereview.chromium.org/1433603004
Cr-Commit-Position: refs/heads/master@{#359199}
Diffstat (limited to 'content')
-rw-r--r-- | content/browser/browser_main_loop.cc | 7 | ||||
-rw-r--r-- | content/child/blink_platform_impl.cc | 18 |
2 files changed, 4 insertions, 21 deletions
diff --git a/content/browser/browser_main_loop.cc b/content/browser/browser_main_loop.cc index 70db843..8566b99 100644 --- a/content/browser/browser_main_loop.cc +++ b/content/browser/browser_main_loop.cc @@ -374,12 +374,7 @@ class BrowserMainLoop::MemoryObserver : public base::MessageLoop::TaskObserver { void DidProcessTask(const base::PendingTask& pending_task) override { #if !defined(OS_IOS) // No ProcessMetrics on IOS. scoped_ptr<base::ProcessMetrics> process_metrics( - base::ProcessMetrics::CreateProcessMetrics( -#if defined(OS_MACOSX) - base::GetCurrentProcessHandle(), NULL)); -#else - base::GetCurrentProcessHandle())); -#endif + base::ProcessMetrics::CreateCurrentProcessMetrics()); size_t private_bytes; process_metrics->GetMemoryBytes(&private_bytes, NULL); LOCAL_HISTOGRAM_MEMORY_KB("Memory.BrowserUsed", private_bytes >> 10); diff --git a/content/child/blink_platform_impl.cc b/content/child/blink_platform_impl.cc index 67c6f8e..b21a722 100644 --- a/content/child/blink_platform_impl.cc +++ b/content/child/blink_platform_impl.cc @@ -1215,20 +1215,6 @@ blink::WebString BlinkPlatformImpl::signedPublicKeyAndChallengeString( return blink::WebString(""); } -static scoped_ptr<base::ProcessMetrics> CurrentProcessMetrics() { - using base::ProcessMetrics; -#if defined(OS_MACOSX) - return scoped_ptr<ProcessMetrics>( - // The default port provider is sufficient to get data for the current - // process. - ProcessMetrics::CreateProcessMetrics(base::GetCurrentProcessHandle(), - NULL)); -#else - return scoped_ptr<ProcessMetrics>( - ProcessMetrics::CreateProcessMetrics(base::GetCurrentProcessHandle())); -#endif -} - static size_t getMemoryUsageMB(bool bypass_cache) { size_t current_mem_usage = 0; MemoryUsageCache* mem_usage_cache_singleton = MemoryUsageCache::GetInstance(); @@ -1268,7 +1254,9 @@ size_t BlinkPlatformImpl::numberOfProcessors() { bool BlinkPlatformImpl::processMemorySizesInBytes( size_t* private_bytes, size_t* shared_bytes) { - return CurrentProcessMetrics()->GetMemoryBytes(private_bytes, shared_bytes); + scoped_ptr<base::ProcessMetrics> current_process_metrics( + base::ProcessMetrics::CreateCurrentProcessMetrics()); + return current_process_metrics->GetMemoryBytes(private_bytes, shared_bytes); } bool BlinkPlatformImpl::memoryAllocatorWasteInBytes(size_t* size) { |