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 #include <vector> |
| 10 |
| 11 #include "ppapi/c/dev/ppb_alarms_dev.h" |
| 12 #include "ppapi/cpp/dev/optional_dev.h" |
| 13 #include "ppapi/cpp/dev/struct_wrapper_base_dev.h" |
| 14 #include "ppapi/cpp/instance_handle.h" |
| 15 #include "ppapi/cpp/output_traits.h" |
| 16 #include "ppapi/cpp/var.h" |
| 17 |
| 18 namespace pp { |
| 19 |
| 20 template <class T> |
| 21 class CompletionCallbackWithOutput; |
| 22 |
| 23 namespace alarms { |
| 24 |
| 25 // Data types ------------------------------------------------------------------ |
| 26 class Alarm_Dev |
| 27 : public internal::StructWrapperBase<PP_Alarms_Alarm_Dev, |
| 28 PP_Alarms_Alarm_Array_Dev> { |
| 29 public: |
| 30 Alarm_Dev(); |
| 31 |
| 32 Alarm_Dev(const Alarm_Dev& other); |
| 33 |
| 34 // For taking input parameters from event listeners. |
| 35 explicit Alarm_Dev(const PP_Alarms_Alarm_Dev& other); |
| 36 |
| 37 // For struct / array members. |
| 38 // It doesn't take ownership of |storage|, therefore |storage| must live |
| 39 // longer than this object. |
| 40 Alarm_Dev(PP_Alarms_Alarm_Dev* storage, NotOwned); |
| 41 |
| 42 virtual ~Alarm_Dev(); |
| 43 |
| 44 Alarm_Dev& operator=(const Alarm_Dev& other); |
| 45 Alarm_Dev& operator=(const PP_Alarms_Alarm_Dev& other); |
| 46 |
| 47 std::string name() const; |
| 48 void set_name(const std::string& value); |
| 49 |
| 50 double scheduled_time() const; |
| 51 void set_scheduled_time(double value); |
| 52 |
| 53 bool is_period_in_minutes_set() const; |
| 54 void unset_period_in_minutes(); |
| 55 double period_in_minutes() const; |
| 56 void set_period_in_minutes(double value); |
| 57 |
| 58 private: |
| 59 virtual void NotifyStartRawUpdate(); |
| 60 virtual void NotifyEndRawUpdate(); |
| 61 |
| 62 internal::StringWrapper name_wrapper_; |
| 63 Optional<double> period_in_minutes_wrapper_; |
| 64 }; |
| 65 |
| 66 class AlarmCreateInfo_Dev |
| 67 : public internal::StructWrapperBase<PP_Alarms_AlarmCreateInfo_Dev> { |
| 68 public: |
| 69 AlarmCreateInfo_Dev(); |
| 70 |
| 71 AlarmCreateInfo_Dev(const AlarmCreateInfo_Dev& other); |
| 72 |
| 73 // For taking input parameters from event listeners. |
| 74 explicit AlarmCreateInfo_Dev(const PP_Alarms_AlarmCreateInfo_Dev& other); |
| 75 |
| 76 // For struct / array members. |
| 77 // It doesn't take ownership of |storage|, therefore |storage| must live |
| 78 // longer than this object. |
| 79 AlarmCreateInfo_Dev(PP_Alarms_AlarmCreateInfo_Dev* storage, NotOwned); |
| 80 |
| 81 virtual ~AlarmCreateInfo_Dev(); |
| 82 |
| 83 AlarmCreateInfo_Dev& operator=(const AlarmCreateInfo_Dev& other); |
| 84 AlarmCreateInfo_Dev& operator=(const PP_Alarms_AlarmCreateInfo_Dev& other); |
| 85 |
| 86 bool is_when_set() const; |
| 87 void unset_when(); |
| 88 double when() const; |
| 89 void set_when(double value); |
| 90 |
| 91 bool is_delay_in_minutes_set() const; |
| 92 void unset_delay_in_minutes(); |
| 93 double delay_in_minutes() const; |
| 94 void set_delay_in_minutes(double value); |
| 95 |
| 96 bool is_period_in_minutes_set() const; |
| 97 void unset_period_in_minutes(); |
| 98 double period_in_minutes() const; |
| 99 void set_period_in_minutes(double value); |
| 100 |
| 101 private: |
| 102 virtual void NotifyStartRawUpdate(); |
| 103 virtual void NotifyEndRawUpdate(); |
| 104 |
| 105 Optional<double> when_wrapper_; |
| 106 Optional<double> delay_in_minutes_wrapper_; |
| 107 Optional<double> period_in_minutes_wrapper_; |
| 108 }; |
| 109 |
| 110 // Functions ------------------------------------------------------------------- |
| 111 class Alarms_Dev { |
| 112 public: |
| 113 explicit Alarms_Dev(const InstanceHandle& instance); |
| 114 ~Alarms_Dev(); |
| 115 |
| 116 void Create(const Optional<std::string>& name, |
| 117 const AlarmCreateInfo_Dev& alarm_info); |
| 118 |
| 119 typedef CompletionCallbackWithOutput<Alarm_Dev> GetCallback; |
| 120 int32_t Get(const Optional<std::string>& name, const GetCallback& callback); |
| 121 |
| 122 typedef CompletionCallbackWithOutput<Array<Alarm_Dev> > |
| 123 GetAllCallback; |
| 124 int32_t GetAll(const GetAllCallback& callback); |
| 125 |
| 126 void Clear(const Optional<std::string>& name); |
| 127 |
| 128 void ClearAll(); |
| 129 |
| 130 private: |
| 131 InstanceHandle instance_; |
| 132 }; |
| 133 |
| 134 // Events ---------------------------------------------------------------------- |
| 135 // TODO(yzshen): add onAlarm event. |
| 136 |
| 137 } // namespace alarms |
| 138 } // namespace pp |
| 139 |
| 140 #endif // PPAPI_CPP_DEV_ALARMS_DEV_H_ |
OLD | NEW |