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

Side by Side Diff: base/message_loop.cc

Issue 3948001: Revert 63176 - Fix regression where high resolution timers could be activated... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « app/hi_res_timer_manager_win.cc ('k') | base/time.h » ('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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "base/message_loop.h" 5 #include "base/message_loop.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 ReloadWorkQueue(); 172 ReloadWorkQueue();
173 // If we end up with empty queues, then break out of the loop. 173 // If we end up with empty queues, then break out of the loop.
174 did_work = DeletePendingTasks(); 174 did_work = DeletePendingTasks();
175 if (!did_work) 175 if (!did_work)
176 break; 176 break;
177 } 177 }
178 DCHECK(!did_work); 178 DCHECK(!did_work);
179 179
180 // OK, now make it so that no one can find us. 180 // OK, now make it so that no one can find us.
181 lazy_tls_ptr.Pointer()->Set(NULL); 181 lazy_tls_ptr.Pointer()->Set(NULL);
182
183 #if defined(OS_WIN)
184 // If we left the high-resolution timer activated, deactivate it now.
185 // Doing this is not-critical, it is mainly to make sure we track
186 // the high resolution timer activations properly in our unit tests.
187 if (!high_resolution_timer_expiration_.is_null()) {
188 Time::ActivateHighResolutionTimer(false);
189 high_resolution_timer_expiration_ = base::TimeTicks();
190 }
191 #endif
192 } 182 }
193 183
194 void MessageLoop::AddDestructionObserver( 184 void MessageLoop::AddDestructionObserver(
195 DestructionObserver* destruction_observer) { 185 DestructionObserver* destruction_observer) {
196 DCHECK(this == current()); 186 DCHECK(this == current());
197 destruction_observers_.AddObserver(destruction_observer); 187 destruction_observers_.AddObserver(destruction_observer);
198 } 188 }
199 189
200 void MessageLoop::RemoveDestructionObserver( 190 void MessageLoop::RemoveDestructionObserver(
201 DestructionObserver* destruction_observer) { 191 DestructionObserver* destruction_observer) {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 #if defined(OS_WIN) 330 #if defined(OS_WIN)
341 if (high_resolution_timer_expiration_.is_null()) { 331 if (high_resolution_timer_expiration_.is_null()) {
342 // Windows timers are granular to 15.6ms. If we only set high-res 332 // Windows timers are granular to 15.6ms. If we only set high-res
343 // timers for those under 15.6ms, then a 18ms timer ticks at ~32ms, 333 // timers for those under 15.6ms, then a 18ms timer ticks at ~32ms,
344 // which as a percentage is pretty inaccurate. So enable high 334 // which as a percentage is pretty inaccurate. So enable high
345 // res timers for any timer which is within 2x of the granularity. 335 // res timers for any timer which is within 2x of the granularity.
346 // This is a tradeoff between accuracy and power management. 336 // This is a tradeoff between accuracy and power management.
347 bool needs_high_res_timers = 337 bool needs_high_res_timers =
348 delay_ms < (2 * Time::kMinLowResolutionThresholdMs); 338 delay_ms < (2 * Time::kMinLowResolutionThresholdMs);
349 if (needs_high_res_timers) { 339 if (needs_high_res_timers) {
350 if (Time::ActivateHighResolutionTimer(true)) { 340 Time::ActivateHighResolutionTimer(true);
351 high_resolution_timer_expiration_ = base::TimeTicks::Now() + 341 high_resolution_timer_expiration_ = base::TimeTicks::Now() +
352 TimeDelta::FromMilliseconds(kHighResolutionTimerModeLeaseTimeMs); 342 TimeDelta::FromMilliseconds(kHighResolutionTimerModeLeaseTimeMs);
353 }
354 } 343 }
355 } 344 }
356 #endif 345 #endif
357 } else { 346 } else {
358 DCHECK_EQ(delay_ms, 0) << "delay should not be negative"; 347 DCHECK_EQ(delay_ms, 0) << "delay should not be negative";
359 } 348 }
360 349
361 #if defined(OS_WIN) 350 #if defined(OS_WIN)
362 if (!high_resolution_timer_expiration_.is_null()) { 351 if (!high_resolution_timer_expiration_.is_null()) {
363 if (base::TimeTicks::Now() > high_resolution_timer_expiration_) { 352 if (base::TimeTicks::Now() > high_resolution_timer_expiration_) {
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 Watcher *delegate) { 680 Watcher *delegate) {
692 return pump_libevent()->WatchFileDescriptor( 681 return pump_libevent()->WatchFileDescriptor(
693 fd, 682 fd,
694 persistent, 683 persistent,
695 static_cast<base::MessagePumpLibevent::Mode>(mode), 684 static_cast<base::MessagePumpLibevent::Mode>(mode),
696 controller, 685 controller,
697 delegate); 686 delegate);
698 } 687 }
699 688
700 #endif 689 #endif
OLDNEW
« no previous file with comments | « app/hi_res_timer_manager_win.cc ('k') | base/time.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698