| OLD | NEW |
| 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 <mlang.h> | 8 #include <mlang.h> |
| 9 #include <objidl.h> | 9 #include <objidl.h> |
| 10 #elif defined(OS_POSIX) && !defined(OS_MACOSX) | 10 #elif defined(OS_POSIX) && !defined(OS_MACOSX) |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 struct mallinfo minfo = mallinfo(); | 344 struct mallinfo minfo = mallinfo(); |
| 345 uint64_t mem_usage = | 345 uint64_t mem_usage = |
| 346 #if defined(USE_TCMALLOC) | 346 #if defined(USE_TCMALLOC) |
| 347 minfo.uordblks | 347 minfo.uordblks |
| 348 #else | 348 #else |
| 349 (minfo.hblkhd + minfo.arena) | 349 (minfo.hblkhd + minfo.arena) |
| 350 #endif | 350 #endif |
| 351 >> 10; | 351 >> 10; |
| 352 | 352 |
| 353 v8::HeapStatistics stat; | 353 v8::HeapStatistics stat; |
| 354 v8::V8::GetHeapStatistics(&stat); | 354 // TODO(svenpanne) The call below doesn't take web workers into account, this |
| 355 // has to be done manually by iterating over all Isolates involved. |
| 356 v8::Isolate::GetCurrent()->GetHeapStatistics(&stat); |
| 355 return mem_usage + (static_cast<uint64_t>(stat.total_heap_size()) >> 10); | 357 return mem_usage + (static_cast<uint64_t>(stat.total_heap_size()) >> 10); |
| 356 } | 358 } |
| 357 #elif defined(OS_MACOSX) | 359 #elif defined(OS_MACOSX) |
| 358 size_t MemoryUsageKB() { | 360 size_t MemoryUsageKB() { |
| 359 scoped_ptr<base::ProcessMetrics> process_metrics( | 361 scoped_ptr<base::ProcessMetrics> process_metrics( |
| 360 // The default port provider is sufficient to get data for the current | 362 // The default port provider is sufficient to get data for the current |
| 361 // process. | 363 // process. |
| 362 base::ProcessMetrics::CreateProcessMetrics( | 364 base::ProcessMetrics::CreateProcessMetrics( |
| 363 base::GetCurrentProcessHandle(), NULL)); | 365 base::GetCurrentProcessHandle(), NULL)); |
| 364 return process_metrics->GetWorkingSetSize() >> 10; | 366 return process_metrics->GetWorkingSetSize() >> 10; |
| 365 } | 367 } |
| 366 #else | 368 #else |
| 367 size_t MemoryUsageKB() { | 369 size_t MemoryUsageKB() { |
| 368 scoped_ptr<base::ProcessMetrics> process_metrics( | 370 scoped_ptr<base::ProcessMetrics> process_metrics( |
| 369 base::ProcessMetrics::CreateProcessMetrics( | 371 base::ProcessMetrics::CreateProcessMetrics( |
| 370 base::GetCurrentProcessHandle())); | 372 base::GetCurrentProcessHandle())); |
| 371 return process_metrics->GetPagefileUsage() >> 10; | 373 return process_metrics->GetPagefileUsage() >> 10; |
| 372 } | 374 } |
| 373 #endif | 375 #endif |
| 374 | 376 |
| 375 double ZoomFactorToZoomLevel(double factor) { | 377 double ZoomFactorToZoomLevel(double factor) { |
| 376 return WebView::zoomFactorToZoomLevel(factor); | 378 return WebView::zoomFactorToZoomLevel(factor); |
| 377 } | 379 } |
| 378 | 380 |
| 379 } // namespace webkit_glue | 381 } // namespace webkit_glue |
| OLD | NEW |