| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "extensions/browser/api/alarms/alarm_manager.h" | 5 #include "extensions/browser/api/alarms/alarm_manager.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 | 457 |
| 458 if (create_info.when.get()) { | 458 if (create_info.when.get()) { |
| 459 // Absolute scheduling. | 459 // Absolute scheduling. |
| 460 js_alarm->scheduled_time = *create_info.when; | 460 js_alarm->scheduled_time = *create_info.when; |
| 461 granularity = base::Time::FromJsTime(js_alarm->scheduled_time) - now; | 461 granularity = base::Time::FromJsTime(js_alarm->scheduled_time) - now; |
| 462 } else { | 462 } else { |
| 463 // Relative scheduling. | 463 // Relative scheduling. |
| 464 double* delay_in_minutes = create_info.delay_in_minutes.get(); | 464 double* delay_in_minutes = create_info.delay_in_minutes.get(); |
| 465 if (delay_in_minutes == NULL) | 465 if (delay_in_minutes == NULL) |
| 466 delay_in_minutes = create_info.period_in_minutes.get(); | 466 delay_in_minutes = create_info.period_in_minutes.get(); |
| 467 CHECK(delay_in_minutes != NULL) | 467 // ValidateAlarmCreateInfo in alarms_api.cc should have prevented this call. |
| 468 << "ValidateAlarmCreateInfo in alarms_api.cc should have " | 468 CHECK(delay_in_minutes != NULL); |
| 469 << "prevented this call."; | |
| 470 base::TimeDelta delay = TimeDeltaFromDelay(*delay_in_minutes); | 469 base::TimeDelta delay = TimeDeltaFromDelay(*delay_in_minutes); |
| 471 js_alarm->scheduled_time = (now + delay).ToJsTime(); | 470 js_alarm->scheduled_time = (now + delay).ToJsTime(); |
| 472 granularity = delay; | 471 granularity = delay; |
| 473 } | 472 } |
| 474 | 473 |
| 475 if (granularity < min_granularity) | 474 if (granularity < min_granularity) |
| 476 granularity = min_granularity; | 475 granularity = min_granularity; |
| 477 | 476 |
| 478 // Check for repetition. | 477 // Check for repetition. |
| 479 if (create_info.period_in_minutes.get()) { | 478 if (create_info.period_in_minutes.get()) { |
| 480 js_alarm->period_in_minutes.reset( | 479 js_alarm->period_in_minutes.reset( |
| 481 new double(*create_info.period_in_minutes)); | 480 new double(*create_info.period_in_minutes)); |
| 482 } | 481 } |
| 483 } | 482 } |
| 484 | 483 |
| 485 Alarm::~Alarm() { | 484 Alarm::~Alarm() { |
| 486 } | 485 } |
| 487 | 486 |
| 488 } // namespace extensions | 487 } // namespace extensions |
| OLD | NEW |