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

Side by Side Diff: ui/ozone/platform/drm/gpu/drm_device.cc

Issue 1006403002: [Ozone-Drm] Do not try to take ref_ptr from destructor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Wait Created 5 years, 9 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/gpu/drm_device.h" 5 #include "ui/ozone/platform/drm/gpu/drm_device.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <sys/mman.h> 8 #include <sys/mman.h>
9 #include <unistd.h> 9 #include <unistd.h>
10 #include <xf86drm.h> 10 #include <xf86drm.h>
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 : io_task_runner_(io_task_runner), paused_(true), fd_(fd) {} 107 : io_task_runner_(io_task_runner), paused_(true), fd_(fd) {}
108 108
109 void SetPaused(bool paused) { 109 void SetPaused(bool paused) {
110 if (paused_ == paused) 110 if (paused_ == paused)
111 return; 111 return;
112 112
113 paused_ = paused; 113 paused_ = paused;
114 base::WaitableEvent done(false, false); 114 base::WaitableEvent done(false, false);
115 io_task_runner_->PostTask( 115 io_task_runner_->PostTask(
116 FROM_HERE, base::Bind(&IOWatcher::SetPausedOnIO, this, &done)); 116 FROM_HERE, base::Bind(&IOWatcher::SetPausedOnIO, this, &done));
117 done.Wait();
117 } 118 }
118 119
119 void Shutdown() { 120 void Shutdown() {
120 if (!paused_) 121 if (!paused_)
121 io_task_runner_->PostTask(FROM_HERE, 122 io_task_runner_->PostTask(FROM_HERE,
122 base::Bind(&IOWatcher::UnregisterOnIO, this)); 123 base::Bind(&IOWatcher::UnregisterOnIO, this));
123 } 124 }
124 125
125 private: 126 private:
126 friend class base::RefCountedThreadSafe<IOWatcher>; 127 friend class base::RefCountedThreadSafe<IOWatcher>;
127 128
128 ~IOWatcher() override { SetPaused(true); } 129 ~IOWatcher() override {}
129 130
130 void RegisterOnIO() { 131 void RegisterOnIO() {
131 DCHECK(base::MessageLoopForIO::IsCurrent()); 132 DCHECK(base::MessageLoopForIO::IsCurrent());
132 base::MessageLoopForIO::current()->WatchFileDescriptor( 133 base::MessageLoopForIO::current()->WatchFileDescriptor(
133 fd_, true, base::MessageLoopForIO::WATCH_READ, &controller_, this); 134 fd_, true, base::MessageLoopForIO::WATCH_READ, &controller_, this);
134 } 135 }
135 136
136 void UnregisterOnIO() { 137 void UnregisterOnIO() {
137 DCHECK(base::MessageLoopForIO::IsCurrent()); 138 DCHECK(base::MessageLoopForIO::IsCurrent());
138 controller_.StopWatchingFileDescriptor(); 139 controller_.StopWatchingFileDescriptor();
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 DCHECK(file_.IsValid()); 444 DCHECK(file_.IsValid());
444 return (drmSetMaster(file_.GetPlatformFile()) == 0); 445 return (drmSetMaster(file_.GetPlatformFile()) == 0);
445 } 446 }
446 447
447 bool DrmDevice::DropMaster() { 448 bool DrmDevice::DropMaster() {
448 DCHECK(file_.IsValid()); 449 DCHECK(file_.IsValid());
449 return (drmDropMaster(file_.GetPlatformFile()) == 0); 450 return (drmDropMaster(file_.GetPlatformFile()) == 0);
450 } 451 }
451 452
452 } // namespace ui 453 } // 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