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