| 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 "content/renderer/render_thread_impl.h" | 5 #include "content/renderer/render_thread_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 1793 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1804 FROM_HERE, record_purge_suspend_metric_closure_.callback(), | 1804 FROM_HERE, record_purge_suspend_metric_closure_.callback(), |
| 1805 base::TimeDelta::FromSeconds(15)); | 1805 base::TimeDelta::FromSeconds(15)); |
| 1806 } | 1806 } |
| 1807 | 1807 |
| 1808 // TODO(tasak): Replace the following GetMallocUsage() with memory-infra | 1808 // TODO(tasak): Replace the following GetMallocUsage() with memory-infra |
| 1809 // when it is possible to run memory-infra without tracing. | 1809 // when it is possible to run memory-infra without tracing. |
| 1810 #if defined(OS_WIN) | 1810 #if defined(OS_WIN) |
| 1811 namespace { | 1811 namespace { |
| 1812 | 1812 |
| 1813 static size_t GetMallocUsage() { | 1813 static size_t GetMallocUsage() { |
| 1814 // Only checks the default process heap. | 1814 // Iterate through whichever heap the CRT is using. |
| 1815 HANDLE heap = ::GetProcessHeap(); | 1815 HANDLE crt_heap = reinterpret_cast<HANDLE>(_get_heap_handle()); |
| 1816 if (heap == NULL) | 1816 if (crt_heap == NULL) |
| 1817 return 0; | 1817 return 0; |
| 1818 if (!::HeapLock(heap)) | 1818 if (!::HeapLock(crt_heap)) |
| 1819 return 0 ; | 1819 return 0 ; |
| 1820 size_t malloc_usage = 0; | 1820 size_t malloc_usage = 0; |
| 1821 PROCESS_HEAP_ENTRY heap_entry; | 1821 PROCESS_HEAP_ENTRY heap_entry; |
| 1822 heap_entry.lpData = NULL; | 1822 heap_entry.lpData = NULL; |
| 1823 while (::HeapWalk(heap, &heap_entry) != 0) { | 1823 while (::HeapWalk(crt_heap, &heap_entry) != 0) { |
| 1824 if ((heap_entry.wFlags & PROCESS_HEAP_ENTRY_BUSY) != 0) | 1824 if ((heap_entry.wFlags & PROCESS_HEAP_ENTRY_BUSY) != 0) |
| 1825 malloc_usage += heap_entry.cbData; | 1825 malloc_usage += heap_entry.cbData; |
| 1826 } | 1826 } |
| 1827 ::HeapUnlock(heap); | 1827 ::HeapUnlock(crt_heap); |
| 1828 return malloc_usage; | 1828 return malloc_usage; |
| 1829 } | 1829 } |
| 1830 | 1830 |
| 1831 } // namespace | 1831 } // namespace |
| 1832 #elif defined(OS_MACOSX) || defined(OS_IOS) | 1832 #elif defined(OS_MACOSX) || defined(OS_IOS) |
| 1833 namespace { | 1833 namespace { |
| 1834 | 1834 |
| 1835 static size_t GetMallocUsage() { | 1835 static size_t GetMallocUsage() { |
| 1836 malloc_statistics_t stats = {0}; | 1836 malloc_statistics_t stats = {0}; |
| 1837 malloc_zone_statistics(nullptr, &stats); | 1837 malloc_zone_statistics(nullptr, &stats); |
| (...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2507 } | 2507 } |
| 2508 } | 2508 } |
| 2509 | 2509 |
| 2510 void RenderThreadImpl::OnRendererInterfaceRequest( | 2510 void RenderThreadImpl::OnRendererInterfaceRequest( |
| 2511 mojom::RendererAssociatedRequest request) { | 2511 mojom::RendererAssociatedRequest request) { |
| 2512 DCHECK(!renderer_binding_.is_bound()); | 2512 DCHECK(!renderer_binding_.is_bound()); |
| 2513 renderer_binding_.Bind(std::move(request)); | 2513 renderer_binding_.Bind(std::move(request)); |
| 2514 } | 2514 } |
| 2515 | 2515 |
| 2516 } // namespace content | 2516 } // namespace content |
| OLD | NEW |