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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 // We don't need to reschedule the poll otherwise, because in | 251 // We don't need to reschedule the poll otherwise, because in |
252 // the worst case we would just poll one extra time. | 252 // the worst case we would just poll one extra time. |
253 if (alarms_.empty()) { | 253 if (alarms_.empty()) { |
254 timer_.Stop(); | 254 timer_.Stop(); |
255 next_poll_time_ = base::Time(); | 255 next_poll_time_ = base::Time(); |
256 } | 256 } |
257 } | 257 } |
258 | 258 |
259 void AlarmManager::OnAlarm(AlarmIterator it) { | 259 void AlarmManager::OnAlarm(AlarmIterator it) { |
260 CHECK(it.first != alarms_.end()); | 260 CHECK(it.first != alarms_.end()); |
261 Alarm& alarm = *it.second->get(); | 261 Alarm& alarm = **it.second; |
262 std::string extension_id_copy(it.first->first); | 262 std::string extension_id_copy(it.first->first); |
263 delegate_->OnAlarm(extension_id_copy, alarm); | 263 delegate_->OnAlarm(extension_id_copy, alarm); |
264 | 264 |
265 // Update our scheduled time for the next alarm. | 265 // Update our scheduled time for the next alarm. |
266 if (double* period_in_minutes = alarm.js_alarm->period_in_minutes.get()) { | 266 if (double* period_in_minutes = alarm.js_alarm->period_in_minutes.get()) { |
267 // Get the timer's delay in JS time (i.e., convert it from minutes to | 267 // Get the timer's delay in JS time (i.e., convert it from minutes to |
268 // milliseconds). | 268 // milliseconds). |
269 double period_in_js_time = *period_in_minutes * | 269 double period_in_js_time = *period_in_minutes * |
270 base::Time::kMicrosecondsPerMinute / | 270 base::Time::kMicrosecondsPerMinute / |
271 base::Time::kMicrosecondsPerMillisecond; | 271 base::Time::kMicrosecondsPerMillisecond; |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 if (create_info.period_in_minutes.get()) { | 479 if (create_info.period_in_minutes.get()) { |
480 js_alarm->period_in_minutes.reset( | 480 js_alarm->period_in_minutes.reset( |
481 new double(*create_info.period_in_minutes)); | 481 new double(*create_info.period_in_minutes)); |
482 } | 482 } |
483 } | 483 } |
484 | 484 |
485 Alarm::~Alarm() { | 485 Alarm::~Alarm() { |
486 } | 486 } |
487 | 487 |
488 } // namespace extensions | 488 } // namespace extensions |
OLD | NEW |