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

Unified Diff: base/message_loop/message_pump_mac.mm

Issue 2470403002: Inline CFRunLoopTimerSetTolerance() which is now available on all supported Mac versions (10.9+). (Closed)
Patch Set: Created 4 years, 1 month 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/message_loop/message_pump_mac.mm
diff --git a/base/message_loop/message_pump_mac.mm b/base/message_loop/message_pump_mac.mm
index b50ea6878813ba1f047cfc291e731c53f3d9fe90..d924ead7cbd9b934341ab6314d059fe769c172fa 100644
--- a/base/message_loop/message_pump_mac.mm
+++ b/base/message_loop/message_pump_mac.mm
@@ -4,7 +4,6 @@
#import "base/message_loop/message_pump_mac.h"
-#include <dlfcn.h>
#import <Foundation/Foundation.h>
#include <limits>
@@ -72,33 +71,6 @@ const CFTimeInterval kCFTimeIntervalMax =
bool g_not_using_cr_app = false;
#endif
-// Call through to CFRunLoopTimerSetTolerance(), which is only available on
-// OS X 10.9.
-void SetTimerTolerance(CFRunLoopTimerRef timer, CFTimeInterval tolerance) {
- typedef void (*CFRunLoopTimerSetTolerancePtr)(CFRunLoopTimerRef timer,
- CFTimeInterval tolerance);
-
- static CFRunLoopTimerSetTolerancePtr settimertolerance_function_ptr;
-
- static dispatch_once_t get_timer_tolerance_function_ptr_once;
- dispatch_once(&get_timer_tolerance_function_ptr_once, ^{
- NSBundle* bundle =[NSBundle
- bundleWithPath:@"/System/Library/Frameworks/CoreFoundation.framework"];
- const char* path = [[bundle executablePath] fileSystemRepresentation];
- CHECK(path);
- void* library_handle = dlopen(path, RTLD_LAZY | RTLD_LOCAL);
- CHECK(library_handle) << dlerror();
- settimertolerance_function_ptr =
- reinterpret_cast<CFRunLoopTimerSetTolerancePtr>(
- dlsym(library_handle, "CFRunLoopTimerSetTolerance"));
-
- dlclose(library_handle);
- });
-
- if (settimertolerance_function_ptr)
- settimertolerance_function_ptr(timer, tolerance);
-}
-
} // namespace
// static
@@ -273,9 +245,9 @@ void MessagePumpCFRunLoopBase::ScheduleDelayedWork(
delayed_work_fire_time_ = CFAbsoluteTimeGetCurrent() + delta.InSecondsF();
CFRunLoopTimerSetNextFireDate(delayed_work_timer_, delayed_work_fire_time_);
if (timer_slack_ == TIMER_SLACK_MAXIMUM) {
- SetTimerTolerance(delayed_work_timer_, delta.InSecondsF() * 0.5);
+ CFRunLoopTimerSetTolerance(delayed_work_timer_, delta.InSecondsF() * 0.5);
} else {
- SetTimerTolerance(delayed_work_timer_, 0);
+ CFRunLoopTimerSetTolerance(delayed_work_timer_, 0);
}
}
« 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