Pepper_31_C++_interfaces
alarms_dev.h
Go to the documentation of this file.
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_EXTENSIONS_DEV_ALARMS_DEV_H_
6 #define PPAPI_CPP_EXTENSIONS_DEV_ALARMS_DEV_H_
7 
8 #include <string>
9 #include <vector>
10 
11 #include "ppapi/c/extensions/dev/ppb_ext_alarms_dev.h"
12 #include "ppapi/cpp/extensions/dict_field.h"
13 #include "ppapi/cpp/extensions/event_base.h"
14 #include "ppapi/cpp/extensions/ext_output_traits.h"
15 #include "ppapi/cpp/instance_handle.h"
16 #include "ppapi/cpp/var.h"
17 
18 namespace pp {
19 namespace ext {
20 
21 template <class T>
22 class ExtCompletionCallbackWithOutput;
23 
24 template <class T>
25 class Optional;
26 
27 namespace alarms {
28 
29 // Data types ------------------------------------------------------------------
30 class Alarm_Dev {
31  public:
32  Alarm_Dev();
33  ~Alarm_Dev();
34 
35  bool Populate(const PP_Ext_Alarms_Alarm_Dev& value);
36 
37  Var CreateVar() const;
38 
39  static const char* const kName;
40  static const char* const kScheduledTime;
41  static const char* const kPeriodInMinutes;
42 
46 };
47 
49  public:
52 
53  bool Populate(const PP_Ext_Alarms_AlarmCreateInfo_Dev& value);
54 
55  Var CreateVar() const;
56 
57  static const char* const kWhen;
58  static const char* const kDelayInMinutes;
59  static const char* const kPeriodInMinutes;
60 
64 };
65 
66 // Functions -------------------------------------------------------------------
67 class Alarms_Dev {
68  public:
69  explicit Alarms_Dev(const InstanceHandle& instance);
70  ~Alarms_Dev();
71 
72  void Create(const Optional<std::string>& name,
73  const AlarmCreateInfo_Dev& alarm_info);
74 
76  int32_t Get(const Optional<std::string>& name, const GetCallback& callback);
77 
80  int32_t GetAll(const GetAllCallback& callback);
81 
82  void Clear(const Optional<std::string>& name);
83 
84  void ClearAll();
85 
86  private:
87  InstanceHandle instance_;
88 };
89 
90 // Events ----------------------------------------------------------------------
91 // Please see ppapi/cpp/extensions/event_base.h for how to use an event class.
92 
94  : public internal::EventBase1<PP_Ext_Alarms_OnAlarm_Dev, Alarm_Dev> {
95  public:
96  class Listener {
97  public:
98  virtual ~Listener() {}
99 
100  virtual void OnAlarm(Alarm_Dev& alarm) = 0;
101  };
102 
103  // |listener| is not owned by this instance and must outlive it.
104  OnAlarmEvent_Dev(const InstanceHandle& instance, Listener* listener);
105  virtual ~OnAlarmEvent_Dev();
106 
107  private:
108  virtual void Callback(Alarm_Dev& alarm);
109 
110  Listener* listener_;
111 };
112 
113 } // namespace alarms
114 } // namespace ext
115 } // namespace pp
116 
117 #endif // PPAPI_CPP_EXTENSIONS_DEV_ALARMS_DEV_H_
OptionalDictField< double > delay_in_minutes
Definition: alarms_dev.h:62
OptionalDictField< double > when
Definition: alarms_dev.h:61
Alarms_Dev(const InstanceHandle &instance)
OptionalDictField< double > period_in_minutes
Definition: alarms_dev.h:45
static const char *const kPeriodInMinutes
Definition: alarms_dev.h:59
static const char *const kDelayInMinutes
Definition: alarms_dev.h:58
virtual void OnAlarm(Alarm_Dev &alarm)=0
static const char *const kPeriodInMinutes
Definition: alarms_dev.h:41
bool Populate(const PP_Ext_Alarms_AlarmCreateInfo_Dev &value)
void Clear(const Optional< std::string > &name)
ExtCompletionCallbackWithOutput< Alarm_Dev > GetCallback
Definition: alarms_dev.h:75
static const char *const kName
Definition: alarms_dev.h:39
ExtCompletionCallbackWithOutput< std::vector< Alarm_Dev > > GetAllCallback
Definition: alarms_dev.h:79
int32_t GetAll(const GetAllCallback &callback)
OnAlarmEvent_Dev(const InstanceHandle &instance, Listener *listener)
static const char *const kScheduledTime
Definition: alarms_dev.h:40
DictField< double > scheduled_time
Definition: alarms_dev.h:44
A generic type used for passing data types between the module and the page.
Definition: var.h:20
DictField< std::string > name
Definition: alarms_dev.h:43
void Create(const Optional< std::string > &name, const AlarmCreateInfo_Dev &alarm_info)
OptionalDictField< double > period_in_minutes
Definition: alarms_dev.h:63
int32_t Get(const Optional< std::string > &name, const GetCallback &callback)
bool Populate(const PP_Ext_Alarms_Alarm_Dev &value)
static const char *const kWhen
Definition: alarms_dev.h:57