| 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 1748 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1759 renderer_scheduler_->OnRendererBackgrounded(); | 1759 renderer_scheduler_->OnRendererBackgrounded(); |
| 1760 } else { | 1760 } else { |
| 1761 renderer_scheduler_->OnRendererForegrounded(); | 1761 renderer_scheduler_->OnRendererForegrounded(); |
| 1762 record_purge_suspend_metric_closure_.Cancel(); | 1762 record_purge_suspend_metric_closure_.Cancel(); |
| 1763 is_renderer_suspended_ = false; | 1763 is_renderer_suspended_ = false; |
| 1764 } | 1764 } |
| 1765 } | 1765 } |
| 1766 | 1766 |
| 1767 void RenderThreadImpl::OnProcessPurgeAndSuspend() { | 1767 void RenderThreadImpl::OnProcessPurgeAndSuspend() { |
| 1768 ChildThreadImpl::OnProcessPurgeAndSuspend(); | 1768 ChildThreadImpl::OnProcessPurgeAndSuspend(); |
| 1769 if (is_renderer_suspended_) | 1769 if (is_renderer_suspended_ || !RendererIsHidden()) |
| 1770 return; | 1770 return; |
| 1771 // TODO(hajimehoshi): Implement purging e.g. cache (crbug/607077) | 1771 // TODO(hajimehoshi): Implement purging e.g. cache (crbug/607077) |
| 1772 is_renderer_suspended_ = true; | 1772 is_renderer_suspended_ = true; |
| 1773 renderer_scheduler_->SuspendRenderer(); | 1773 renderer_scheduler_->SuspendRenderer(); |
| 1774 | 1774 |
| 1775 // Since purging is not a synchronous task (e.g. v8 GC, oilpan GC, ...), | 1775 // Since purging is not a synchronous task (e.g. v8 GC, oilpan GC, ...), |
| 1776 // we need to wait until the task is finished. So wait 15 seconds and | 1776 // we need to wait until the task is finished. So wait 15 seconds and |
| 1777 // update purge+suspend UMA histogram. | 1777 // update purge+suspend UMA histogram. |
| 1778 // TODO(tasak): use MemoryCoordinator's callback to report purge+suspend | 1778 // TODO(tasak): use MemoryCoordinator's callback to report purge+suspend |
| 1779 // UMA when MemoryCoordinator is available. | 1779 // UMA when MemoryCoordinator is available. |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1870 // memory-infra. | 1870 // memory-infra. |
| 1871 UMA_HISTOGRAM_MEMORY_MB("PurgeAndSuspend.Memory.V8MainThreadIsolateMB", | 1871 UMA_HISTOGRAM_MEMORY_MB("PurgeAndSuspend.Memory.V8MainThreadIsolateMB", |
| 1872 v8_usage / 1024 / 1024); | 1872 v8_usage / 1024 / 1024); |
| 1873 UMA_HISTOGRAM_MEMORY_MB("PurgeAndSuspend.Memory.TotalAllocatedMB", | 1873 UMA_HISTOGRAM_MEMORY_MB("PurgeAndSuspend.Memory.TotalAllocatedMB", |
| 1874 (blink_stats.partitionAllocTotalAllocatedBytes + | 1874 (blink_stats.partitionAllocTotalAllocatedBytes + |
| 1875 blink_stats.blinkGCTotalAllocatedBytes + | 1875 blink_stats.blinkGCTotalAllocatedBytes + |
| 1876 malloc_usage + v8_usage + discardable_usage) / | 1876 malloc_usage + v8_usage + discardable_usage) / |
| 1877 1024 / 1024); | 1877 1024 / 1024); |
| 1878 } | 1878 } |
| 1879 | 1879 |
| 1880 void RenderThreadImpl::OnProcessResume() { |
| 1881 ChildThreadImpl::OnProcessResume(); |
| 1882 if (!is_renderer_suspended_) |
| 1883 return; |
| 1884 |
| 1885 is_renderer_suspended_ = false; |
| 1886 renderer_scheduler_->ResumeRenderer(); |
| 1887 } |
| 1888 |
| 1880 scoped_refptr<gpu::GpuChannelHost> RenderThreadImpl::EstablishGpuChannelSync() { | 1889 scoped_refptr<gpu::GpuChannelHost> RenderThreadImpl::EstablishGpuChannelSync() { |
| 1881 TRACE_EVENT0("gpu", "RenderThreadImpl::EstablishGpuChannelSync"); | 1890 TRACE_EVENT0("gpu", "RenderThreadImpl::EstablishGpuChannelSync"); |
| 1882 | 1891 |
| 1883 if (gpu_channel_) { | 1892 if (gpu_channel_) { |
| 1884 // Do nothing if we already have a GPU channel or are already | 1893 // Do nothing if we already have a GPU channel or are already |
| 1885 // establishing one. | 1894 // establishing one. |
| 1886 if (!gpu_channel_->IsLost()) | 1895 if (!gpu_channel_->IsLost()) |
| 1887 return gpu_channel_; | 1896 return gpu_channel_; |
| 1888 | 1897 |
| 1889 // Recreate the channel if it has been lost. | 1898 // Recreate the channel if it has been lost. |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2471 } | 2480 } |
| 2472 } | 2481 } |
| 2473 | 2482 |
| 2474 void RenderThreadImpl::OnRendererInterfaceRequest( | 2483 void RenderThreadImpl::OnRendererInterfaceRequest( |
| 2475 mojom::RendererAssociatedRequest request) { | 2484 mojom::RendererAssociatedRequest request) { |
| 2476 DCHECK(!renderer_binding_.is_bound()); | 2485 DCHECK(!renderer_binding_.is_bound()); |
| 2477 renderer_binding_.Bind(std::move(request)); | 2486 renderer_binding_.Bind(std::move(request)); |
| 2478 } | 2487 } |
| 2479 | 2488 |
| 2480 } // namespace content | 2489 } // namespace content |
| OLD | NEW |