Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Side by Side Diff: services/ui/gpu/gpu_service.cc

Issue 2814843002: gpu: GPU service scheduler. (Closed)
Patch Set: Do not allow HIGH priority contexts by unprivileged clients. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "services/ui/gpu/gpu_service.h" 5 #include "services/ui/gpu/gpu_service.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/debug/crash_logging.h" 8 #include "base/debug/crash_logging.h"
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "base/threading/thread_task_runner_handle.h" 12 #include "base/threading/thread_task_runner_handle.h"
13 #include "build/build_config.h" 13 #include "build/build_config.h"
14 #include "cc/output/in_process_context_provider.h" 14 #include "cc/output/in_process_context_provider.h"
15 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h" 15 #include "gpu/command_buffer/client/gpu_memory_buffer_manager.h"
16 #include "gpu/command_buffer/service/gpu_switches.h" 16 #include "gpu/command_buffer/service/gpu_switches.h"
17 #include "gpu/command_buffer/service/scheduler.h"
17 #include "gpu/command_buffer/service/sync_point_manager.h" 18 #include "gpu/command_buffer/service/sync_point_manager.h"
18 #include "gpu/config/gpu_info_collector.h" 19 #include "gpu/config/gpu_info_collector.h"
19 #include "gpu/config/gpu_switches.h" 20 #include "gpu/config/gpu_switches.h"
20 #include "gpu/config/gpu_util.h" 21 #include "gpu/config/gpu_util.h"
21 #include "gpu/ipc/common/gpu_memory_buffer_support.h" 22 #include "gpu/ipc/common/gpu_memory_buffer_support.h"
22 #include "gpu/ipc/common/memory_stats.h" 23 #include "gpu/ipc/common/memory_stats.h"
23 #include "gpu/ipc/gpu_in_process_thread_service.h" 24 #include "gpu/ipc/gpu_in_process_thread_service.h"
24 #include "gpu/ipc/service/gpu_channel.h" 25 #include "gpu/ipc/service/gpu_channel.h"
25 #include "gpu/ipc/service/gpu_channel_manager.h" 26 #include "gpu/ipc/service/gpu_channel_manager.h"
26 #include "gpu/ipc/service/gpu_memory_buffer_factory.h" 27 #include "gpu/ipc/service/gpu_memory_buffer_factory.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 std::unique_ptr<gpu::GpuWatchdogThread> watchdog_thread, 88 std::unique_ptr<gpu::GpuWatchdogThread> watchdog_thread,
88 scoped_refptr<base::SingleThreadTaskRunner> io_runner, 89 scoped_refptr<base::SingleThreadTaskRunner> io_runner,
89 const gpu::GpuFeatureInfo& gpu_feature_info) 90 const gpu::GpuFeatureInfo& gpu_feature_info)
90 : main_runner_(base::ThreadTaskRunnerHandle::Get()), 91 : main_runner_(base::ThreadTaskRunnerHandle::Get()),
91 io_runner_(std::move(io_runner)), 92 io_runner_(std::move(io_runner)),
92 watchdog_thread_(std::move(watchdog_thread)), 93 watchdog_thread_(std::move(watchdog_thread)),
93 gpu_memory_buffer_factory_( 94 gpu_memory_buffer_factory_(
94 gpu::GpuMemoryBufferFactory::CreateNativeType()), 95 gpu::GpuMemoryBufferFactory::CreateNativeType()),
95 gpu_info_(gpu_info), 96 gpu_info_(gpu_info),
96 gpu_feature_info_(gpu_feature_info), 97 gpu_feature_info_(gpu_feature_info),
97 sync_point_manager_(nullptr),
98 bindings_(base::MakeUnique<mojo::BindingSet<mojom::GpuService>>()), 98 bindings_(base::MakeUnique<mojo::BindingSet<mojom::GpuService>>()),
99 weak_ptr_factory_(this) { 99 weak_ptr_factory_(this) {
100 weak_ptr_ = weak_ptr_factory_.GetWeakPtr(); 100 weak_ptr_ = weak_ptr_factory_.GetWeakPtr();
101 } 101 }
102 102
103 GpuService::~GpuService() { 103 GpuService::~GpuService() {
104 DCHECK(main_runner_->BelongsToCurrentThread()); 104 DCHECK(main_runner_->BelongsToCurrentThread());
105 bind_task_tracker_.TryCancelAll(); 105 bind_task_tracker_.TryCancelAll();
106 logging::SetLogMessageHandler(nullptr); 106 logging::SetLogMessageHandler(nullptr);
107 g_log_callback.Get() = 107 g_log_callback.Get() =
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 } 161 }
162 162
163 shutdown_event_ = shutdown_event; 163 shutdown_event_ = shutdown_event;
164 if (!shutdown_event_) { 164 if (!shutdown_event_) {
165 owned_shutdown_event_ = base::MakeUnique<base::WaitableEvent>( 165 owned_shutdown_event_ = base::MakeUnique<base::WaitableEvent>(
166 base::WaitableEvent::ResetPolicy::MANUAL, 166 base::WaitableEvent::ResetPolicy::MANUAL,
167 base::WaitableEvent::InitialState::NOT_SIGNALED); 167 base::WaitableEvent::InitialState::NOT_SIGNALED);
168 shutdown_event_ = owned_shutdown_event_.get(); 168 shutdown_event_ = owned_shutdown_event_.get();
169 } 169 }
170 170
171 if (gpu_preferences_.enable_gpu_scheduler) {
172 scheduler_ = base::MakeUnique<gpu::Scheduler>(
173 base::ThreadTaskRunnerHandle::Get(), sync_point_manager_);
174 }
175
171 // Defer creation of the render thread. This is to prevent it from handling 176 // Defer creation of the render thread. This is to prevent it from handling
172 // IPC messages before the sandbox has been enabled and all other necessary 177 // IPC messages before the sandbox has been enabled and all other necessary
173 // initialization has succeeded. 178 // initialization has succeeded.
174 gpu_channel_manager_.reset(new gpu::GpuChannelManager( 179 gpu_channel_manager_.reset(new gpu::GpuChannelManager(
175 gpu_preferences_, this, watchdog_thread_.get(), 180 gpu_preferences_, this, watchdog_thread_.get(),
176 base::ThreadTaskRunnerHandle::Get(), io_runner_, sync_point_manager_, 181 base::ThreadTaskRunnerHandle::Get(), io_runner_, scheduler_.get(),
177 gpu_memory_buffer_factory_.get(), gpu_feature_info_, 182 sync_point_manager_, gpu_memory_buffer_factory_.get(), gpu_feature_info_,
178 std::move(activity_flags))); 183 std::move(activity_flags)));
179 184
180 media_gpu_channel_manager_.reset( 185 media_gpu_channel_manager_.reset(
181 new media::MediaGpuChannelManager(gpu_channel_manager_.get())); 186 new media::MediaGpuChannelManager(gpu_channel_manager_.get()));
182 if (watchdog_thread()) 187 if (watchdog_thread())
183 watchdog_thread()->AddPowerObserver(); 188 watchdog_thread()->AddPowerObserver();
184 } 189 }
185 190
186 void GpuService::Bind(mojom::GpuServiceRequest request) { 191 void GpuService::Bind(mojom::GpuServiceRequest request) {
187 if (main_runner_->BelongsToCurrentThread()) { 192 if (main_runner_->BelongsToCurrentThread()) {
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 513
509 void GpuService::Stop(const StopCallback& callback) { 514 void GpuService::Stop(const StopCallback& callback) {
510 DCHECK(io_runner_->BelongsToCurrentThread()); 515 DCHECK(io_runner_->BelongsToCurrentThread());
511 main_runner_->PostTaskAndReply(FROM_HERE, base::Bind([] { 516 main_runner_->PostTaskAndReply(FROM_HERE, base::Bind([] {
512 base::MessageLoop::current()->QuitWhenIdle(); 517 base::MessageLoop::current()->QuitWhenIdle();
513 }), 518 }),
514 callback); 519 callback);
515 } 520 }
516 521
517 } // namespace ui 522 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698