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

Side by Side Diff: webkit/glue/webkit_glue.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.h ('k') | webkit/glue/webkitplatformsupport_impl.cc » ('j') | 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/webkit_glue.h" 5 #include "webkit/glue/webkit_glue.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <objidl.h> 8 #include <objidl.h>
9 #include <mlang.h> 9 #include <mlang.h>
10 #elif defined(OS_POSIX) && !defined(OS_MACOSX) 10 #elif defined(OS_POSIX) && !defined(OS_MACOSX)
11 #include <sys/utsname.h> 11 #include <sys/utsname.h>
12 #endif 12 #endif
13 13
14 #if defined(OS_LINUX)
15 #include <malloc.h>
16 #endif
17
14 #include <limits> 18 #include <limits>
15 19
16 #include "base/logging.h" 20 #include "base/logging.h"
17 #include "base/memory/scoped_ptr.h" 21 #include "base/memory/scoped_ptr.h"
18 #include "base/path_service.h" 22 #include "base/path_service.h"
23 #include "base/process_util.h"
19 #include "base/string_piece.h" 24 #include "base/string_piece.h"
20 #include "base/string_tokenizer.h" 25 #include "base/string_tokenizer.h"
21 #include "base/string_util.h" 26 #include "base/string_util.h"
22 #include "base/stringprintf.h" 27 #include "base/stringprintf.h"
23 #include "base/sys_info.h" 28 #include "base/sys_info.h"
24 #include "base/utf_string_conversions.h" 29 #include "base/utf_string_conversions.h"
25 #include "net/base/escape.h" 30 #include "net/base/escape.h"
26 #include "net/url_request/url_request.h" 31 #include "net/url_request/url_request.h"
27 #include "skia/ext/platform_canvas.h" 32 #include "skia/ext/platform_canvas.h"
28 #if defined(OS_MACOSX) 33 #if defined(OS_MACOSX)
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 case WebKit::WebReferrerPolicyNever: 332 case WebKit::WebReferrerPolicyNever:
328 case WebKit::WebReferrerPolicyOrigin: 333 case WebKit::WebReferrerPolicyOrigin:
329 net_referrer_policy = net::URLRequest::NEVER_CLEAR_REFERRER; 334 net_referrer_policy = net::URLRequest::NEVER_CLEAR_REFERRER;
330 break; 335 break;
331 } 336 }
332 request->set_referrer_policy(net_referrer_policy); 337 request->set_referrer_policy(net_referrer_policy);
333 } 338 }
334 339
335 COMPILE_ASSERT(std::numeric_limits<double>::has_quiet_NaN, has_quiet_NaN); 340 COMPILE_ASSERT(std::numeric_limits<double>::has_quiet_NaN, has_quiet_NaN);
336 341
342 #if defined(OS_LINUX) || defined(OS_ANDROID)
343 size_t MemoryUsageKB() {
344 struct mallinfo minfo = mallinfo();
345 uint64_t mem_usage =
346 #if defined(USE_TCMALLOC)
347 minfo.uordblks
348 #else
349 (minfo.hblkhd + minfo.arena)
350 #endif
351 >> 10;
352
353 v8::HeapStatistics stat;
354 v8::V8::GetHeapStatistics(&stat);
355 return mem_usage + (static_cast<uint64_t>(stat.total_heap_size()) >> 10);
356 }
357 #elif defined(OS_MACOSX)
358 size_t MemoryUsageKB() {
359 scoped_ptr<base::ProcessMetrics> process_metrics(
360 // The default port provider is sufficient to get data for the current
361 // process.
362 base::ProcessMetrics::CreateProcessMetrics(
363 base::GetCurrentProcessHandle(), NULL));
364 return process_metrics->GetWorkingSetSize() >> 10;
365 }
366 #else
367 size_t MemoryUsageKB() {
368 scoped_ptr<base::ProcessMetrics> process_metrics(
369 base::ProcessMetrics::CreateProcessMetrics(
370 base::GetCurrentProcessHandle()));
371 return process_metrics->GetPagefileUsage() >> 10;
372 }
373 #endif
374
337 } // namespace webkit_glue 375 } // namespace webkit_glue
OLDNEW
« no previous file with comments | « webkit/glue/webkit_glue.h ('k') | webkit/glue/webkitplatformsupport_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698