| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "ppapi/cpp/dev/alarms_dev.h" |
| 6 |
| 7 #include "ppapi/cpp/completion_callback.h" |
| 8 #include "ppapi/cpp/dev/array_dev.h" |
| 9 #include "ppapi/cpp/dev/to_c_type_converter_dev.h" |
| 10 #include "ppapi/cpp/module_impl.h" |
| 11 |
| 12 namespace pp { |
| 13 |
| 14 namespace { |
| 15 |
| 16 template <> const char* interface_name<PPB_Alarms_Dev_0_1>() { |
| 17 return PPB_ALARMS_DEV_INTERFACE_0_1; |
| 18 } |
| 19 |
| 20 } // namespace |
| 21 |
| 22 namespace alarms { |
| 23 |
| 24 Alarm_Dev::Alarm_Dev() |
| 25 : name_wrapper_(&storage_->name, NOT_OWNED), |
| 26 period_in_minutes_wrapper_(&storage_->period_in_minutes, NOT_OWNED) { |
| 27 } |
| 28 |
| 29 Alarm_Dev::Alarm_Dev(const Alarm_Dev& other) |
| 30 : name_wrapper_(&storage_->name, NOT_OWNED), |
| 31 period_in_minutes_wrapper_(&storage_->period_in_minutes, NOT_OWNED) { |
| 32 operator=(other); |
| 33 } |
| 34 |
| 35 Alarm_Dev::Alarm_Dev(const PP_Alarms_Alarm_Dev& other) |
| 36 : name_wrapper_(&storage_->name, NOT_OWNED), |
| 37 period_in_minutes_wrapper_(&storage_->period_in_minutes, NOT_OWNED) { |
| 38 operator=(other); |
| 39 } |
| 40 |
| 41 Alarm_Dev::Alarm_Dev(PP_Alarms_Alarm_Dev* storage, NotOwned) |
| 42 : StructWrapperBase(storage, NOT_OWNED), |
| 43 name_wrapper_(&storage_->name, NOT_OWNED), |
| 44 period_in_minutes_wrapper_(&storage_->period_in_minutes, NOT_OWNED) { |
| 45 } |
| 46 |
| 47 Alarm_Dev::~Alarm_Dev() { |
| 48 } |
| 49 |
| 50 Alarm_Dev& Alarm_Dev::operator=(const Alarm_Dev& other) { |
| 51 return operator=(*other.storage_); |
| 52 } |
| 53 |
| 54 Alarm_Dev& Alarm_Dev::operator=(const PP_Alarms_Alarm_Dev& other) { |
| 55 if (storage_.get() == &other) |
| 56 return *this; |
| 57 |
| 58 name_wrapper_ = other.name; |
| 59 storage_->scheduled_time = other.scheduled_time; |
| 60 period_in_minutes_wrapper_ = other.period_in_minutes; |
| 61 |
| 62 return *this; |
| 63 } |
| 64 |
| 65 std::string Alarm_Dev::name() const { |
| 66 return name_wrapper_.get(); |
| 67 } |
| 68 |
| 69 void Alarm_Dev::set_name(const std::string& value) { |
| 70 name_wrapper_.set(value); |
| 71 } |
| 72 |
| 73 double Alarm_Dev::scheduled_time() const { |
| 74 return storage_->scheduled_time; |
| 75 } |
| 76 |
| 77 void Alarm_Dev::set_scheduled_time(double value) { |
| 78 storage_->scheduled_time = value; |
| 79 } |
| 80 |
| 81 bool Alarm_Dev::is_period_in_minutes_set() const { |
| 82 return period_in_minutes_wrapper_.is_set(); |
| 83 } |
| 84 |
| 85 void Alarm_Dev::unset_period_in_minutes() { |
| 86 period_in_minutes_wrapper_.unset(); |
| 87 } |
| 88 |
| 89 double Alarm_Dev::period_in_minutes() const { |
| 90 return period_in_minutes_wrapper_.get(); |
| 91 } |
| 92 |
| 93 void Alarm_Dev::set_period_in_minutes(double value) { |
| 94 period_in_minutes_wrapper_.set(value); |
| 95 } |
| 96 |
| 97 void Alarm_Dev::NotifyStartRawUpdate() { |
| 98 name_wrapper_.StartRawUpdate(); |
| 99 period_in_minutes_wrapper_.StartRawUpdate(); |
| 100 } |
| 101 |
| 102 void Alarm_Dev::NotifyEndRawUpdate() { |
| 103 name_wrapper_.EndRawUpdate(); |
| 104 period_in_minutes_wrapper_.EndRawUpdate(); |
| 105 } |
| 106 |
| 107 AlarmCreateInfo_Dev::AlarmCreateInfo_Dev() |
| 108 : when_wrapper_(&storage_->when, NOT_OWNED), |
| 109 delay_in_minutes_wrapper_(&storage_->delay_in_minutes, NOT_OWNED), |
| 110 period_in_minutes_wrapper_(&storage_->period_in_minutes, NOT_OWNED) { |
| 111 } |
| 112 |
| 113 AlarmCreateInfo_Dev::AlarmCreateInfo_Dev(const AlarmCreateInfo_Dev& other) |
| 114 : when_wrapper_(&storage_->when, NOT_OWNED), |
| 115 delay_in_minutes_wrapper_(&storage_->delay_in_minutes, NOT_OWNED), |
| 116 period_in_minutes_wrapper_(&storage_->period_in_minutes, NOT_OWNED) { |
| 117 operator=(other); |
| 118 } |
| 119 |
| 120 AlarmCreateInfo_Dev::AlarmCreateInfo_Dev( |
| 121 const PP_Alarms_AlarmCreateInfo_Dev& other) |
| 122 : when_wrapper_(&storage_->when, NOT_OWNED), |
| 123 delay_in_minutes_wrapper_(&storage_->delay_in_minutes, NOT_OWNED), |
| 124 period_in_minutes_wrapper_(&storage_->period_in_minutes, NOT_OWNED) { |
| 125 operator=(other); |
| 126 } |
| 127 |
| 128 AlarmCreateInfo_Dev::AlarmCreateInfo_Dev( |
| 129 PP_Alarms_AlarmCreateInfo_Dev* storage, |
| 130 NotOwned) |
| 131 : StructWrapperBase(storage, NOT_OWNED), |
| 132 when_wrapper_(&storage_->when, NOT_OWNED), |
| 133 delay_in_minutes_wrapper_(&storage_->delay_in_minutes, NOT_OWNED), |
| 134 period_in_minutes_wrapper_(&storage_->period_in_minutes, NOT_OWNED) { |
| 135 } |
| 136 |
| 137 AlarmCreateInfo_Dev::~AlarmCreateInfo_Dev() { |
| 138 } |
| 139 |
| 140 AlarmCreateInfo_Dev& AlarmCreateInfo_Dev::operator=( |
| 141 const AlarmCreateInfo_Dev& other) { |
| 142 return operator=(*other.storage_); |
| 143 } |
| 144 |
| 145 AlarmCreateInfo_Dev& AlarmCreateInfo_Dev::operator=( |
| 146 const PP_Alarms_AlarmCreateInfo_Dev& other) { |
| 147 if (storage_.get() == &other) |
| 148 return *this; |
| 149 |
| 150 when_wrapper_ = other.when; |
| 151 delay_in_minutes_wrapper_ = other.delay_in_minutes; |
| 152 period_in_minutes_wrapper_ = other.period_in_minutes; |
| 153 |
| 154 return *this; |
| 155 } |
| 156 |
| 157 bool AlarmCreateInfo_Dev::is_when_set() const { |
| 158 return when_wrapper_.is_set(); |
| 159 } |
| 160 |
| 161 void AlarmCreateInfo_Dev::unset_when() { |
| 162 when_wrapper_.unset(); |
| 163 } |
| 164 |
| 165 double AlarmCreateInfo_Dev::when() const { |
| 166 return when_wrapper_.get(); |
| 167 } |
| 168 |
| 169 void AlarmCreateInfo_Dev::set_when(double value) { |
| 170 when_wrapper_.set(value); |
| 171 } |
| 172 |
| 173 bool AlarmCreateInfo_Dev::is_delay_in_minutes_set() const { |
| 174 return delay_in_minutes_wrapper_.is_set(); |
| 175 } |
| 176 |
| 177 void AlarmCreateInfo_Dev::unset_delay_in_minutes() { |
| 178 delay_in_minutes_wrapper_.unset(); |
| 179 } |
| 180 |
| 181 double AlarmCreateInfo_Dev::delay_in_minutes() const { |
| 182 return delay_in_minutes_wrapper_.get(); |
| 183 } |
| 184 |
| 185 void AlarmCreateInfo_Dev::set_delay_in_minutes(double value) { |
| 186 delay_in_minutes_wrapper_.set(value); |
| 187 } |
| 188 |
| 189 bool AlarmCreateInfo_Dev::is_period_in_minutes_set() const { |
| 190 return period_in_minutes_wrapper_.is_set(); |
| 191 } |
| 192 |
| 193 void AlarmCreateInfo_Dev::unset_period_in_minutes() { |
| 194 period_in_minutes_wrapper_.unset(); |
| 195 } |
| 196 |
| 197 double AlarmCreateInfo_Dev::period_in_minutes() const { |
| 198 return period_in_minutes_wrapper_.get(); |
| 199 } |
| 200 |
| 201 void AlarmCreateInfo_Dev::set_period_in_minutes(double value) { |
| 202 period_in_minutes_wrapper_.set(value); |
| 203 } |
| 204 |
| 205 void AlarmCreateInfo_Dev::NotifyStartRawUpdate() { |
| 206 when_wrapper_.StartRawUpdate(); |
| 207 delay_in_minutes_wrapper_.StartRawUpdate(); |
| 208 period_in_minutes_wrapper_.StartRawUpdate(); |
| 209 } |
| 210 |
| 211 void AlarmCreateInfo_Dev::NotifyEndRawUpdate() { |
| 212 when_wrapper_.EndRawUpdate(); |
| 213 delay_in_minutes_wrapper_.EndRawUpdate(); |
| 214 period_in_minutes_wrapper_.EndRawUpdate(); |
| 215 } |
| 216 |
| 217 Alarms_Dev::Alarms_Dev(const InstanceHandle& instance) : instance_(instance) { |
| 218 } |
| 219 |
| 220 Alarms_Dev::~Alarms_Dev() { |
| 221 } |
| 222 |
| 223 void Alarms_Dev::Create(const Optional<std::string>& name, |
| 224 const AlarmCreateInfo_Dev& alarm_info) { |
| 225 if (!has_interface<PPB_Alarms_Dev_0_1>()) |
| 226 return; |
| 227 |
| 228 internal::ToCTypeConverter<Optional<std::string> > name_converter(name); |
| 229 internal::ToCTypeConverter<AlarmCreateInfo_Dev> alarm_info_converter( |
| 230 alarm_info); |
| 231 |
| 232 return get_interface<PPB_Alarms_Dev_0_1>()->Create( |
| 233 instance_.pp_instance(), |
| 234 name_converter.ToCInput(), |
| 235 alarm_info_converter.ToCInput()); |
| 236 } |
| 237 |
| 238 int32_t Alarms_Dev::Get(const Optional<std::string>& name, |
| 239 const GetCallback& callback) { |
| 240 if (!has_interface<PPB_Alarms_Dev_0_1>()) |
| 241 return callback.MayForce(PP_ERROR_NOINTERFACE); |
| 242 |
| 243 internal::ToCTypeConverter<Optional<std::string> > name_converter(name); |
| 244 |
| 245 return get_interface<PPB_Alarms_Dev_0_1>()->Get( |
| 246 instance_.pp_instance(), |
| 247 name_converter.ToCInput(), |
| 248 callback.output(), |
| 249 callback.pp_completion_callback()); |
| 250 } |
| 251 |
| 252 int32_t Alarms_Dev::GetAll(const GetAllCallback& callback) { |
| 253 if (!has_interface<PPB_Alarms_Dev_0_1>()) |
| 254 return callback.MayForce(PP_ERROR_NOINTERFACE); |
| 255 |
| 256 return get_interface<PPB_Alarms_Dev_0_1>()->GetAll( |
| 257 instance_.pp_instance(), |
| 258 callback.output(), |
| 259 internal::ArrayAllocator::Get(), |
| 260 callback.pp_completion_callback()); |
| 261 } |
| 262 |
| 263 void Alarms_Dev::Clear(const Optional<std::string>& name) { |
| 264 if (!has_interface<PPB_Alarms_Dev_0_1>()) |
| 265 return; |
| 266 |
| 267 internal::ToCTypeConverter<Optional<std::string> > name_converter(name); |
| 268 |
| 269 return get_interface<PPB_Alarms_Dev_0_1>()->Clear( |
| 270 instance_.pp_instance(), |
| 271 name_converter.ToCInput()); |
| 272 } |
| 273 |
| 274 void Alarms_Dev::ClearAll() { |
| 275 if (!has_interface<PPB_Alarms_Dev_0_1>()) |
| 276 return; |
| 277 |
| 278 return get_interface<PPB_Alarms_Dev_0_1>()->ClearAll( |
| 279 instance_.pp_instance()); |
| 280 } |
| 281 |
| 282 } // namespace alarms |
| 283 } // namespace pp |
| OLD | NEW |