Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(211)

Unified Diff: ppapi/cpp/dev/alarms_dev.h

Issue 116963003: App APIs in Pepper: C++ APIs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: changes according to Sam's suggestions. Created 7 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « native_client_sdk/src/libraries/ppapi_cpp/library.dsc ('k') | ppapi/cpp/dev/alarms_dev.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ppapi/cpp/dev/alarms_dev.h
diff --git a/ppapi/cpp/dev/alarms_dev.h b/ppapi/cpp/dev/alarms_dev.h
new file mode 100644
index 0000000000000000000000000000000000000000..ce9eaeb1a86f595033830898cf0f4c4ee1d8eb35
--- /dev/null
+++ b/ppapi/cpp/dev/alarms_dev.h
@@ -0,0 +1,170 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PPAPI_CPP_DEV_ALARMS_DEV_H_
+#define PPAPI_CPP_DEV_ALARMS_DEV_H_
+
+#include <string>
+
+#include "ppapi/c/dev/ppb_alarms_dev.h"
+#include "ppapi/cpp/dev/may_own_ptr_dev.h"
+#include "ppapi/cpp/dev/optional_dev.h"
+#include "ppapi/cpp/dev/string_wrapper_dev.h"
+#include "ppapi/cpp/dev/struct_wrapper_output_traits_dev.h"
+#include "ppapi/cpp/instance_handle.h"
+#include "ppapi/cpp/output_traits.h"
+
+namespace pp {
+
+template <typename T>
+class CompletionCallbackWithOutput;
+
+template <typename T>
+class Array;
+
+namespace alarms {
+
+// Data types ------------------------------------------------------------------
+class Alarm_Dev {
+ public:
+ typedef PP_Alarms_Alarm_Dev CType;
+ typedef PP_Alarms_Alarm_Array_Dev CArrayType;
+
+ Alarm_Dev();
+
+ Alarm_Dev(const Alarm_Dev& other);
+
+ explicit Alarm_Dev(const PP_Alarms_Alarm_Dev& other);
+
+ // Creates an accessor to |storage| but doesn't take ownership of the memory.
+ // |storage| must live longer than this object. The contents pointed to by
+ // |storage| is managed by this object.
+ // Used by Pepper internal implementation.
+ Alarm_Dev(PP_Alarms_Alarm_Dev* storage, NotOwned);
+
+ ~Alarm_Dev();
+
+ Alarm_Dev& operator=(const Alarm_Dev& other);
+ Alarm_Dev& operator=(const PP_Alarms_Alarm_Dev& other);
+
+ std::string name() const;
+ void set_name(const std::string& value);
+
+ double scheduled_time() const;
+ void set_scheduled_time(double value);
+
+ bool is_period_in_minutes_set() const;
+ void unset_period_in_minutes();
+ double period_in_minutes() const;
+ void set_period_in_minutes(double value);
+
+ const PP_Alarms_Alarm_Dev* ToStruct() const;
+
+ // The returned pointer is still owned by this object. And after it is used,
+ // EndRawUpdate() must be called.
+ PP_Alarms_Alarm_Dev* StartRawUpdate();
+ void EndRawUpdate();
+
+ private:
+ internal::MayOwnPtr<PP_Alarms_Alarm_Dev> storage_;
+
+ internal::StringWrapper name_wrapper_;
+ Optional<double> period_in_minutes_wrapper_;
+};
+
+class AlarmCreateInfo_Dev {
+ public:
+ typedef PP_Alarms_AlarmCreateInfo_Dev CType;
+
+ AlarmCreateInfo_Dev();
+
+ AlarmCreateInfo_Dev(const AlarmCreateInfo_Dev& other);
+
+ explicit AlarmCreateInfo_Dev(const PP_Alarms_AlarmCreateInfo_Dev& other);
+
+ // Creates an accessor to |storage| but doesn't take ownership of the memory.
+ // |storage| must live longer than this object. The contents pointed to by
+ // |storage| is managed by this object.
+ // Used by Pepper internal implementation.
+ AlarmCreateInfo_Dev(PP_Alarms_AlarmCreateInfo_Dev* storage, NotOwned);
+
+ ~AlarmCreateInfo_Dev();
+
+ AlarmCreateInfo_Dev& operator=(const AlarmCreateInfo_Dev& other);
+ AlarmCreateInfo_Dev& operator=(const PP_Alarms_AlarmCreateInfo_Dev& other);
+
+ bool is_when_set() const;
+ void unset_when();
+ double when() const;
+ void set_when(double value);
+
+ bool is_delay_in_minutes_set() const;
+ void unset_delay_in_minutes();
+ double delay_in_minutes() const;
+ void set_delay_in_minutes(double value);
+
+ bool is_period_in_minutes_set() const;
+ void unset_period_in_minutes();
+ double period_in_minutes() const;
+ void set_period_in_minutes(double value);
+
+ const PP_Alarms_AlarmCreateInfo_Dev* ToStruct() const;
+
+ // The returned pointer is still owned by this object. And after it is used,
+ // EndRawUpdate() must be called.
+ PP_Alarms_AlarmCreateInfo_Dev* StartRawUpdate();
+ void EndRawUpdate();
+
+ private:
+ internal::MayOwnPtr<PP_Alarms_AlarmCreateInfo_Dev> storage_;
+
+ Optional<double> when_wrapper_;
+ Optional<double> delay_in_minutes_wrapper_;
+ Optional<double> period_in_minutes_wrapper_;
+};
+
+// Functions -------------------------------------------------------------------
+class Alarms_Dev {
+ public:
+ explicit Alarms_Dev(const InstanceHandle& instance);
+ ~Alarms_Dev();
+
+ void Create(const Optional<std::string>& name,
+ const AlarmCreateInfo_Dev& alarm_info);
+
+ typedef CompletionCallbackWithOutput<Alarm_Dev> GetCallback;
+ int32_t Get(const Optional<std::string>& name, const GetCallback& callback);
+
+ typedef CompletionCallbackWithOutput<Array<Alarm_Dev> > GetAllCallback;
+ int32_t GetAll(const GetAllCallback& callback);
+
+ void Clear(const Optional<std::string>& name);
+
+ void ClearAll();
+
+ private:
+ InstanceHandle instance_;
+};
+
+// Events ----------------------------------------------------------------------
+// TODO(yzshen): add onAlarm event.
+
+} // namespace alarms
+
+namespace internal {
+
+template <>
+struct CallbackOutputTraits<alarms::Alarm_Dev>
+ : public internal::StructWrapperOutputTraits<alarms::Alarm_Dev> {
+};
+
+template <>
+struct CallbackOutputTraits<alarms::AlarmCreateInfo_Dev>
+ : public internal::StructWrapperOutputTraits<alarms::AlarmCreateInfo_Dev> {
+};
+
+} // namespace internal
+} // namespace pp
+
+#endif // PPAPI_CPP_DEV_ALARMS_DEV_H_
« no previous file with comments | « native_client_sdk/src/libraries/ppapi_cpp/library.dsc ('k') | ppapi/cpp/dev/alarms_dev.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698