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

Side by Side Diff: ui/ozone/platform/drm/host/drm_display_host_manager.cc

Issue 2603153003: Use TaskScheduler instead of WorkerPool in drm_display_host_manager.cc. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ui/ozone/platform/drm/host/drm_display_host_manager.h" 5 #include "ui/ozone/platform/drm/host/drm_display_host_manager.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <xf86drm.h> 9 #include <xf86drm.h>
10 10
11 #include <utility> 11 #include <utility>
12 12
13 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
14 #include "base/files/file_util.h" 14 #include "base/files/file_util.h"
15 #include "base/memory/ptr_util.h" 15 #include "base/memory/ptr_util.h"
16 #include "base/strings/stringprintf.h" 16 #include "base/strings/stringprintf.h"
17 #include "base/task_scheduler/post_task.h"
17 #include "base/threading/thread_restrictions.h" 18 #include "base/threading/thread_restrictions.h"
18 #include "base/threading/thread_task_runner_handle.h" 19 #include "base/threading/thread_task_runner_handle.h"
19 #include "base/threading/worker_pool.h"
20 #include "ui/display/types/display_snapshot.h" 20 #include "ui/display/types/display_snapshot.h"
21 #include "ui/events/ozone/device/device_event.h" 21 #include "ui/events/ozone/device/device_event.h"
22 #include "ui/events/ozone/device/device_manager.h" 22 #include "ui/events/ozone/device/device_manager.h"
23 #include "ui/ozone/platform/drm/common/drm_util.h" 23 #include "ui/ozone/platform/drm/common/drm_util.h"
24 #include "ui/ozone/platform/drm/host/drm_device_handle.h" 24 #include "ui/ozone/platform/drm/host/drm_device_handle.h"
25 #include "ui/ozone/platform/drm/host/drm_display_host.h" 25 #include "ui/ozone/platform/drm/host/drm_display_host.h"
26 #include "ui/ozone/platform/drm/host/drm_native_display_delegate.h" 26 #include "ui/ozone/platform/drm/host/drm_native_display_delegate.h"
27 #include "ui/ozone/platform/drm/host/gpu_thread_adapter.h" 27 #include "ui/ozone/platform/drm/host/gpu_thread_adapter.h"
28 28
29 namespace ui { 29 namespace ui {
(...skipping 15 matching lines...) Expand all
45 base::FilePath MapDevPathToSysPath(const base::FilePath& device_path) { 45 base::FilePath MapDevPathToSysPath(const base::FilePath& device_path) {
46 // |device_path| looks something like /dev/dri/card0. We take the basename of 46 // |device_path| looks something like /dev/dri/card0. We take the basename of
47 // that (card0) and append it to /sys/class/drm. /sys/class/drm/card0 is a 47 // that (card0) and append it to /sys/class/drm. /sys/class/drm/card0 is a
48 // symlink that points to something like 48 // symlink that points to something like
49 // /sys/devices/pci0000:00/0000:00:02.0/0000:05:00.0/drm/card0, which exposes 49 // /sys/devices/pci0000:00/0000:00:02.0/0000:05:00.0/drm/card0, which exposes
50 // some metadata about the attached device. 50 // some metadata about the attached device.
51 return base::MakeAbsoluteFilePath( 51 return base::MakeAbsoluteFilePath(
52 base::FilePath("/sys/class/drm").Append(device_path.BaseName())); 52 base::FilePath("/sys/class/drm").Append(device_path.BaseName()));
53 } 53 }
54 54
55 void OpenDeviceOnWorkerThread( 55 void OpenDeviceAsync(const base::FilePath& device_path,
56 const base::FilePath& device_path, 56 const scoped_refptr<base::TaskRunner>& reply_runner,
57 const scoped_refptr<base::TaskRunner>& reply_runner, 57 const OnOpenDeviceReplyCallback& callback) {
58 const OnOpenDeviceReplyCallback& callback) {
59 base::FilePath sys_path = MapDevPathToSysPath(device_path); 58 base::FilePath sys_path = MapDevPathToSysPath(device_path);
60 59
61 std::unique_ptr<DrmDeviceHandle> handle(new DrmDeviceHandle()); 60 std::unique_ptr<DrmDeviceHandle> handle(new DrmDeviceHandle());
62 handle->Initialize(device_path, sys_path); 61 handle->Initialize(device_path, sys_path);
63 reply_runner->PostTask(FROM_HERE, 62 reply_runner->PostTask(FROM_HERE,
64 base::Bind(callback, device_path, sys_path, 63 base::Bind(callback, device_path, sys_path,
65 base::Passed(std::move(handle)))); 64 base::Passed(std::move(handle))));
66 } 65 }
67 66
68 base::FilePath GetPrimaryDisplayCardPath() { 67 base::FilePath GetPrimaryDisplayCardPath() {
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 237
239 void DrmDisplayHostManager::ProcessEvent() { 238 void DrmDisplayHostManager::ProcessEvent() {
240 while (!event_queue_.empty() && !task_pending_) { 239 while (!event_queue_.empty() && !task_pending_) {
241 DisplayEvent event = event_queue_.front(); 240 DisplayEvent event = event_queue_.front();
242 event_queue_.pop(); 241 event_queue_.pop();
243 VLOG(1) << "Got display event " << kDisplayActionString[event.action_type] 242 VLOG(1) << "Got display event " << kDisplayActionString[event.action_type]
244 << " for " << event.path.value(); 243 << " for " << event.path.value();
245 switch (event.action_type) { 244 switch (event.action_type) {
246 case DeviceEvent::ADD: 245 case DeviceEvent::ADD:
247 if (drm_devices_.find(event.path) == drm_devices_.end()) { 246 if (drm_devices_.find(event.path) == drm_devices_.end()) {
248 task_pending_ = base::WorkerPool::PostTask( 247 base::PostTaskWithTraits(
249 FROM_HERE, 248 FROM_HERE,
250 base::Bind(&OpenDeviceOnWorkerThread, event.path, 249 base::TaskTraits()
250 .WithShutdownBehavior(
251 base::TaskShutdownBehavior::CONTINUE_ON_SHUTDOWN)
252 .MayBlock(),
253 base::Bind(&OpenDeviceAsync, event.path,
251 base::ThreadTaskRunnerHandle::Get(), 254 base::ThreadTaskRunnerHandle::Get(),
252 base::Bind(&DrmDisplayHostManager::OnAddGraphicsDevice, 255 base::Bind(&DrmDisplayHostManager::OnAddGraphicsDevice,
253 weak_ptr_factory_.GetWeakPtr())), 256 weak_ptr_factory_.GetWeakPtr())));
254 false /* task_is_slow */); 257 task_pending_ = true;
255 } 258 }
256 break; 259 break;
257 case DeviceEvent::CHANGE: 260 case DeviceEvent::CHANGE:
258 task_pending_ = base::ThreadTaskRunnerHandle::Get()->PostTask( 261 task_pending_ = base::ThreadTaskRunnerHandle::Get()->PostTask(
259 FROM_HERE, 262 FROM_HERE,
260 base::Bind(&DrmDisplayHostManager::OnUpdateGraphicsDevice, 263 base::Bind(&DrmDisplayHostManager::OnUpdateGraphicsDevice,
261 weak_ptr_factory_.GetWeakPtr())); 264 weak_ptr_factory_.GetWeakPtr()));
262 break; 265 break;
263 case DeviceEvent::REMOVE: 266 case DeviceEvent::REMOVE:
264 DCHECK(event.path != primary_graphics_card_path_) 267 DCHECK(event.path != primary_graphics_card_path_)
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 464
462 callback.Run(snapshots); 465 callback.Run(snapshots);
463 } 466 }
464 467
465 void DrmDisplayHostManager::NotifyDisplayDelegate() const { 468 void DrmDisplayHostManager::NotifyDisplayDelegate() const {
466 if (delegate_) 469 if (delegate_)
467 delegate_->OnConfigurationChanged(); 470 delegate_->OnConfigurationChanged();
468 } 471 }
469 472
470 } // namespace ui 473 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698