Chromium Code Reviews| 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 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 434 attributes.lose_context_when_out_of_memory = true; | 434 attributes.lose_context_when_out_of_memory = true; |
| 435 const bool automatic_flushes = false; | 435 const bool automatic_flushes = false; |
| 436 return make_scoped_refptr(new ContextProviderCommandBuffer( | 436 return make_scoped_refptr(new ContextProviderCommandBuffer( |
| 437 std::move(gpu_channel_host), stream_id, stream_priority, | 437 std::move(gpu_channel_host), stream_id, stream_priority, |
| 438 gpu::kNullSurfaceHandle, | 438 gpu::kNullSurfaceHandle, |
| 439 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext"), | 439 GURL("chrome://gpu/RenderThreadImpl::CreateOffscreenContext"), |
| 440 gl::PreferIntegratedGpu, automatic_flushes, support_locking, limits, | 440 gl::PreferIntegratedGpu, automatic_flushes, support_locking, limits, |
| 441 attributes, nullptr, type)); | 441 attributes, nullptr, type)); |
| 442 } | 442 } |
| 443 | 443 |
| 444 void SetRAILModeOnWorker(v8::RAILMode rail_mode) { | |
| 445 if (v8::Isolate* isolate = v8::Isolate::GetCurrent()) | |
|
jochen (gone - plz use gerrit)
2016/06/28 13:20:58
the latest and greatest is introducing helper func
Sami
2016/06/28 13:53:18
I am now aligned with the latest and greatest tren
| |
| 446 isolate->SetRAILMode(rail_mode); | |
| 447 } | |
| 448 | |
| 444 } // namespace | 449 } // namespace |
| 445 | 450 |
| 446 // For measuring memory usage after each task. Behind a command line flag. | 451 // For measuring memory usage after each task. Behind a command line flag. |
| 447 class MemoryObserver : public base::MessageLoop::TaskObserver { | 452 class MemoryObserver : public base::MessageLoop::TaskObserver { |
| 448 public: | 453 public: |
| 449 MemoryObserver() {} | 454 MemoryObserver() {} |
| 450 ~MemoryObserver() override {} | 455 ~MemoryObserver() override {} |
| 451 | 456 |
| 452 void WillProcessTask(const base::PendingTask& pending_task) override {} | 457 void WillProcessTask(const base::PendingTask& pending_task) override {} |
| 453 | 458 |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 941 shared_main_thread_contexts_ = nullptr; | 946 shared_main_thread_contexts_ = nullptr; |
| 942 | 947 |
| 943 if (gpu_channel_.get()) | 948 if (gpu_channel_.get()) |
| 944 gpu_channel_->DestroyChannel(); | 949 gpu_channel_->DestroyChannel(); |
| 945 | 950 |
| 946 ChildThreadImpl::Shutdown(); | 951 ChildThreadImpl::Shutdown(); |
| 947 | 952 |
| 948 // Shut down the message loop and the renderer scheduler before shutting down | 953 // Shut down the message loop and the renderer scheduler before shutting down |
| 949 // Blink. This prevents a scenario where a pending task in the message loop | 954 // Blink. This prevents a scenario where a pending task in the message loop |
| 950 // accesses Blink objects after Blink shuts down. | 955 // accesses Blink objects after Blink shuts down. |
| 956 renderer_scheduler_->SetRAILModeObserver(nullptr); | |
| 951 renderer_scheduler_->Shutdown(); | 957 renderer_scheduler_->Shutdown(); |
| 952 if (main_message_loop_) | 958 if (main_message_loop_) |
| 953 main_message_loop_->RunUntilIdle(); | 959 main_message_loop_->RunUntilIdle(); |
| 954 | 960 |
| 955 if (blink_platform_impl_) { | 961 if (blink_platform_impl_) { |
| 956 blink_platform_impl_->Shutdown(); | 962 blink_platform_impl_->Shutdown(); |
| 957 // This must be at the very end of the shutdown sequence. | 963 // This must be at the very end of the shutdown sequence. |
| 958 // blink::shutdown() must be called after all strong references from | 964 // blink::shutdown() must be called after all strong references from |
| 959 // Chromium to Blink are cleared. | 965 // Chromium to Blink are cleared. |
| 960 blink::shutdown(); | 966 blink::shutdown(); |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1154 SetRuntimeFeaturesDefaultsAndUpdateFromArgs(command_line); | 1160 SetRuntimeFeaturesDefaultsAndUpdateFromArgs(command_line); |
| 1155 | 1161 |
| 1156 blink_platform_impl_.reset(new RendererBlinkPlatformImpl( | 1162 blink_platform_impl_.reset(new RendererBlinkPlatformImpl( |
| 1157 renderer_scheduler_.get(), | 1163 renderer_scheduler_.get(), |
| 1158 GetRemoteInterfaces()->GetWeakPtr())); | 1164 GetRemoteInterfaces()->GetWeakPtr())); |
| 1159 blink::initialize(blink_platform_impl_.get()); | 1165 blink::initialize(blink_platform_impl_.get()); |
| 1160 | 1166 |
| 1161 v8::Isolate* isolate = blink::mainThreadIsolate(); | 1167 v8::Isolate* isolate = blink::mainThreadIsolate(); |
| 1162 isolate->SetCreateHistogramFunction(CreateHistogram); | 1168 isolate->SetCreateHistogramFunction(CreateHistogram); |
| 1163 isolate->SetAddHistogramSampleFunction(AddHistogramSample); | 1169 isolate->SetAddHistogramSampleFunction(AddHistogramSample); |
| 1170 renderer_scheduler_->SetRAILModeObserver(this); | |
| 1164 | 1171 |
| 1165 main_thread_compositor_task_runner_ = | 1172 main_thread_compositor_task_runner_ = |
| 1166 renderer_scheduler_->CompositorTaskRunner(); | 1173 renderer_scheduler_->CompositorTaskRunner(); |
| 1167 | 1174 |
| 1168 main_input_callback_.Reset( | 1175 main_input_callback_.Reset( |
| 1169 base::Bind(base::IgnoreResult(&RenderThreadImpl::OnMessageReceived), | 1176 base::Bind(base::IgnoreResult(&RenderThreadImpl::OnMessageReceived), |
| 1170 base::Unretained(this))); | 1177 base::Unretained(this))); |
| 1171 | 1178 |
| 1172 scoped_refptr<base::SingleThreadTaskRunner> resource_task_queue2; | 1179 scoped_refptr<base::SingleThreadTaskRunner> resource_task_queue2; |
| 1173 if (resource_task_queue) { | 1180 if (resource_task_queue) { |
| (...skipping 447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1621 } | 1628 } |
| 1622 | 1629 |
| 1623 bool RenderThreadImpl::AreImageDecodeTasksEnabled() { | 1630 bool RenderThreadImpl::AreImageDecodeTasksEnabled() { |
| 1624 return are_image_decode_tasks_enabled_; | 1631 return are_image_decode_tasks_enabled_; |
| 1625 } | 1632 } |
| 1626 | 1633 |
| 1627 bool RenderThreadImpl::IsThreadedAnimationEnabled() { | 1634 bool RenderThreadImpl::IsThreadedAnimationEnabled() { |
| 1628 return is_threaded_animation_enabled_; | 1635 return is_threaded_animation_enabled_; |
| 1629 } | 1636 } |
| 1630 | 1637 |
| 1638 void RenderThreadImpl::OnRAILModeChanged(v8::RAILMode rail_mode) { | |
| 1639 blink::mainThreadIsolate()->SetRAILMode(rail_mode); | |
| 1640 WorkerThreadRegistry::Instance()->PostTaskToAllThreads( | |
| 1641 base::Bind(&SetRAILModeOnWorker, rail_mode)); | |
| 1642 } | |
| 1643 | |
| 1631 bool RenderThreadImpl::IsMainThread() { | 1644 bool RenderThreadImpl::IsMainThread() { |
| 1632 return !!current(); | 1645 return !!current(); |
| 1633 } | 1646 } |
| 1634 | 1647 |
| 1635 scoped_refptr<base::SingleThreadTaskRunner> | 1648 scoped_refptr<base::SingleThreadTaskRunner> |
| 1636 RenderThreadImpl::GetIOThreadTaskRunner() { | 1649 RenderThreadImpl::GetIOThreadTaskRunner() { |
| 1637 return io_thread_task_runner_; | 1650 return io_thread_task_runner_; |
| 1638 } | 1651 } |
| 1639 | 1652 |
| 1640 std::unique_ptr<base::SharedMemory> RenderThreadImpl::AllocateSharedMemory( | 1653 std::unique_ptr<base::SharedMemory> RenderThreadImpl::AllocateSharedMemory( |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2207 v8_memory_pressure_level == v8::MemoryPressureLevel::kCritical) | 2220 v8_memory_pressure_level == v8::MemoryPressureLevel::kCritical) |
| 2208 v8_memory_pressure_level = v8::MemoryPressureLevel::kModerate; | 2221 v8_memory_pressure_level = v8::MemoryPressureLevel::kModerate; |
| 2209 | 2222 |
| 2210 blink::mainThreadIsolate()->MemoryPressureNotification( | 2223 blink::mainThreadIsolate()->MemoryPressureNotification( |
| 2211 v8_memory_pressure_level); | 2224 v8_memory_pressure_level); |
| 2212 blink::MemoryPressureNotificationToWorkerThreadIsolates( | 2225 blink::MemoryPressureNotificationToWorkerThreadIsolates( |
| 2213 v8_memory_pressure_level); | 2226 v8_memory_pressure_level); |
| 2214 } | 2227 } |
| 2215 | 2228 |
| 2216 } // namespace content | 2229 } // namespace content |
| OLD | NEW |