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

Unified Diff: base/message_loop/message_pump_mac.h

Issue 2709813003: [Mac] Reduce timer CPU use in MessagePumpCFRunLoopBase. (Closed)
Patch Set: Fix iOS compile problems. Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/BUILD.gn ('k') | base/message_loop/message_pump_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_loop/message_pump_mac.h
diff --git a/base/message_loop/message_pump_mac.h b/base/message_loop/message_pump_mac.h
index 14b8377b9086b922eacd82765e54d68ae2ef74fa..f0766eb860e592d5cab96c93db7ae57d36ce00bc 100644
--- a/base/message_loop/message_pump_mac.h
+++ b/base/message_loop/message_pump_mac.h
@@ -78,9 +78,11 @@ class AutoreleasePoolType;
typedef NSAutoreleasePool AutoreleasePoolType;
#endif // !defined(__OBJC__) || __has_feature(objc_arc)
-class MessagePumpCFRunLoopBase : public MessagePump {
+class BASE_EXPORT MessagePumpCFRunLoopBase : public MessagePump {
// Needs access to CreateAutoreleasePool.
friend class MessagePumpScopedAutoreleasePool;
+ friend class TestMessagePumpCFRunLoopBase;
+
public:
MessagePumpCFRunLoopBase();
~MessagePumpCFRunLoopBase() override;
@@ -113,6 +115,21 @@ class MessagePumpCFRunLoopBase : public MessagePump {
virtual AutoreleasePoolType* CreateAutoreleasePool();
private:
+ // Marking timers as invalid at the right time helps significantly reduce
+ // power use (see the comment in RunDelayedWorkTimer()), however there is no
+ // public API for doing so. CFRuntime.h states that CFRuntimeBase, upon which
+ // the above timer invalidation functions are based, can change from release
+ // to release and should not be accessed directly (this struct last changed at
+ // least in 2008 in CF-476).
+ //
+ // This function uses private API to modify a test timer's valid state and
+ // uses public API to confirm that the private API changed the right bit.
+ static bool CanInvalidateCFRunLoopTimers();
+
+ // Sets a Core Foundation object's "invalid" bit to |valid|. Based on code
+ // from CFRunLoop.c.
+ static void ChromeCFRunLoopTimerSetValid(CFRunLoopTimerRef timer, bool valid);
+
// Timer callback scheduled by ScheduleDelayedWork. This does not do any
// work, but it signals work_source_ so that delayed work can be performed
// within the appropriate priority constraints.
« no previous file with comments | « base/BUILD.gn ('k') | base/message_loop/message_pump_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698