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

Side by Side Diff: content/gpu/gpu_watchdog_thread.cc

Issue 1207823004: PlatformThreadHandle: remove public id() interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: the last two nits Created 5 years, 5 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 | « content/browser/power_save_blocker_mac.cc ('k') | gpu/command_buffer/service/gpu_tracer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #if defined(OS_WIN) 5 #if defined(OS_WIN)
6 #include <windows.h> 6 #include <windows.h>
7 #endif 7 #endif
8 8
9 #include "content/gpu/gpu_watchdog_thread.h" 9 #include "content/gpu/gpu_watchdog_thread.h"
10 10
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 135
136 #if defined(USE_X11) 136 #if defined(USE_X11)
137 XDestroyWindow(display_, window_); 137 XDestroyWindow(display_, window_);
138 XCloseDisplay(display_); 138 XCloseDisplay(display_);
139 #endif 139 #endif
140 140
141 watched_message_loop_->RemoveTaskObserver(&task_observer_); 141 watched_message_loop_->RemoveTaskObserver(&task_observer_);
142 } 142 }
143 143
144 void GpuWatchdogThread::OnAcknowledge() { 144 void GpuWatchdogThread::OnAcknowledge() {
145 CHECK(base::PlatformThread::CurrentId() == thread_id()); 145 CHECK(base::PlatformThread::CurrentId() == GetThreadId());
146 146
147 // The check has already been acknowledged and another has already been 147 // The check has already been acknowledged and another has already been
148 // scheduled by a previous call to OnAcknowledge. It is normal for a 148 // scheduled by a previous call to OnAcknowledge. It is normal for a
149 // watched thread to see armed_ being true multiple times before 149 // watched thread to see armed_ being true multiple times before
150 // the OnAcknowledge task is run on the watchdog thread. 150 // the OnAcknowledge task is run on the watchdog thread.
151 if (!armed_) 151 if (!armed_)
152 return; 152 return;
153 153
154 // Revoke any pending hang termination. 154 // Revoke any pending hang termination.
155 weak_factory_.InvalidateWeakPtrs(); 155 weak_factory_.InvalidateWeakPtrs();
156 armed_ = false; 156 armed_ = false;
157 157
158 if (suspended_) 158 if (suspended_)
159 return; 159 return;
160 160
161 // If it took a long time for the acknowledgement, assume the computer was 161 // If it took a long time for the acknowledgement, assume the computer was
162 // recently suspended. 162 // recently suspended.
163 bool was_suspended = (base::Time::Now() > suspension_timeout_); 163 bool was_suspended = (base::Time::Now() > suspension_timeout_);
164 164
165 // The monitored thread has responded. Post a task to check it again. 165 // The monitored thread has responded. Post a task to check it again.
166 task_runner()->PostDelayedTask( 166 task_runner()->PostDelayedTask(
167 FROM_HERE, base::Bind(&GpuWatchdogThread::OnCheck, 167 FROM_HERE, base::Bind(&GpuWatchdogThread::OnCheck,
168 weak_factory_.GetWeakPtr(), was_suspended), 168 weak_factory_.GetWeakPtr(), was_suspended),
169 0.5 * timeout_); 169 0.5 * timeout_);
170 } 170 }
171 171
172 void GpuWatchdogThread::OnCheck(bool after_suspend) { 172 void GpuWatchdogThread::OnCheck(bool after_suspend) {
173 CHECK(base::PlatformThread::CurrentId() == thread_id()); 173 CHECK(base::PlatformThread::CurrentId() == GetThreadId());
174 174
175 // Do not create any new termination tasks if one has already been created 175 // Do not create any new termination tasks if one has already been created
176 // or the system is suspended. 176 // or the system is suspended.
177 if (armed_ || suspended_) 177 if (armed_ || suspended_)
178 return; 178 return;
179 179
180 // Must set armed before posting the task. This task might be the only task 180 // Must set armed before posting the task. This task might be the only task
181 // that will activate the TaskObserver on the watched thread and it must not 181 // that will activate the TaskObserver on the watched thread and it must not
182 // miss the false -> true transition. 182 // miss the false -> true transition.
183 armed_ = true; 183 armed_ = true;
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 // not increasing. The other is where either the kernel hangs and never 393 // not increasing. The other is where either the kernel hangs and never
394 // returns to user level or where user level code 394 // returns to user level or where user level code
395 // calls into kernel level repeatedly, giving up its quanta before it is 395 // calls into kernel level repeatedly, giving up its quanta before it is
396 // tracked, for example a loop that repeatedly Sleeps. 396 // tracked, for example a loop that repeatedly Sleeps.
397 return base::TimeDelta::FromMilliseconds(static_cast<int64>( 397 return base::TimeDelta::FromMilliseconds(static_cast<int64>(
398 (user_time64.QuadPart + kernel_time64.QuadPart) / 10000)); 398 (user_time64.QuadPart + kernel_time64.QuadPart) / 10000));
399 } 399 }
400 #endif 400 #endif
401 401
402 } // namespace content 402 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/power_save_blocker_mac.cc ('k') | gpu/command_buffer/service/gpu_tracer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698