OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "ppapi/cpp/extensions/dev/alarms_dev.h" | 5 #include "ppapi/cpp/extensions/dev/alarms_dev.h" |
6 | 6 |
7 #include "ppapi/cpp/completion_callback.h" | 7 #include "ppapi/cpp/completion_callback.h" |
8 #include "ppapi/cpp/dev/var_dictionary_dev.h" | |
9 #include "ppapi/cpp/extensions/optional.h" | 8 #include "ppapi/cpp/extensions/optional.h" |
10 #include "ppapi/cpp/extensions/to_var_converter.h" | 9 #include "ppapi/cpp/extensions/to_var_converter.h" |
11 #include "ppapi/cpp/logging.h" | 10 #include "ppapi/cpp/logging.h" |
12 #include "ppapi/cpp/module_impl.h" | 11 #include "ppapi/cpp/module_impl.h" |
| 12 #include "ppapi/cpp/var_dictionary.h" |
13 | 13 |
14 namespace pp { | 14 namespace pp { |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 template <> const char* interface_name<PPB_Ext_Alarms_Dev_0_1>() { | 18 template <> const char* interface_name<PPB_Ext_Alarms_Dev_0_1>() { |
19 return PPB_EXT_ALARMS_DEV_INTERFACE_0_1; | 19 return PPB_EXT_ALARMS_DEV_INTERFACE_0_1; |
20 } | 20 } |
21 | 21 |
22 } // namespace | 22 } // namespace |
(...skipping 11 matching lines...) Expand all Loading... |
34 period_in_minutes(kPeriodInMinutes) { | 34 period_in_minutes(kPeriodInMinutes) { |
35 } | 35 } |
36 | 36 |
37 Alarm_Dev::~Alarm_Dev() { | 37 Alarm_Dev::~Alarm_Dev() { |
38 } | 38 } |
39 | 39 |
40 bool Alarm_Dev::Populate(const PP_Ext_Alarms_Alarm_Dev& value) { | 40 bool Alarm_Dev::Populate(const PP_Ext_Alarms_Alarm_Dev& value) { |
41 if (value.type != PP_VARTYPE_DICTIONARY) | 41 if (value.type != PP_VARTYPE_DICTIONARY) |
42 return false; | 42 return false; |
43 | 43 |
44 VarDictionary_Dev dict(value); | 44 VarDictionary dict(value); |
45 bool result = name.Populate(dict); | 45 bool result = name.Populate(dict); |
46 result = scheduled_time.Populate(dict) && result; | 46 result = scheduled_time.Populate(dict) && result; |
47 result = period_in_minutes.Populate(dict) && result; | 47 result = period_in_minutes.Populate(dict) && result; |
48 | 48 |
49 return result; | 49 return result; |
50 } | 50 } |
51 | 51 |
52 Var Alarm_Dev::CreateVar() const { | 52 Var Alarm_Dev::CreateVar() const { |
53 VarDictionary_Dev dict; | 53 VarDictionary dict; |
54 | 54 |
55 bool result = name.AddTo(&dict); | 55 bool result = name.AddTo(&dict); |
56 result = scheduled_time.AddTo(&dict) && result; | 56 result = scheduled_time.AddTo(&dict) && result; |
57 result = period_in_minutes.MayAddTo(&dict) && result; | 57 result = period_in_minutes.MayAddTo(&dict) && result; |
58 PP_DCHECK(result); | 58 PP_DCHECK(result); |
59 | 59 |
60 return dict; | 60 return dict; |
61 } | 61 } |
62 | 62 |
63 const char* const AlarmCreateInfo_Dev::kWhen = "when"; | 63 const char* const AlarmCreateInfo_Dev::kWhen = "when"; |
64 const char* const AlarmCreateInfo_Dev::kDelayInMinutes = "delayInMinutes"; | 64 const char* const AlarmCreateInfo_Dev::kDelayInMinutes = "delayInMinutes"; |
65 const char* const AlarmCreateInfo_Dev::kPeriodInMinutes = "periodInMinutes"; | 65 const char* const AlarmCreateInfo_Dev::kPeriodInMinutes = "periodInMinutes"; |
66 | 66 |
67 AlarmCreateInfo_Dev::AlarmCreateInfo_Dev() | 67 AlarmCreateInfo_Dev::AlarmCreateInfo_Dev() |
68 : when(kWhen), | 68 : when(kWhen), |
69 delay_in_minutes(kDelayInMinutes), | 69 delay_in_minutes(kDelayInMinutes), |
70 period_in_minutes(kPeriodInMinutes) { | 70 period_in_minutes(kPeriodInMinutes) { |
71 } | 71 } |
72 | 72 |
73 AlarmCreateInfo_Dev::~AlarmCreateInfo_Dev() { | 73 AlarmCreateInfo_Dev::~AlarmCreateInfo_Dev() { |
74 } | 74 } |
75 | 75 |
76 bool AlarmCreateInfo_Dev::Populate( | 76 bool AlarmCreateInfo_Dev::Populate( |
77 const PP_Ext_Alarms_AlarmCreateInfo_Dev& value) { | 77 const PP_Ext_Alarms_AlarmCreateInfo_Dev& value) { |
78 if (value.type != PP_VARTYPE_DICTIONARY) | 78 if (value.type != PP_VARTYPE_DICTIONARY) |
79 return false; | 79 return false; |
80 | 80 |
81 VarDictionary_Dev dict(value); | 81 VarDictionary dict(value); |
82 bool result = when.Populate(dict); | 82 bool result = when.Populate(dict); |
83 result = delay_in_minutes.Populate(dict) && result; | 83 result = delay_in_minutes.Populate(dict) && result; |
84 result = period_in_minutes.Populate(dict) && result; | 84 result = period_in_minutes.Populate(dict) && result; |
85 | 85 |
86 return result; | 86 return result; |
87 } | 87 } |
88 | 88 |
89 Var AlarmCreateInfo_Dev::CreateVar() const { | 89 Var AlarmCreateInfo_Dev::CreateVar() const { |
90 VarDictionary_Dev dict; | 90 VarDictionary dict; |
91 | 91 |
92 bool result = when.MayAddTo(&dict); | 92 bool result = when.MayAddTo(&dict); |
93 result = delay_in_minutes.MayAddTo(&dict) && result; | 93 result = delay_in_minutes.MayAddTo(&dict) && result; |
94 result = period_in_minutes.MayAddTo(&dict) && result; | 94 result = period_in_minutes.MayAddTo(&dict) && result; |
95 PP_DCHECK(result); | 95 PP_DCHECK(result); |
96 | 96 |
97 return dict; | 97 return dict; |
98 } | 98 } |
99 | 99 |
100 Alarms_Dev::Alarms_Dev(const InstanceHandle& instance) : instance_(instance) { | 100 Alarms_Dev::Alarms_Dev(const InstanceHandle& instance) : instance_(instance) { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 OnAlarmEvent_Dev::~OnAlarmEvent_Dev() { | 170 OnAlarmEvent_Dev::~OnAlarmEvent_Dev() { |
171 } | 171 } |
172 | 172 |
173 void OnAlarmEvent_Dev::Callback(Alarm_Dev& alarm) { | 173 void OnAlarmEvent_Dev::Callback(Alarm_Dev& alarm) { |
174 listener_->OnAlarm(alarm); | 174 listener_->OnAlarm(alarm); |
175 } | 175 } |
176 | 176 |
177 } // namespace alarms | 177 } // namespace alarms |
178 } // namespace ext | 178 } // namespace ext |
179 } // namespace pp | 179 } // namespace pp |
OLD | NEW |