summaryrefslogtreecommitdiffstats
path: root/base
diff options
context:
space:
mode:
authormark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-14 16:04:05 +0000
committermark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-14 16:04:05 +0000
commit055cceb1b4ca2b25b94b7e5e6d71c4d86d904e36 (patch)
treed9979fbde7626dcb8365b69933ea2037ad06f064 /base
parent394dc47a52388ab922ff23bf422948a7e1c3274c (diff)
downloadchromium_src-055cceb1b4ca2b25b94b7e5e6d71c4d86d904e36.zip
chromium_src-055cceb1b4ca2b25b94b7e5e6d71c4d86d904e36.tar.gz
chromium_src-055cceb1b4ca2b25b94b7e5e6d71c4d86d904e36.tar.bz2
Remove code rendered pointless by r65322.
Since r65322 MessagePump::ScheduleDelayedWork, which is the underlying implementation for PostDelayedTask, operates on TimeTicks instead of Time units. The TimeTicks timebase is stopped during system sleep. Consequently, since that revision, any work that is scheduled through this interface is now expected to be dispatched after a period of TimeTicks, meaning that it will be further delayed by system sleep. MessagePumpCFRunLoopBase::PowerStateNotification had been used to force an attempt to process queued delayed work upon system wakeup. This had the result of dispatching any work whose expected fire time had occurred while the system was asleep, if any, and of resetting the CFRunLoopTimer properly following a change in the offset between the two timebases. Since r65322, there is only a single timebase and no offset, so PowerStateNotification's dispatch attempt was pointless and would never result in delayed work being dispatched or the CFRunLoopTimer being reset to fire at a time other than what it had already been to fire at. IORegisterForSystemPower may be blocked by the sandbox in some processes on some OS releases, and its use in such circumstances might result in messages about its failure being logged. Since this code no longer has any effect, it can be dropped without perceptible impact, and these alleged log messages will allegedly disappear. BUG=74055 TEST=FutureCat Console.app Also run the tests from http://codereview.chromium.org/342011. The behavior post-r65322 may have changed from the expectations listed in that change, but the behavior should not change at all between the post-r65322 code and this change. Review URL: http://codereview.chromium.org/6831009 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81597 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r--base/message_pump_mac.h14
-rw-r--r--base/message_pump_mac.mm92
2 files changed, 2 insertions, 104 deletions
diff --git a/base/message_pump_mac.h b/base/message_pump_mac.h
index b903a1a..08d6b83 100644
--- a/base/message_pump_mac.h
+++ b/base/message_pump_mac.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -34,7 +34,6 @@
#include "base/message_pump.h"
#include <CoreFoundation/CoreFoundation.h>
-#include <IOKit/IOKitLib.h>
#if !defined(__OBJC__)
class NSAutoreleasePool;
@@ -142,12 +141,6 @@ class MessagePumpCFRunLoopBase : public MessagePump {
// the basis of run loops starting and stopping.
virtual void EnterExitRunLoop(CFRunLoopActivity activity);
- // IOKit power state change notification callback, called when the system
- // enters and leaves the sleep state.
- static void PowerStateNotification(void* info, io_service_t service,
- uint32_t message_type,
- void* message_argument);
-
// The thread's run loop.
CFRunLoopRef run_loop_;
@@ -161,11 +154,6 @@ class MessagePumpCFRunLoopBase : public MessagePump {
CFRunLoopObserverRef pre_source_observer_;
CFRunLoopObserverRef enter_exit_observer_;
- // Objects used for power state notification. See PowerStateNotification.
- io_connect_t root_power_domain_;
- IONotificationPortRef power_notification_port_;
- io_object_t power_notification_object_;
-
// (weak) Delegate passed as an argument to the innermost Run call.
Delegate* delegate_;
diff --git a/base/message_pump_mac.mm b/base/message_pump_mac.mm
index 8feb56f..2a50b64 100644
--- a/base/message_pump_mac.mm
+++ b/base/message_pump_mac.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -6,8 +6,6 @@
#import <AppKit/AppKit.h>
#import <Foundation/Foundation.h>
-#include <IOKit/IOMessage.h>
-#include <IOKit/pwr_mgt/IOPMLib.h>
#include <limits>
@@ -116,33 +114,12 @@ MessagePumpCFRunLoopBase::MessagePumpCFRunLoopBase()
EnterExitObserver,
&observer_context);
CFRunLoopAddObserver(run_loop_, enter_exit_observer_, kCFRunLoopCommonModes);
-
- root_power_domain_ = IORegisterForSystemPower(this,
- &power_notification_port_,
- PowerStateNotification,
- &power_notification_object_);
- if (root_power_domain_ != MACH_PORT_NULL) {
- CFRunLoopAddSource(
- run_loop_,
- IONotificationPortGetRunLoopSource(power_notification_port_),
- kCFRunLoopCommonModes);
- }
}
// Ideally called on the run loop thread. If other run loops were running
// lower on the run loop thread's stack when this object was created, the
// same number of run loops must be running when this object is destroyed.
MessagePumpCFRunLoopBase::~MessagePumpCFRunLoopBase() {
- if (root_power_domain_ != MACH_PORT_NULL) {
- CFRunLoopRemoveSource(
- run_loop_,
- IONotificationPortGetRunLoopSource(power_notification_port_),
- kCFRunLoopCommonModes);
- IODeregisterForSystemPower(&power_notification_object_);
- IOServiceClose(root_power_domain_);
- IONotificationPortDestroy(power_notification_port_);
- }
-
CFRunLoopRemoveObserver(run_loop_, enter_exit_observer_,
kCFRunLoopCommonModes);
CFRelease(enter_exit_observer_);
@@ -465,73 +442,6 @@ void MessagePumpCFRunLoopBase::EnterExitObserver(CFRunLoopObserverRef observer,
self->EnterExitRunLoop(activity);
}
-// Called from the run loop.
-// static
-void MessagePumpCFRunLoopBase::PowerStateNotification(void* info,
- io_service_t service,
- uint32_t message_type,
- void* message_argument) {
- // CFRunLoopTimer (NSTimer) is scheduled in terms of CFAbsoluteTime, which
- // measures the number of seconds since 2001-01-01 00:00:00.0 Z. It is
- // implemented in terms of kernel ticks, as in mach_absolute_time. While an
- // offset and scale factor can be applied to convert between the two time
- // bases at any time after boot, the kernel clock stops while the system is
- // asleep, altering the offset. (The offset will also change when the
- // real-time clock is adjusted.) CFRunLoopTimers are not readjusted to take
- // this into account when the system wakes up, so any timers that were
- // pending while the system was asleep will be delayed by the sleep
- // duration.
- //
- // The MessagePump interface assumes that scheduled delayed work will be
- // performed at the time ScheduleDelayedWork was asked to perform it. The
- // delay caused by the CFRunLoopTimer not firing at the appropriate time
- // results in a stall of queued delayed work when the system wakes up.
- // With this limitation, scheduled work would not be performed until
- // (system wake time + scheduled work time - system sleep time), while it
- // would be expected to be performed at (scheduled work time).
- //
- // To work around this problem, when the system wakes up from sleep, if a
- // delayed work timer is pending, it is rescheduled to fire at the original
- // time that it was scheduled to fire.
- //
- // This mechanism is not resilient if the real-time clock does not maintain
- // stable time while the system is sleeping, but it matches the behavior of
- // the various other MessagePump implementations, and MessageLoop seems to
- // be limited in the same way.
- //
- // References
- // - Chris Kane, "NSTimer and deep sleep," cocoa-dev@lists.apple.com,
- // http://lists.apple.com/archives/Cocoa-dev/2002/May/msg01547.html
- // - Apple Technical Q&A QA1340, "Registering and unregistering for sleep
- // and wake notifications,"
- // http://developer.apple.com/mac/library/qa/qa2004/qa1340.html
- // - Core Foundation source code, CF-550/CFRunLoop.c and CF-550/CFDate.c,
- // http://www.opensource.apple.com/
-
- MessagePumpCFRunLoopBase* self = static_cast<MessagePumpCFRunLoopBase*>(info);
-
- switch (message_type) {
- case kIOMessageSystemWillPowerOn:
- if (self->delayed_work_fire_time_ != kCFTimeIntervalMax) {
- CFRunLoopTimerSetNextFireDate(self->delayed_work_timer_,
- self->delayed_work_fire_time_);
- }
- break;
-
- case kIOMessageSystemWillSleep:
- case kIOMessageCanSystemSleep:
- // The system will wait for 30 seconds before entering sleep if neither
- // IOAllowPowerChange nor IOCancelPowerChange are called. That would be
- // pretty antisocial.
- IOAllowPowerChange(self->root_power_domain_,
- reinterpret_cast<long>(message_argument));
- break;
-
- default:
- break;
- }
-}
-
// Called by MessagePumpCFRunLoopBase::EnterExitRunLoop. The default
// implementation is a no-op.
void MessagePumpCFRunLoopBase::EnterExitRunLoop(CFRunLoopActivity activity) {