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 "chrome/browser/extensions/api/alarms/alarm_manager.h" | 5 #include "chrome/browser/extensions/api/alarms/alarm_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/time.h" | 10 #include "base/time.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 api::alarms::Alarm::Populate(*alarm_dict, alarm.js_alarm.get())) { | 63 api::alarms::Alarm::Populate(*alarm_dict, alarm.js_alarm.get())) { |
64 const base::Value* time_value = NULL; | 64 const base::Value* time_value = NULL; |
65 if (alarm_dict->Get(kAlarmGranularity, &time_value)) | 65 if (alarm_dict->Get(kAlarmGranularity, &time_value)) |
66 base::GetValueAsTimeDelta(*time_value, &alarm.granularity); | 66 base::GetValueAsTimeDelta(*time_value, &alarm.granularity); |
67 alarms.push_back(alarm); | 67 alarms.push_back(alarm); |
68 } | 68 } |
69 } | 69 } |
70 return alarms; | 70 return alarms; |
71 } | 71 } |
72 | 72 |
73 scoped_ptr<base::ListValue> AlarmsToValue( | 73 scoped_ptr<base::ListValue> AlarmsToValue(const std::vector<Alarm>& alarms) { |
74 const std::vector<Alarm>& alarms) { | |
75 scoped_ptr<base::ListValue> list(new ListValue()); | 74 scoped_ptr<base::ListValue> list(new ListValue()); |
76 for (size_t i = 0; i < alarms.size(); ++i) { | 75 for (size_t i = 0; i < alarms.size(); ++i) { |
77 scoped_ptr<base::DictionaryValue> alarm = | 76 scoped_ptr<base::DictionaryValue> alarm = |
78 alarms[i].js_alarm->ToValue().Pass(); | 77 alarms[i].js_alarm->ToValue().Pass(); |
79 alarm->Set(kAlarmGranularity, | 78 alarm->Set(kAlarmGranularity, |
80 base::CreateTimeDeltaValue(alarms[i].granularity)); | 79 base::CreateTimeDeltaValue(alarms[i].granularity)); |
81 list->Append(alarm.release()); | 80 list->Append(alarm.release()); |
82 } | 81 } |
83 return list.Pass(); | 82 return list.Pass(); |
84 } | 83 } |
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 if (create_info.period_in_minutes.get()) { | 376 if (create_info.period_in_minutes.get()) { |
378 js_alarm->period_in_minutes.reset( | 377 js_alarm->period_in_minutes.reset( |
379 new double(*create_info.period_in_minutes)); | 378 new double(*create_info.period_in_minutes)); |
380 } | 379 } |
381 } | 380 } |
382 | 381 |
383 Alarm::~Alarm() { | 382 Alarm::~Alarm() { |
384 } | 383 } |
385 | 384 |
386 } // namespace extensions | 385 } // namespace extensions |
OLD | NEW |