| 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 #ifndef PPAPI_CPP_DEV_ALARMS_DEV_H_ |
| 6 #define PPAPI_CPP_DEV_ALARMS_DEV_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "ppapi/c/dev/ppb_alarms_dev.h" |
| 11 #include "ppapi/cpp/dev/may_own_ptr_dev.h" |
| 12 #include "ppapi/cpp/dev/optional_dev.h" |
| 13 #include "ppapi/cpp/dev/string_wrapper_dev.h" |
| 14 #include "ppapi/cpp/dev/struct_wrapper_output_traits_dev.h" |
| 15 #include "ppapi/cpp/instance_handle.h" |
| 16 #include "ppapi/cpp/output_traits.h" |
| 17 |
| 18 namespace pp { |
| 19 |
| 20 template <typename T> |
| 21 class CompletionCallbackWithOutput; |
| 22 |
| 23 template <typename T> |
| 24 class Array; |
| 25 |
| 26 namespace alarms { |
| 27 |
| 28 // Data types ------------------------------------------------------------------ |
| 29 class Alarm_Dev { |
| 30 public: |
| 31 typedef PP_Alarms_Alarm_Dev CType; |
| 32 typedef PP_Alarms_Alarm_Array_Dev CArrayType; |
| 33 |
| 34 Alarm_Dev(); |
| 35 |
| 36 Alarm_Dev(const Alarm_Dev& other); |
| 37 |
| 38 explicit Alarm_Dev(const PP_Alarms_Alarm_Dev& other); |
| 39 |
| 40 // Creates an accessor to |storage| but doesn't take ownership of the memory. |
| 41 // |storage| must live longer than this object. The contents pointed to by |
| 42 // |storage| is managed by this object. |
| 43 // Used by Pepper internal implementation. |
| 44 Alarm_Dev(PP_Alarms_Alarm_Dev* storage, NotOwned); |
| 45 |
| 46 ~Alarm_Dev(); |
| 47 |
| 48 Alarm_Dev& operator=(const Alarm_Dev& other); |
| 49 Alarm_Dev& operator=(const PP_Alarms_Alarm_Dev& other); |
| 50 |
| 51 std::string name() const; |
| 52 void set_name(const std::string& value); |
| 53 |
| 54 double scheduled_time() const; |
| 55 void set_scheduled_time(double value); |
| 56 |
| 57 bool is_period_in_minutes_set() const; |
| 58 void unset_period_in_minutes(); |
| 59 double period_in_minutes() const; |
| 60 void set_period_in_minutes(double value); |
| 61 |
| 62 const PP_Alarms_Alarm_Dev* ToStruct() const; |
| 63 |
| 64 // The returned pointer is still owned by this object. And after it is used, |
| 65 // EndRawUpdate() must be called. |
| 66 PP_Alarms_Alarm_Dev* StartRawUpdate(); |
| 67 void EndRawUpdate(); |
| 68 |
| 69 private: |
| 70 internal::MayOwnPtr<PP_Alarms_Alarm_Dev> storage_; |
| 71 |
| 72 internal::StringWrapper name_wrapper_; |
| 73 Optional<double> period_in_minutes_wrapper_; |
| 74 }; |
| 75 |
| 76 class AlarmCreateInfo_Dev { |
| 77 public: |
| 78 typedef PP_Alarms_AlarmCreateInfo_Dev CType; |
| 79 |
| 80 AlarmCreateInfo_Dev(); |
| 81 |
| 82 AlarmCreateInfo_Dev(const AlarmCreateInfo_Dev& other); |
| 83 |
| 84 explicit AlarmCreateInfo_Dev(const PP_Alarms_AlarmCreateInfo_Dev& other); |
| 85 |
| 86 // Creates an accessor to |storage| but doesn't take ownership of the memory. |
| 87 // |storage| must live longer than this object. The contents pointed to by |
| 88 // |storage| is managed by this object. |
| 89 // Used by Pepper internal implementation. |
| 90 AlarmCreateInfo_Dev(PP_Alarms_AlarmCreateInfo_Dev* storage, NotOwned); |
| 91 |
| 92 ~AlarmCreateInfo_Dev(); |
| 93 |
| 94 AlarmCreateInfo_Dev& operator=(const AlarmCreateInfo_Dev& other); |
| 95 AlarmCreateInfo_Dev& operator=(const PP_Alarms_AlarmCreateInfo_Dev& other); |
| 96 |
| 97 bool is_when_set() const; |
| 98 void unset_when(); |
| 99 double when() const; |
| 100 void set_when(double value); |
| 101 |
| 102 bool is_delay_in_minutes_set() const; |
| 103 void unset_delay_in_minutes(); |
| 104 double delay_in_minutes() const; |
| 105 void set_delay_in_minutes(double value); |
| 106 |
| 107 bool is_period_in_minutes_set() const; |
| 108 void unset_period_in_minutes(); |
| 109 double period_in_minutes() const; |
| 110 void set_period_in_minutes(double value); |
| 111 |
| 112 const PP_Alarms_AlarmCreateInfo_Dev* ToStruct() const; |
| 113 |
| 114 // The returned pointer is still owned by this object. And after it is used, |
| 115 // EndRawUpdate() must be called. |
| 116 PP_Alarms_AlarmCreateInfo_Dev* StartRawUpdate(); |
| 117 void EndRawUpdate(); |
| 118 |
| 119 private: |
| 120 internal::MayOwnPtr<PP_Alarms_AlarmCreateInfo_Dev> storage_; |
| 121 |
| 122 Optional<double> when_wrapper_; |
| 123 Optional<double> delay_in_minutes_wrapper_; |
| 124 Optional<double> period_in_minutes_wrapper_; |
| 125 }; |
| 126 |
| 127 // Functions ------------------------------------------------------------------- |
| 128 class Alarms_Dev { |
| 129 public: |
| 130 explicit Alarms_Dev(const InstanceHandle& instance); |
| 131 ~Alarms_Dev(); |
| 132 |
| 133 void Create(const Optional<std::string>& name, |
| 134 const AlarmCreateInfo_Dev& alarm_info); |
| 135 |
| 136 typedef CompletionCallbackWithOutput<Alarm_Dev> GetCallback; |
| 137 int32_t Get(const Optional<std::string>& name, const GetCallback& callback); |
| 138 |
| 139 typedef CompletionCallbackWithOutput<Array<Alarm_Dev> > GetAllCallback; |
| 140 int32_t GetAll(const GetAllCallback& callback); |
| 141 |
| 142 void Clear(const Optional<std::string>& name); |
| 143 |
| 144 void ClearAll(); |
| 145 |
| 146 private: |
| 147 InstanceHandle instance_; |
| 148 }; |
| 149 |
| 150 // Events ---------------------------------------------------------------------- |
| 151 // TODO(yzshen): add onAlarm event. |
| 152 |
| 153 } // namespace alarms |
| 154 |
| 155 namespace internal { |
| 156 |
| 157 template <> |
| 158 struct CallbackOutputTraits<alarms::Alarm_Dev> |
| 159 : public internal::StructWrapperOutputTraits<alarms::Alarm_Dev> { |
| 160 }; |
| 161 |
| 162 template <> |
| 163 struct CallbackOutputTraits<alarms::AlarmCreateInfo_Dev> |
| 164 : public internal::StructWrapperOutputTraits<alarms::AlarmCreateInfo_Dev> { |
| 165 }; |
| 166 |
| 167 } // namespace internal |
| 168 } // namespace pp |
| 169 |
| 170 #endif // PPAPI_CPP_DEV_ALARMS_DEV_H_ |
| OLD | NEW |