| 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/optional_dev.h" |
| 12 #include "ppapi/cpp/dev/string_wrapper_dev.h" |
| 13 #include "ppapi/cpp/dev/struct_wrapper_base_dev.h" |
| 14 #include "ppapi/cpp/instance_handle.h" |
| 15 |
| 16 namespace pp { |
| 17 |
| 18 template <typename T> |
| 19 class CompletionCallbackWithOutput; |
| 20 |
| 21 template <typename T> |
| 22 class Array; |
| 23 |
| 24 namespace alarms { |
| 25 |
| 26 // Data types ------------------------------------------------------------------ |
| 27 class Alarm_Dev |
| 28 : public internal::StructWrapperBase<PP_Alarms_Alarm_Dev, |
| 29 PP_Alarms_Alarm_Array_Dev> { |
| 30 public: |
| 31 Alarm_Dev(); |
| 32 |
| 33 Alarm_Dev(const Alarm_Dev& other); |
| 34 |
| 35 explicit Alarm_Dev(const PP_Alarms_Alarm_Dev& other); |
| 36 |
| 37 // Used to wrap struct members and array elements. |
| 38 // It doesn't take ownership of |storage|, therefore |storage| must live |
| 39 // longer than this object. |storage| must be zero-initialized. |
| 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 explicit AlarmCreateInfo_Dev(const PP_Alarms_AlarmCreateInfo_Dev& other); |
| 74 |
| 75 // Used to wrap struct members and array elements. |
| 76 // It doesn't take ownership of |storage|, therefore |storage| must live |
| 77 // longer than this object. |storage| must be zero-initialized. |
| 78 AlarmCreateInfo_Dev(PP_Alarms_AlarmCreateInfo_Dev* storage, NotOwned); |
| 79 |
| 80 virtual ~AlarmCreateInfo_Dev(); |
| 81 |
| 82 AlarmCreateInfo_Dev& operator=(const AlarmCreateInfo_Dev& other); |
| 83 AlarmCreateInfo_Dev& operator=(const PP_Alarms_AlarmCreateInfo_Dev& other); |
| 84 |
| 85 bool is_when_set() const; |
| 86 void unset_when(); |
| 87 double when() const; |
| 88 void set_when(double value); |
| 89 |
| 90 bool is_delay_in_minutes_set() const; |
| 91 void unset_delay_in_minutes(); |
| 92 double delay_in_minutes() const; |
| 93 void set_delay_in_minutes(double value); |
| 94 |
| 95 bool is_period_in_minutes_set() const; |
| 96 void unset_period_in_minutes(); |
| 97 double period_in_minutes() const; |
| 98 void set_period_in_minutes(double value); |
| 99 |
| 100 private: |
| 101 virtual void NotifyStartRawUpdate(); |
| 102 virtual void NotifyEndRawUpdate(); |
| 103 |
| 104 Optional<double> when_wrapper_; |
| 105 Optional<double> delay_in_minutes_wrapper_; |
| 106 Optional<double> period_in_minutes_wrapper_; |
| 107 }; |
| 108 |
| 109 // Functions ------------------------------------------------------------------- |
| 110 class Alarms_Dev { |
| 111 public: |
| 112 explicit Alarms_Dev(const InstanceHandle& instance); |
| 113 ~Alarms_Dev(); |
| 114 |
| 115 void Create(const Optional<std::string>& name, |
| 116 const AlarmCreateInfo_Dev& alarm_info); |
| 117 |
| 118 typedef CompletionCallbackWithOutput<Alarm_Dev> GetCallback; |
| 119 int32_t Get(const Optional<std::string>& name, const GetCallback& callback); |
| 120 |
| 121 typedef CompletionCallbackWithOutput<Array<Alarm_Dev> > GetAllCallback; |
| 122 int32_t GetAll(const GetAllCallback& callback); |
| 123 |
| 124 void Clear(const Optional<std::string>& name); |
| 125 |
| 126 void ClearAll(); |
| 127 |
| 128 private: |
| 129 InstanceHandle instance_; |
| 130 }; |
| 131 |
| 132 // Events ---------------------------------------------------------------------- |
| 133 // TODO(yzshen): add onAlarm event. |
| 134 |
| 135 } // namespace alarms |
| 136 } // namespace pp |
| 137 |
| 138 #endif // PPAPI_CPP_DEV_ALARMS_DEV_H_ |
| OLD | NEW |