OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <sys/timerfd.h> | 5 #include <sys/timerfd.h> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 | 405 |
406 namespace { | 406 namespace { |
407 void TimerRanCallback(bool* did_run) { | 407 void TimerRanCallback(bool* did_run) { |
408 *did_run = true; | 408 *did_run = true; |
409 | 409 |
410 base::MessageLoop::current()->PostTask( | 410 base::MessageLoop::current()->PostTask( |
411 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); | 411 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); |
412 } | 412 } |
413 | 413 |
414 bool IsAlarmTimerSupported() { | 414 bool IsAlarmTimerSupported() { |
| 415 #ifdef CLOCK_REALTIME_ALARM |
415 int fd = timerfd_create(CLOCK_REALTIME_ALARM, 0); | 416 int fd = timerfd_create(CLOCK_REALTIME_ALARM, 0); |
| 417 #else |
| 418 int fd = -1; |
| 419 #endif |
416 | 420 |
417 if (fd == -1) { | 421 if (fd == -1) { |
418 LOG(WARNING) << "CLOCK_REALTIME_ALARM is not supported on this system. " | 422 LOG(WARNING) << "CLOCK_REALTIME_ALARM is not supported on this system. " |
419 << "Skipping test. Upgrade to at least linux version 3.11 to " | 423 << "Skipping test. Upgrade to at least linux version 3.11 to " |
420 << "support this timer."; | 424 << "support this timer."; |
421 return false; | 425 return false; |
422 } | 426 } |
423 | 427 |
424 close(fd); | 428 close(fd); |
425 return true; | 429 return true; |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 if (!did_run) { | 507 if (!did_run) { |
504 base::RunLoop().Run(); | 508 base::RunLoop().Run(); |
505 EXPECT_TRUE(did_run); | 509 EXPECT_TRUE(did_run); |
506 } | 510 } |
507 } | 511 } |
508 } | 512 } |
509 | 513 |
510 } // namespace | 514 } // namespace |
511 | 515 |
512 } // namespace timers | 516 } // namespace timers |
OLD | NEW |