| 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 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 base::Bind(&RenderThreadImpl::OnMemoryPressure, base::Unretained(this)), | 814 base::Bind(&RenderThreadImpl::OnMemoryPressure, base::Unretained(this)), |
| 815 base::Bind(&RenderThreadImpl::OnSyncMemoryPressure, | 815 base::Bind(&RenderThreadImpl::OnSyncMemoryPressure, |
| 816 base::Unretained(this)))); | 816 base::Unretained(this)))); |
| 817 | 817 |
| 818 if (memory_coordinator::IsEnabled()) { | 818 if (memory_coordinator::IsEnabled()) { |
| 819 // TODO(bashi): Revisit how to manage the lifetime of | 819 // TODO(bashi): Revisit how to manage the lifetime of |
| 820 // ChildMemoryCoordinatorImpl. | 820 // ChildMemoryCoordinatorImpl. |
| 821 // https://codereview.chromium.org/2094583002/#msg52 | 821 // https://codereview.chromium.org/2094583002/#msg52 |
| 822 memory_coordinator::mojom::MemoryCoordinatorHandlePtr parent_coordinator; | 822 memory_coordinator::mojom::MemoryCoordinatorHandlePtr parent_coordinator; |
| 823 GetRemoteInterfaces()->GetInterface(mojo::GetProxy(&parent_coordinator)); | 823 GetRemoteInterfaces()->GetInterface(mojo::GetProxy(&parent_coordinator)); |
| 824 memory_coordinator_.reset( | 824 memory_coordinator_ = memory_coordinator::CreateChildMemoryCoordinator( |
| 825 new memory_coordinator::ChildMemoryCoordinatorImpl( | 825 std::move(parent_coordinator), this); |
| 826 std::move(parent_coordinator))); | |
| 827 } | 826 } |
| 828 | 827 |
| 829 int num_raster_threads = 0; | 828 int num_raster_threads = 0; |
| 830 std::string string_value = | 829 std::string string_value = |
| 831 command_line.GetSwitchValueASCII(switches::kNumRasterThreads); | 830 command_line.GetSwitchValueASCII(switches::kNumRasterThreads); |
| 832 bool parsed_num_raster_threads = | 831 bool parsed_num_raster_threads = |
| 833 base::StringToInt(string_value, &num_raster_threads); | 832 base::StringToInt(string_value, &num_raster_threads); |
| 834 DCHECK(parsed_num_raster_threads) << string_value; | 833 DCHECK(parsed_num_raster_threads) << string_value; |
| 835 DCHECK_GT(num_raster_threads, 0); | 834 DCHECK_GT(num_raster_threads, 0); |
| 836 | 835 |
| (...skipping 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2209 if (!RendererIsHidden() && | 2208 if (!RendererIsHidden() && |
| 2210 v8_memory_pressure_level == v8::MemoryPressureLevel::kCritical) | 2209 v8_memory_pressure_level == v8::MemoryPressureLevel::kCritical) |
| 2211 v8_memory_pressure_level = v8::MemoryPressureLevel::kModerate; | 2210 v8_memory_pressure_level = v8::MemoryPressureLevel::kModerate; |
| 2212 | 2211 |
| 2213 blink::mainThreadIsolate()->MemoryPressureNotification( | 2212 blink::mainThreadIsolate()->MemoryPressureNotification( |
| 2214 v8_memory_pressure_level); | 2213 v8_memory_pressure_level); |
| 2215 blink::MemoryPressureNotificationToWorkerThreadIsolates( | 2214 blink::MemoryPressureNotificationToWorkerThreadIsolates( |
| 2216 v8_memory_pressure_level); | 2215 v8_memory_pressure_level); |
| 2217 } | 2216 } |
| 2218 | 2217 |
| 2218 // Note that this would be called only when memory_coordinator is enabled. |
| 2219 // OnSyncMemoryPressure() is never called in that case. |
| 2220 void RenderThreadImpl::OnTrimMemoryImmediately() { |
| 2221 if (blink::mainThreadIsolate()) { |
| 2222 blink::mainThreadIsolate()->MemoryPressureNotification( |
| 2223 v8::MemoryPressureLevel::kCritical); |
| 2224 blink::MemoryPressureNotificationToWorkerThreadIsolates( |
| 2225 v8::MemoryPressureLevel::kCritical); |
| 2226 } |
| 2227 } |
| 2228 |
| 2229 |
| 2219 } // namespace content | 2230 } // namespace content |
| OLD | NEW |