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

Side by Side Diff: chrome/browser/extensions/api/alarms/alarm_manager.cc

Issue 10837044: Correct const accessors in base/values.(h|cc), Part II (ListValue) (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: David's comments Created 8 years, 4 months 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 unified diff | Download patch
OLDNEW
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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 // Creates a TimeDelta from a delay as specified in the API. 53 // Creates a TimeDelta from a delay as specified in the API.
54 base::TimeDelta TimeDeltaFromDelay(double delay_in_minutes) { 54 base::TimeDelta TimeDeltaFromDelay(double delay_in_minutes) {
55 return base::TimeDelta::FromMicroseconds( 55 return base::TimeDelta::FromMicroseconds(
56 delay_in_minutes * base::Time::kMicrosecondsPerMinute); 56 delay_in_minutes * base::Time::kMicrosecondsPerMinute);
57 } 57 }
58 58
59 std::vector<Alarm> AlarmsFromValue(const base::ListValue* list) { 59 std::vector<Alarm> AlarmsFromValue(const base::ListValue* list) {
60 std::vector<Alarm> alarms; 60 std::vector<Alarm> alarms;
61 for (size_t i = 0; i < list->GetSize(); ++i) { 61 for (size_t i = 0; i < list->GetSize(); ++i) {
62 base::DictionaryValue* alarm_dict = NULL; 62 const base::DictionaryValue* alarm_dict = NULL;
63 Alarm alarm; 63 Alarm alarm;
64 if (list->GetDictionary(i, &alarm_dict) && 64 if (list->GetDictionary(i, &alarm_dict) &&
65 api::alarms::Alarm::Populate(*alarm_dict, alarm.js_alarm.get())) { 65 api::alarms::Alarm::Populate(*alarm_dict, alarm.js_alarm.get())) {
66 base::Value* time_value = NULL; 66 const base::Value* time_value = NULL;
67 if (alarm_dict->Get(kAlarmGranularity, &time_value)) 67 if (alarm_dict->Get(kAlarmGranularity, &time_value))
68 base::GetValueAsTimeDelta(*time_value, &alarm.granularity); 68 base::GetValueAsTimeDelta(*time_value, &alarm.granularity);
69 alarms.push_back(alarm); 69 alarms.push_back(alarm);
70 } 70 }
71 } 71 }
72 return alarms; 72 return alarms;
73 } 73 }
74 74
75 scoped_ptr<base::ListValue> AlarmsToValue( 75 scoped_ptr<base::ListValue> AlarmsToValue(
76 const std::vector<Alarm>& alarms) { 76 const std::vector<Alarm>& alarms) {
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 if (create_info.period_in_minutes.get()) { 379 if (create_info.period_in_minutes.get()) {
380 js_alarm->period_in_minutes.reset( 380 js_alarm->period_in_minutes.reset(
381 new double(*create_info.period_in_minutes)); 381 new double(*create_info.period_in_minutes));
382 } 382 }
383 } 383 }
384 384
385 Alarm::~Alarm() { 385 Alarm::~Alarm() {
386 } 386 }
387 387
388 } // namespace extensions 388 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698