From 9997d2396ff1cb7eea3cdaca6c9f204b02d8ca21 Mon Sep 17 00:00:00 2001 From: "yzshen@chromium.org" Date: Mon, 11 Mar 2013 03:19:56 +0000 Subject: Revert 187227 since it caused buildbot failure in NativeClientSDK on linux-sdk-multi - Add C/C++ interfaces for PPB_Ext_Alarms_Dev and PPB_Ext_Events_Dev. This CL also adds necessary C++ utilities to support these interfaces. An example of using these APIs: https://codereview.chromium.org/12387051/ BUG=None TEST=None Review URL: https://codereview.chromium.org/12295043 TBR=yzshen@chromium.org Review URL: https://codereview.chromium.org/12760002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@187229 0039d316-1c4b-4281-b951-d872f2087c98 --- ppapi/api/extensions/dev/ppb_alarms_dev.idl | 178 ---------------- ppapi/api/extensions/dev/ppb_events_dev.idl | 87 -------- ppapi/c/extensions/dev/ppb_alarms_dev.h | 202 ------------------ ppapi/c/extensions/dev/ppb_events_dev.h | 118 ----------- ppapi/cpp/extensions/dev/alarms_dev.cc | 173 --------------- ppapi/cpp/extensions/dev/alarms_dev.h | 113 ---------- ppapi/cpp/extensions/dev/events_dev.cc | 43 ---- ppapi/cpp/extensions/dev/events_dev.h | 34 --- ppapi/cpp/extensions/dict_field.h | 69 ------ ppapi/cpp/extensions/event_base.cc | 44 ---- ppapi/cpp/extensions/event_base.h | 232 --------------------- ppapi/cpp/extensions/ext_output_traits.h | 133 ------------ ppapi/cpp/extensions/from_var_converter.h | 100 --------- ppapi/cpp/extensions/optional.h | 91 -------- ppapi/cpp/extensions/to_var_converter.h | 89 -------- ppapi/cpp/output_traits.h | 45 ++-- ppapi/cpp/var.cc | 12 -- ppapi/cpp/var.h | 7 +- ppapi/generators/idl_parser.py | 3 +- .../src/untrusted/pnacl_irt_shim/pnacl_shim.c | 81 ------- ppapi/ppapi_sources.gypi | 19 -- ppapi/tests/all_c_includes.h | 2 - ppapi/tests/all_cpp_includes.h | 1 - 23 files changed, 21 insertions(+), 1855 deletions(-) delete mode 100644 ppapi/api/extensions/dev/ppb_alarms_dev.idl delete mode 100644 ppapi/api/extensions/dev/ppb_events_dev.idl delete mode 100644 ppapi/c/extensions/dev/ppb_alarms_dev.h delete mode 100644 ppapi/c/extensions/dev/ppb_events_dev.h delete mode 100644 ppapi/cpp/extensions/dev/alarms_dev.cc delete mode 100644 ppapi/cpp/extensions/dev/alarms_dev.h delete mode 100644 ppapi/cpp/extensions/dev/events_dev.cc delete mode 100644 ppapi/cpp/extensions/dev/events_dev.h delete mode 100644 ppapi/cpp/extensions/dict_field.h delete mode 100644 ppapi/cpp/extensions/event_base.cc delete mode 100644 ppapi/cpp/extensions/event_base.h delete mode 100644 ppapi/cpp/extensions/ext_output_traits.h delete mode 100644 ppapi/cpp/extensions/from_var_converter.h delete mode 100644 ppapi/cpp/extensions/optional.h delete mode 100644 ppapi/cpp/extensions/to_var_converter.h (limited to 'ppapi') diff --git a/ppapi/api/extensions/dev/ppb_alarms_dev.idl b/ppapi/api/extensions/dev/ppb_alarms_dev.idl deleted file mode 100644 index b227993..0000000 --- a/ppapi/api/extensions/dev/ppb_alarms_dev.idl +++ /dev/null @@ -1,178 +0,0 @@ -/* 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. - */ - -/** - * This file defines the Pepper equivalent of the chrome.alarms - * extension API. - */ - -label Chrome { - M27 = 0.1 -}; - -#inline c -#include "ppapi/c/extensions/dev/ppb_events_dev.h" -#endinl - -/** - * A dictionary PP_Var which contains: - * - "name" : string PP_Var - * Name of this alarm. - * - * - "scheduledTime" : double PP_Var - * Time at which this alarm was scheduled to fire, in milliseconds past the - * epoch (e.g. Date.now() + n). For performance reasons, the - * alarm may have been delayed an arbitrary amount beyond this. - * - * - "periodInMinutes" : double or undefined PP_Var - * If not undefined, the alarm is a repeating alarm and will fire again in - * periodInMinutes minutes. - */ -typedef PP_Var PP_Ext_Alarms_Alarm_Dev; - -/** - * A dictionary PP_Var which contains - * - "when" : double or undefined PP_Var - * Time at which the alarm should fire, in milliseconds past the epoch - * (e.g. Date.now() + n). - * - * - "delayInMinutes" : double or undefined PP_Var - * Length of time in minutes after which the - * PP_Ext_Alarms_OnAlarm_Dev event should fire. - * - * - "periodInMinutes" : double or undefined PP_Var - * If set, the PP_Ext_Alarms_OnAlarm_Dev event should fire every - * periodInMinutes minutes after the initial event specified by - * when or delayInMinutes. If not set, the alarm will - * only fire once. - */ -typedef PP_Var PP_Ext_Alarms_AlarmCreateInfo_Dev; - -/** - * An array PP_Var which contains elements of - * PP_Ext_Alarms_Alarm_Dev. - */ -typedef PP_Var PP_Ext_Alarms_Alarm_Dev_Array; - -interface PPB_Ext_Alarms_Dev { - /** - * Creates an alarm. Near the time(s) specified by alarm_info, - * the PP_Ext_Alarms_OnAlarm_Dev event is fired. If there is - * another alarm with the same name (or no name if none is specified), it will - * be cancelled and replaced by this alarm. - * - * In order to reduce the load on the user's machine, Chrome limits alarms - * to at most once every 1 minute but may delay them an arbitrary amount - * more. That is, setting - * $ref:[PP_Ext_Alarms_AlarmCreateInfo_Dev.delayInMinutes - * delayInMinutes] or - * $ref:[PP_Ext_Alarms_AlarmCreateInfo_Dev.periodInMinutes - * periodInMinutes] to less than 1 will not be honored - * and will cause a warning. - * $ref:[PP_Ext_Alarms_AlarmCreateInfo_Dev.when when] can be set - * to less than 1 minute after "now" without warning but won't actually cause - * the alarm to fire for at least 1 minute. - * - * To help you debug your app or extension, when you've loaded it unpacked, - * there's no limit to how often the alarm can fire. - * - * @param[in] instance A PP_Instance. - * @param[in] name A string or undefined PP_Var. Optional name to - * identify this alarm. Defaults to the empty string. - * @param[in] alarm_info A PP_Var whose contents conform to the - * description of PP_Ext_Alarms_AlarmCreateInfo_Dev. Describes - * when the alarm should fire. The initial time must be specified by either - * when or delayInMinutes (but not both). If - * periodInMinutes is set, the alarm will repeat every - * periodInMinutes minutes after the initial event. If neither - * when or delayInMinutes is set for a repeating alarm, - * periodInMinutes is used as the default for - * delayInMinutes. - */ - void Create( - [in] PP_Instance instance, - [in] PP_Var name, - [in] PP_Ext_Alarms_AlarmCreateInfo_Dev alarm_info); - - /** - * Retrieves details about the specified alarm. - * - * @param[in] instance A PP_Instance. - * @param[in] name A string or undefined PP_Var. The name of the - * alarm to get. Defaults to the empty string. - * @param[out] alarm A PP_Var whose contents conform to the - * description of PP_Ext_Alarms_Alarm_Dev. - * @param[in] callback A PP_CompletionCallback to be called upon - * completion. - * - * @return An error code from pp_errors.h - */ - int32_t Get( - [in] PP_Instance instance, - [in] PP_Var name, - [out] PP_Ext_Alarms_Alarm_Dev alarm, - [in] PP_CompletionCallback callback); - - /** - * Gets an array of all the alarms. - * - * @param[in] instance A PP_Instance. - * @param[out] alarms A PP_Var whose contents conform to the - * description of PP_Ext_Alarms_Alarm_Dev_Array. - * @param[in] callback A PP_CompletionCallback to be called upon - * completion. - * - * @return An error code from pp_errors.h - */ - int32_t GetAll( - [in] PP_Instance instance, - [out] PP_Ext_Alarms_Alarm_Dev_Array alarms, - [in] PP_CompletionCallback callback); - - /** - * Clears the alarm with the given name. - * - * @param[in] instance A PP_Instance. - * @param[in] name A string or undefined PP_Var. The name of the - * alarm to clear. Defaults to the empty string. - */ - void Clear( - [in] PP_Instance instance, - [in] PP_Var name); - - /** - * Clears all alarms. - * - * @param[in] instance A PP_Instance. - */ - void ClearAll( - [in] PP_Instance instance); -}; - -/** - * Fired when an alarm has elapsed. Useful for event pages. - * - * @param[in] listener_id The listener ID. - * @param[inout] user_data The opaque pointer that was used when registering the - * listener. - * @param[in] alarm A PP_Var whose contents conform to the - * description of PP_Ext_Alarms_Alarm_Dev. The alarm that has - * elapsed. - */ -typedef void PP_Ext_Alarms_OnAlarm_Func_Dev_0_1( - [in] uint32_t listener_id, - [inout] mem_t user_data, - [in] PP_Ext_Alarms_Alarm_Dev alarm); - -#inline c -PP_INLINE struct PP_Ext_EventListener PP_Ext_Alarms_OnAlarm_Dev_0_1( - PP_Ext_Alarms_OnAlarm_Func_Dev_0_1 func, - void* user_data) { - return PP_Ext_MakeEventListener("alarms.onAlarm;0.1", - (PP_Ext_GenericFuncType)(func), user_data); -} - -#define PP_Ext_Alarms_OnAlarm_Dev PP_Ext_Alarms_OnAlarm_Dev_0_1 -#endinl diff --git a/ppapi/api/extensions/dev/ppb_events_dev.idl b/ppapi/api/extensions/dev/ppb_events_dev.idl deleted file mode 100644 index cfcc809..0000000 --- a/ppapi/api/extensions/dev/ppb_events_dev.idl +++ /dev/null @@ -1,87 +0,0 @@ -/* 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. - */ - -label Chrome { - M27 = 0.1 -}; - -/** - * Used to represent arbitrary C function pointers. Please note that usually - * the function that a PP_Ext_GenericFuncType pointer points to - * has a different signature than void (*)(). - */ -typedef void PP_Ext_GenericFuncType(); - -/** - * An event listener that can be registered with the browser and receive - * notifications via the callback function. - * - * A function is defined for each event type to return a properly-filled - * PP_Ext_EventListener struct, for example, - * PP_Ext_Alarms_OnAlarm_Dev(). - */ -[passByValue] -struct PP_Ext_EventListener { - /** - * The name of the event to register to. - */ - cstr_t event_name; - /** - * A callback function whose signature is determined by - * event_name. All calls will happen on the same thread as the - * one on which AddListener() is called. - */ - PP_Ext_GenericFuncType func; - /** - * An opaque pointer that will be passed to func. - */ - mem_t user_data; -}; - -interface PPB_Ext_Events_Dev { - /** - * Registers a listener to an event. - * - * @param[in] instance A PP_Instance identifying one instance of - * a module. - * @param[in] listener A PP_Ext_EventListener struct. - * - * @return An listener ID, or 0 if failed. - */ - uint32_t AddListener( - [in] PP_Instance instance, - [in] PP_Ext_EventListener listener); - - /** - * Deregisters a listener. - * - * @param[in] instance A PP_Instance identifying one instance of - * a module. - * @param[in] listener_id The ID returned by AddListener(). - */ - void RemoveListener( - [in] PP_Instance instance, - [in] uint32_t listener_id); -}; - -#inline c -/** - * Creates a PP_Ext_EventListener struct. - * - * Usually you should not call it directly. Instead you should call those - * functions that return a PP_Ext_EventListener struct for a - * specific event type, for example, PP_Ext_Alarms_OnAlarm_Dev(). - */ -PP_INLINE struct PP_Ext_EventListener PP_Ext_MakeEventListener( - const char* event_name, - PP_Ext_GenericFuncType func, - void* user_data) { - struct PP_Ext_EventListener listener; - listener.event_name = event_name; - listener.func = func; - listener.user_data = user_data; - return listener; -} -#endinl diff --git a/ppapi/c/extensions/dev/ppb_alarms_dev.h b/ppapi/c/extensions/dev/ppb_alarms_dev.h deleted file mode 100644 index a573527..0000000 --- a/ppapi/c/extensions/dev/ppb_alarms_dev.h +++ /dev/null @@ -1,202 +0,0 @@ -/* 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. - */ - -/* From extensions/dev/ppb_alarms_dev.idl modified Tue Mar 05 14:02:41 2013. */ - -#ifndef PPAPI_C_EXTENSIONS_DEV_PPB_ALARMS_DEV_H_ -#define PPAPI_C_EXTENSIONS_DEV_PPB_ALARMS_DEV_H_ - -#include "ppapi/c/pp_bool.h" -#include "ppapi/c/pp_completion_callback.h" -#include "ppapi/c/pp_instance.h" -#include "ppapi/c/pp_macros.h" -#include "ppapi/c/pp_stdint.h" -#include "ppapi/c/pp_var.h" - -#define PPB_EXT_ALARMS_DEV_INTERFACE_0_1 "PPB_Ext_Alarms(Dev);0.1" -#define PPB_EXT_ALARMS_DEV_INTERFACE PPB_EXT_ALARMS_DEV_INTERFACE_0_1 - -/** - * @file - * This file defines the Pepper equivalent of the chrome.alarms - * extension API. - */ - - -#include "ppapi/c/extensions/dev/ppb_events_dev.h" - -/** - * @addtogroup Typedefs - * @{ - */ -/** - * A dictionary PP_Var which contains: - * - "name" : string PP_Var - * Name of this alarm. - * - * - "scheduledTime" : double PP_Var - * Time at which this alarm was scheduled to fire, in milliseconds past the - * epoch (e.g. Date.now() + n). For performance reasons, the - * alarm may have been delayed an arbitrary amount beyond this. - * - * - "periodInMinutes" : double or undefined PP_Var - * If not undefined, the alarm is a repeating alarm and will fire again in - * periodInMinutes minutes. - */ -typedef struct PP_Var PP_Ext_Alarms_Alarm_Dev; - -/** - * A dictionary PP_Var which contains - * - "when" : double or undefined PP_Var - * Time at which the alarm should fire, in milliseconds past the epoch - * (e.g. Date.now() + n). - * - * - "delayInMinutes" : double or undefined PP_Var - * Length of time in minutes after which the - * PP_Ext_Alarms_OnAlarm_Dev event should fire. - * - * - "periodInMinutes" : double or undefined PP_Var - * If set, the PP_Ext_Alarms_OnAlarm_Dev event should fire every - * periodInMinutes minutes after the initial event specified by - * when or delayInMinutes. If not set, the alarm will - * only fire once. - */ -typedef struct PP_Var PP_Ext_Alarms_AlarmCreateInfo_Dev; - -/** - * An array PP_Var which contains elements of - * PP_Ext_Alarms_Alarm_Dev. - */ -typedef struct PP_Var PP_Ext_Alarms_Alarm_Dev_Array; -/** - * @} - */ - -/** - * @addtogroup Interfaces - * @{ - */ -struct PPB_Ext_Alarms_Dev_0_1 { - /** - * Creates an alarm. Near the time(s) specified by alarm_info, - * the PP_Ext_Alarms_OnAlarm_Dev event is fired. If there is - * another alarm with the same name (or no name if none is specified), it will - * be cancelled and replaced by this alarm. - * - * In order to reduce the load on the user's machine, Chrome limits alarms - * to at most once every 1 minute but may delay them an arbitrary amount - * more. That is, setting - * $ref:[PP_Ext_Alarms_AlarmCreateInfo_Dev.delayInMinutes - * delayInMinutes] or - * $ref:[PP_Ext_Alarms_AlarmCreateInfo_Dev.periodInMinutes - * periodInMinutes] to less than 1 will not be honored - * and will cause a warning. - * $ref:[PP_Ext_Alarms_AlarmCreateInfo_Dev.when when] can be set - * to less than 1 minute after "now" without warning but won't actually cause - * the alarm to fire for at least 1 minute. - * - * To help you debug your app or extension, when you've loaded it unpacked, - * there's no limit to how often the alarm can fire. - * - * @param[in] instance A PP_Instance. - * @param[in] name A string or undefined PP_Var. Optional name to - * identify this alarm. Defaults to the empty string. - * @param[in] alarm_info A PP_Var whose contents conform to the - * description of PP_Ext_Alarms_AlarmCreateInfo_Dev. Describes - * when the alarm should fire. The initial time must be specified by either - * when or delayInMinutes (but not both). If - * periodInMinutes is set, the alarm will repeat every - * periodInMinutes minutes after the initial event. If neither - * when or delayInMinutes is set for a repeating alarm, - * periodInMinutes is used as the default for - * delayInMinutes. - */ - void (*Create)(PP_Instance instance, - struct PP_Var name, - PP_Ext_Alarms_AlarmCreateInfo_Dev alarm_info); - /** - * Retrieves details about the specified alarm. - * - * @param[in] instance A PP_Instance. - * @param[in] name A string or undefined PP_Var. The name of the - * alarm to get. Defaults to the empty string. - * @param[out] alarm A PP_Var whose contents conform to the - * description of PP_Ext_Alarms_Alarm_Dev. - * @param[in] callback A PP_CompletionCallback to be called upon - * completion. - * - * @return An error code from pp_errors.h - */ - int32_t (*Get)(PP_Instance instance, - struct PP_Var name, - PP_Ext_Alarms_Alarm_Dev* alarm, - struct PP_CompletionCallback callback); - /** - * Gets an array of all the alarms. - * - * @param[in] instance A PP_Instance. - * @param[out] alarms A PP_Var whose contents conform to the - * description of PP_Ext_Alarms_Alarm_Dev_Array. - * @param[in] callback A PP_CompletionCallback to be called upon - * completion. - * - * @return An error code from pp_errors.h - */ - int32_t (*GetAll)(PP_Instance instance, - PP_Ext_Alarms_Alarm_Dev_Array* alarms, - struct PP_CompletionCallback callback); - /** - * Clears the alarm with the given name. - * - * @param[in] instance A PP_Instance. - * @param[in] name A string or undefined PP_Var. The name of the - * alarm to clear. Defaults to the empty string. - */ - void (*Clear)(PP_Instance instance, struct PP_Var name); - /** - * Clears all alarms. - * - * @param[in] instance A PP_Instance. - */ - void (*ClearAll)(PP_Instance instance); -}; - -typedef struct PPB_Ext_Alarms_Dev_0_1 PPB_Ext_Alarms_Dev; -/** - * @} - */ - -/** - * @addtogroup Typedefs - * @{ - */ -/** - * Fired when an alarm has elapsed. Useful for event pages. - * - * @param[in] listener_id The listener ID. - * @param[inout] user_data The opaque pointer that was used when registering the - * listener. - * @param[in] alarm A PP_Var whose contents conform to the - * description of PP_Ext_Alarms_Alarm_Dev. The alarm that has - * elapsed. - */ -typedef void (*PP_Ext_Alarms_OnAlarm_Func_Dev_0_1)( - uint32_t listener_id, - void* user_data, - PP_Ext_Alarms_Alarm_Dev alarm); -/** - * @} - */ - -PP_INLINE struct PP_Ext_EventListener PP_Ext_Alarms_OnAlarm_Dev_0_1( - PP_Ext_Alarms_OnAlarm_Func_Dev_0_1 func, - void* user_data) { - return PP_Ext_MakeEventListener("alarms.onAlarm;0.1", - (PP_Ext_GenericFuncType)(func), user_data); -} - -#define PP_Ext_Alarms_OnAlarm_Dev PP_Ext_Alarms_OnAlarm_Dev_0_1 -#endif /* PPAPI_C_EXTENSIONS_DEV_PPB_ALARMS_DEV_H_ */ - diff --git a/ppapi/c/extensions/dev/ppb_events_dev.h b/ppapi/c/extensions/dev/ppb_events_dev.h deleted file mode 100644 index 5483dc9..0000000 --- a/ppapi/c/extensions/dev/ppb_events_dev.h +++ /dev/null @@ -1,118 +0,0 @@ -/* 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. - */ - -/* From extensions/dev/ppb_events_dev.idl modified Sun Mar 10 10:37:48 2013. */ - -#ifndef PPAPI_C_EXTENSIONS_DEV_PPB_EVENTS_DEV_H_ -#define PPAPI_C_EXTENSIONS_DEV_PPB_EVENTS_DEV_H_ - -#include "ppapi/c/pp_instance.h" -#include "ppapi/c/pp_macros.h" -#include "ppapi/c/pp_stdint.h" - -#define PPB_EXT_EVENTS_DEV_INTERFACE_0_1 "PPB_Ext_Events(Dev);0.1" -#define PPB_EXT_EVENTS_DEV_INTERFACE PPB_EXT_EVENTS_DEV_INTERFACE_0_1 - -/** - * @file - */ - - -/** - * @addtogroup Typedefs - * @{ - */ -/** - * Used to represent arbitrary C function pointers. Please note that usually - * the function that a PP_Ext_GenericFuncType pointer points to - * has a different signature than void (*)(). - */ -typedef void (*PP_Ext_GenericFuncType)(void); -/** - * @} - */ - -/** - * @addtogroup Structs - * @{ - */ -/** - * An event listener that can be registered with the browser and receive - * notifications via the callback function. - * - * A function is defined for each event type to return a properly-filled - * PP_Ext_EventListener struct, for example, - * PP_Ext_Alarms_OnAlarm_Dev(). - */ -struct PP_Ext_EventListener { - /** - * The name of the event to register to. - */ - const char* event_name; - /** - * A callback function whose signature is determined by - * event_name. All calls will happen on the same thread as the - * one on which AddListener() is called. - */ - PP_Ext_GenericFuncType func; - /** - * An opaque pointer that will be passed to func. - */ - void* user_data; -}; -/** - * @} - */ - -/** - * @addtogroup Interfaces - * @{ - */ -struct PPB_Ext_Events_Dev_0_1 { - /** - * Registers a listener to an event. - * - * @param[in] instance A PP_Instance identifying one instance of - * a module. - * @param[in] listener A PP_Ext_EventListener struct. - * - * @return An listener ID, or 0 if failed. - */ - uint32_t (*AddListener)(PP_Instance instance, - struct PP_Ext_EventListener listener); - /** - * Deregisters a listener. - * - * @param[in] instance A PP_Instance identifying one instance of - * a module. - * @param[in] listener_id The ID returned by AddListener(). - */ - void (*RemoveListener)(PP_Instance instance, uint32_t listener_id); -}; - -typedef struct PPB_Ext_Events_Dev_0_1 PPB_Ext_Events_Dev; -/** - * @} - */ - -/** - * Creates a PP_Ext_EventListener struct. - * - * Usually you should not call it directly. Instead you should call those - * functions that return a PP_Ext_EventListener struct for a - * specific event type, for example, PP_Ext_Alarms_OnAlarm_Dev(). - */ -PP_INLINE struct PP_Ext_EventListener PP_Ext_MakeEventListener( - const char* event_name, - PP_Ext_GenericFuncType func, - void* user_data) { - struct PP_Ext_EventListener listener; - listener.event_name = event_name; - listener.func = func; - listener.user_data = user_data; - return listener; -} -#endif /* PPAPI_C_EXTENSIONS_DEV_PPB_EVENTS_DEV_H_ */ - diff --git a/ppapi/cpp/extensions/dev/alarms_dev.cc b/ppapi/cpp/extensions/dev/alarms_dev.cc deleted file mode 100644 index a77fed0..0000000 --- a/ppapi/cpp/extensions/dev/alarms_dev.cc +++ /dev/null @@ -1,173 +0,0 @@ -// 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. - -#include "ppapi/cpp/extensions/dev/alarms_dev.h" - -#include "ppapi/cpp/completion_callback.h" -#include "ppapi/cpp/extensions/optional.h" -#include "ppapi/cpp/extensions/to_var_converter.h" -#include "ppapi/cpp/module_impl.h" - -namespace pp { - -namespace { - -template <> const char* interface_name() { - return PPB_EXT_ALARMS_DEV_INTERFACE_0_1; -} - -} // namespace - -namespace ext { -namespace alarms { - -const char* const Alarm_Dev::kName = "name"; -const char* const Alarm_Dev::kScheduledTime = "scheduledTime"; -const char* const Alarm_Dev::kPeriodInMinutes = "periodInMinutes"; - -Alarm_Dev::Alarm_Dev() - : name(kName), - scheduled_time(kScheduledTime), - period_in_minutes(kPeriodInMinutes) { -} - -Alarm_Dev::~Alarm_Dev() { -} - -bool Alarm_Dev::Populate(const PP_Ext_Alarms_Alarm_Dev& value) { - Var var(value); - - bool result = name.Populate(var); - result = scheduled_time.Populate(var) && result; - result = period_in_minutes.Populate(var) && result; - - return result; -} - -Var Alarm_Dev::CreateVar() const { - Var var; - - name.AddTo(&var); - scheduled_time.AddTo(&var); - period_in_minutes.MayAddTo(&var); - - return var; -} - -const char* const AlarmCreateInfo_Dev::kWhen = "when"; -const char* const AlarmCreateInfo_Dev::kDelayInMinutes = "delayInMinutes"; -const char* const AlarmCreateInfo_Dev::kPeriodInMinutes = "periodInMinutes"; - -AlarmCreateInfo_Dev::AlarmCreateInfo_Dev() - : when(kWhen), - delay_in_minutes(kDelayInMinutes), - period_in_minutes(kPeriodInMinutes) { -} - -AlarmCreateInfo_Dev::~AlarmCreateInfo_Dev() { -} - -bool AlarmCreateInfo_Dev::Populate( - const PP_Ext_Alarms_AlarmCreateInfo_Dev& value) { - Var var(value); - - bool result = when.Populate(var); - result = delay_in_minutes.Populate(var) && result; - result = period_in_minutes.Populate(var) && result; - - return result; -} - -Var AlarmCreateInfo_Dev::CreateVar() const { - Var var; - - when.MayAddTo(&var); - delay_in_minutes.MayAddTo(&var); - period_in_minutes.MayAddTo(&var); - - return var; -} - -Alarms_Dev::Alarms_Dev(const InstanceHandle& instance) : instance_(instance) { -} - -Alarms_Dev::~Alarms_Dev() { -} - -void Alarms_Dev::Create(const Optional& name, - const AlarmCreateInfo_Dev& alarm_info) { - if (!has_interface()) - return; - - internal::ToVarConverter > name_var(name); - internal::ToVarConverter alarm_info_var(alarm_info); - - return get_interface()->Create( - instance_.pp_instance(), - name_var.pp_var(), - alarm_info_var.pp_var()); -} - -int32_t Alarms_Dev::Get( - const Optional& name, - const CompletionCallbackWithOutput& callback) { - if (!has_interface()) - return callback.MayForce(PP_ERROR_NOINTERFACE); - - internal::ToVarConverter > name_var(name); - - return get_interface()->Get( - instance_.pp_instance(), - name_var.pp_var(), - callback.output(), - callback.pp_completion_callback()); -} - -int32_t Alarms_Dev::GetAll( - const CompletionCallbackWithOutput >& callback) { - if (!has_interface()) - return callback.MayForce(PP_ERROR_NOINTERFACE); - - return get_interface()->GetAll( - instance_.pp_instance(), - callback.output(), - callback.pp_completion_callback()); -} - -void Alarms_Dev::Clear(const Optional& name) { - if (!has_interface()) - return; - - internal::ToVarConverter > name_var(name); - - return get_interface()->Clear( - instance_.pp_instance(), - name_var.pp_var()); -} - -void Alarms_Dev::ClearAll() { - if (!has_interface()) - return; - - return get_interface()->ClearAll( - instance_.pp_instance()); -} - -OnAlarmEvent_Dev::OnAlarmEvent_Dev( - const InstanceHandle& instance, - Listener* listener) - : internal::EventBase1(instance), - listener_(listener) { -} - -OnAlarmEvent_Dev::~OnAlarmEvent_Dev() { -} - -void OnAlarmEvent_Dev::Callback(Alarm_Dev& alarm) { - listener_->OnAlarm(alarm); -} - -} // namespace alarms -} // namespace ext -} // namespace pp diff --git a/ppapi/cpp/extensions/dev/alarms_dev.h b/ppapi/cpp/extensions/dev/alarms_dev.h deleted file mode 100644 index 762e006..0000000 --- a/ppapi/cpp/extensions/dev/alarms_dev.h +++ /dev/null @@ -1,113 +0,0 @@ -// 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_EXTENSIONS_DEV_ALARMS_DEV_H_ -#define PPAPI_CPP_EXTENSIONS_DEV_ALARMS_DEV_H_ - -#include -#include - -#include "ppapi/c/extensions/dev/ppb_alarms_dev.h" -#include "ppapi/cpp/extensions/dict_field.h" -#include "ppapi/cpp/extensions/event_base.h" -#include "ppapi/cpp/extensions/ext_output_traits.h" -#include "ppapi/cpp/instance_handle.h" -#include "ppapi/cpp/var.h" - -namespace pp { - -template -class CompletionCallbackWithOutput; - -namespace ext { - -template -class Optional; - -namespace alarms { - -// Data types ------------------------------------------------------------------ -class Alarm_Dev : public internal::OutputObjectBase { - public: - Alarm_Dev(); - ~Alarm_Dev(); - - bool Populate(const PP_Ext_Alarms_Alarm_Dev& value); - - Var CreateVar() const; - - static const char* const kName; - static const char* const kScheduledTime; - static const char* const kPeriodInMinutes; - - DictField name; - DictField scheduled_time; - OptionalDictField period_in_minutes; -}; - -class AlarmCreateInfo_Dev { - public: - AlarmCreateInfo_Dev(); - ~AlarmCreateInfo_Dev(); - - bool Populate(const PP_Ext_Alarms_AlarmCreateInfo_Dev& value); - - Var CreateVar() const; - - static const char* const kWhen; - static const char* const kDelayInMinutes; - static const char* const kPeriodInMinutes; - - OptionalDictField when; - OptionalDictField delay_in_minutes; - OptionalDictField period_in_minutes; -}; - -// Functions ------------------------------------------------------------------- -class Alarms_Dev { - public: - explicit Alarms_Dev(const InstanceHandle& instance); - ~Alarms_Dev(); - - void Create(const Optional& name, - const AlarmCreateInfo_Dev& alarm_info); - int32_t Get(const Optional& name, - const CompletionCallbackWithOutput& callback); - int32_t GetAll( - const CompletionCallbackWithOutput >& callback); - void Clear(const Optional& name); - void ClearAll(); - - private: - InstanceHandle instance_; -}; - -// Events ---------------------------------------------------------------------- -// Please see ppapi/cpp/extensions/event_base.h for how to use an event class. - -class OnAlarmEvent_Dev - : public internal::EventBase1 { - public: - class Listener { - public: - virtual ~Listener() {} - - virtual void OnAlarm(Alarm_Dev& alarm) = 0; - }; - - // |listener| is not owned by this instance and must outlive it. - OnAlarmEvent_Dev(const InstanceHandle& instance, Listener* listener); - virtual ~OnAlarmEvent_Dev(); - - private: - virtual void Callback(Alarm_Dev& alarm); - - Listener* listener_; -}; - -} // namespace alarms -} // namespace ext -} // namespace pp - -#endif // PPAPI_CPP_EXTENSIONS_DEV_ALARMS_DEV_H_ diff --git a/ppapi/cpp/extensions/dev/events_dev.cc b/ppapi/cpp/extensions/dev/events_dev.cc deleted file mode 100644 index 4b51fb5..0000000 --- a/ppapi/cpp/extensions/dev/events_dev.cc +++ /dev/null @@ -1,43 +0,0 @@ -// 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. - -#include "ppapi/cpp/extensions/dev/events_dev.h" - -#include "ppapi/c/extensions/dev/ppb_events_dev.h" -#include "ppapi/cpp/module_impl.h" - -namespace pp { - -namespace { - -template <> const char* interface_name() { - return PPB_EXT_EVENTS_DEV_INTERFACE_0_1; -} - -} // namespace - -namespace ext { -namespace events { - -// static -uint32_t Events_Dev::AddListener(PP_Instance instance, - const PP_Ext_EventListener& listener) { - if (!has_interface()) - return 0; - return get_interface()->AddListener(instance, - listener); -} - -// static -void Events_Dev::RemoveListener(PP_Instance instance, - uint32_t listener_id) { - if (has_interface()) { - get_interface()->RemoveListener(instance, - listener_id); - } -} - -} // namespace events -} // namespace ext -} // namespace pp diff --git a/ppapi/cpp/extensions/dev/events_dev.h b/ppapi/cpp/extensions/dev/events_dev.h deleted file mode 100644 index e816ca5..0000000 --- a/ppapi/cpp/extensions/dev/events_dev.h +++ /dev/null @@ -1,34 +0,0 @@ -// 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_EXTENSIONS_DEV_EVENTS_DEV_H_ -#define PPAPI_CPP_EXTENSIONS_DEV_EVENTS_DEV_H_ - -#include "ppapi/c/pp_instance.h" -#include "ppapi/c/pp_stdint.h" - -struct PP_Ext_EventListener; - -namespace pp { -namespace ext { -namespace events { - -// This is a simple wrapper of the PPB_Ext_Events_Dev interface. -// -// Usually you don't have to directly use this interface. Instead, you could -// use those more object-oriented event classes. Please see -// ppapi/cpp/extensions/event_base.h for more details. -class Events_Dev { - public: - static uint32_t AddListener(PP_Instance instance, - const PP_Ext_EventListener& listener); - - static void RemoveListener(PP_Instance instance, uint32_t listener_id); -}; - -} // namespace events -} // namespace ext -} // namespace pp - -#endif // PPAPI_CPP_EXTENSIONS_DEV_EVENTS_DEV_H_ diff --git a/ppapi/cpp/extensions/dict_field.h b/ppapi/cpp/extensions/dict_field.h deleted file mode 100644 index d137025..0000000 --- a/ppapi/cpp/extensions/dict_field.h +++ /dev/null @@ -1,69 +0,0 @@ -// 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_EXTENSIONS_DICT_FIELD_H_ -#define PPAPI_CPP_EXTENSIONS_DICT_FIELD_H_ - -#include - -#include "ppapi/cpp/extensions/optional.h" - -namespace pp { - -class Var; - -namespace ext { - -template -class DictField { - public: - explicit DictField(const std::string& in_key) : key(in_key), value() { - } - - ~DictField() { - } - - // Adds this field to the dictionary var. - bool AddTo(Var* /* var */) const { - // TODO(yzshen): change Var to DictionaryVar and add support. - return true; - } - - bool Populate(const Var& /* var */) { - // TODO(yzshen): change Var to DictionaryVar and add support. - return true; - } - - const std::string key; - T value; -}; - -template -class OptionalDictField { - public: - explicit OptionalDictField(const std::string& in_key) : key(in_key) { - } - - ~OptionalDictField() { - } - - // Adds this field to the dictionary var, if |value| has been set. - bool MayAddTo(Var* /* var */) const { - // TODO(yzshen): change Var to DictionaryVar and add support - return true; - } - - bool Populate(const Var& /* var */) { - // TODO(yzshen): change Var to DictionaryVar and add support. - return true; - } - - const std::string key; - Optional value; -}; - -} // namespace ext -} // namespace pp - -#endif // PPAPI_CPP_EXTENSIONS_DICT_FIELD_H_ diff --git a/ppapi/cpp/extensions/event_base.cc b/ppapi/cpp/extensions/event_base.cc deleted file mode 100644 index 210b213..0000000 --- a/ppapi/cpp/extensions/event_base.cc +++ /dev/null @@ -1,44 +0,0 @@ -// 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. - -#include "ppapi/cpp/extensions/event_base.h" - -#include "ppapi/cpp/extensions/dev/events_dev.h" - -namespace pp { -namespace ext { -namespace internal { - -GenericEventBase::GenericEventBase( - const InstanceHandle& instance, - const PP_Ext_EventListener& pp_listener) - : instance_(instance), - listener_id_(0), - pp_listener_(pp_listener) { -} - -GenericEventBase::~GenericEventBase() { - StopListening(); -} - -bool GenericEventBase::StartListening() { - if (IsListening()) - return true; - - listener_id_ = events::Events_Dev::AddListener(instance_.pp_instance(), - pp_listener_); - return IsListening(); -} - -void GenericEventBase::StopListening() { - if (!IsListening()) - return; - - events::Events_Dev::RemoveListener(instance_.pp_instance(), listener_id_); - listener_id_ = 0; -} - -} // namespace internal -} // namespace ext -} // namespace pp diff --git a/ppapi/cpp/extensions/event_base.h b/ppapi/cpp/extensions/event_base.h deleted file mode 100644 index 8a65fb0..0000000 --- a/ppapi/cpp/extensions/event_base.h +++ /dev/null @@ -1,232 +0,0 @@ -// 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_EXTENSIONS_EVENT_BASE_H_ -#define PPAPI_CPP_EXTENSIONS_EVENT_BASE_H_ - -#include "ppapi/c/extensions/dev/ppb_events_dev.h" -#include "ppapi/c/pp_macros.h" -#include "ppapi/c/pp_stdint.h" -#include "ppapi/c/pp_var.h" -#include "ppapi/cpp/extensions/from_var_converter.h" -#include "ppapi/cpp/instance_handle.h" -#include "ppapi/cpp/logging.h" - -namespace pp { -namespace ext { -namespace internal { - -// This file contains base classes for events. Usually you don't need to use -// them directly. -// -// For each event type, there is a corresponding event class derived from -// EventBase[0-3]. The event class defines a Listener interface and exposes the -// public methods of GenericEventBase. -// -// Take pp::ext::alarms::OnAlarmEvent_Dev as example, your code to listen to the -// event would look like this: -// -// class MyListener : public pp::ext::alarms::OnAlarmEvent_Dev { -// ... -// // The parameter is a non-const reference so you could directly modify it -// // if necessary. -// virtual void OnAlarm(Alarm_Dev& alarm) { -// ...handle the event... -// } -// }; -// -// MyListener on_alarm_listener; -// // The listener is not owned by the event and must outlive it. -// pp::ext::alarms::OnAlarmEvent_Dev on_alarm(instance, &on_alarm_listener); -// on_alarm.StartListening(); -// ... -// // It is guaranteed that |on_alarm_listener| won't get called after -// // |on_alarm| goes away. So this step is optional. -// on_alarm.StopListening(); - -class GenericEventBase { - public: - bool StartListening(); - void StopListening(); - - bool IsListening() const { return listener_id_ != 0; } - uint32_t listener_id() const { return listener_id_; } - - protected: - GenericEventBase(const InstanceHandle& instance, - const PP_Ext_EventListener& pp_listener); - ~GenericEventBase(); - - InstanceHandle instance_; - uint32_t listener_id_; - const PP_Ext_EventListener pp_listener_; - - private: - // Disallow copying and assignment. - GenericEventBase(const GenericEventBase&); - GenericEventBase& operator=(const GenericEventBase&); -}; - -// EventBase[0-3] are event base classes which can be instantiated with a -// pointer to a PP_Ext_EventListener creation function and the input parameter -// types of the listener callback. -// -// For example, EvenBase1 deals with -// the event type defined by the PP_Ext_Alarms_OnAlarm_Dev function pointer. And -// it defines a pure virtual method as the listener callback: -// virtual void Callback(Alarm_Dev&) = 0; - -typedef PP_Ext_EventListener (*CreatePPEventListener0)( - void (*)(uint32_t, void*), void*); -template -class EventBase0 : public GenericEventBase { - public: - explicit EventBase0(const InstanceHandle& instance) - : PP_ALLOW_THIS_IN_INITIALIZER_LIST( - GenericEventBase(instance, - kCreatePPEventListener0(&CallbackThunk, this))) { - } - - virtual ~EventBase0() {} - - private: - virtual void Callback() = 0; - - static void CallbackThunk(uint32_t listener_id, void* user_data) { - EventBase0* event_base = - static_cast*>(user_data); - PP_DCHECK(listener_id == event_base->listener_id_); - // Suppress unused variable warnings. - static_cast(listener_id); - - event_base->Callback(); - } - - // Disallow copying and assignment. - EventBase0(const EventBase0&); - EventBase0& operator=( - const EventBase0&); -}; - -typedef PP_Ext_EventListener (*CreatePPEventListener1)( - void (*)(uint32_t, void*, PP_Var), void*); -template -class EventBase1 : public GenericEventBase { - public: - explicit EventBase1(const InstanceHandle& instance) - : PP_ALLOW_THIS_IN_INITIALIZER_LIST( - GenericEventBase(instance, - kCreatePPEventListener1(&CallbackThunk, this))) { - } - - virtual ~EventBase1() {} - - private: - virtual void Callback(A&) = 0; - - static void CallbackThunk(uint32_t listener_id, - void* user_data, - PP_Var var_a) { - EventBase1* event_base = - static_cast*>(user_data); - PP_DCHECK(listener_id == event_base->listener_id_); - // Suppress unused variable warnings. - static_cast(listener_id); - - FromVarConverter a(var_a); - event_base->Callback(a.value()); - } - - // Disallow copying and assignment. - EventBase1(const EventBase1&); - EventBase1& operator=( - const EventBase1&); -}; - -typedef PP_Ext_EventListener (*CreatePPEventListener2)( - void (*)(uint32_t, void*, PP_Var, PP_Var), void*); -template -class EventBase2 : public GenericEventBase { - public: - explicit EventBase2(const InstanceHandle& instance) - : PP_ALLOW_THIS_IN_INITIALIZER_LIST( - GenericEventBase(instance, - kCreatePPEventListener2(&CallbackThunk, this))) { - } - - virtual ~EventBase2() {} - - private: - virtual void Callback(A&, B&) = 0; - - static void CallbackThunk(uint32_t listener_id, - void* user_data, - PP_Var var_a, - PP_Var var_b) { - EventBase2* event_base = - static_cast*>(user_data); - PP_DCHECK(listener_id == event_base->listener_id_); - // Suppress unused variable warnings. - static_cast(listener_id); - - FromVarConverter a(var_a); - FromVarConverter b(var_b); - event_base->Callback(a.value(), b.value()); - } - - // Disallow copying and assignment. - EventBase2(const EventBase2&); - EventBase2& operator=( - const EventBase2&); -}; - -typedef PP_Ext_EventListener (*CreatePPEventListener3)( - void (*)(uint32_t, void*, PP_Var, PP_Var, PP_Var), void*); -template -class EventBase3 : public GenericEventBase { - public: - explicit EventBase3(const InstanceHandle& instance) - : PP_ALLOW_THIS_IN_INITIALIZER_LIST( - GenericEventBase(instance, - kCreatePPEventListener3(&CallbackThunk, this))) { - } - - virtual ~EventBase3() {} - - private: - virtual void Callback(A&, B&, C&) = 0; - - static void CallbackThunk(uint32_t listener_id, - void* user_data, - PP_Var var_a, - PP_Var var_b, - PP_Var var_c) { - EventBase3* event_base = - static_cast*>(user_data); - PP_DCHECK(listener_id == event_base->listener_id_); - // Suppress unused variable warnings. - static_cast(listener_id); - - FromVarConverter a(var_a); - FromVarConverter b(var_b); - FromVarConverter c(var_c); - event_base->Callback(a.value(), b.value(), c.value()); - } - - // Disallow copying and assignment. - EventBase3(const EventBase3&); - EventBase3& operator=( - const EventBase3&); -}; - -} // namespace internal -} // namespace ext -} // namespace pp - -#endif // PPAPI_CPP_EXTENSIONS_EVENT_BASE_H_ diff --git a/ppapi/cpp/extensions/ext_output_traits.h b/ppapi/cpp/extensions/ext_output_traits.h deleted file mode 100644 index b49ff9f..0000000 --- a/ppapi/cpp/extensions/ext_output_traits.h +++ /dev/null @@ -1,133 +0,0 @@ -// 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_EXTENSIONS_OUTPUT_TRAITS_H_ -#define PPAPI_CPP_EXTENSIONS_OUTPUT_TRAITS_H_ - -#include - -#include "ppapi/c/pp_var.h" -#include "ppapi/cpp/extensions/from_var_converter.h" -#include "ppapi/cpp/logging.h" -#include "ppapi/cpp/pass_ref.h" -#include "ppapi/cpp/var.h" - -namespace pp { -namespace ext { -namespace internal { - -// Base class for all those types within the pp::ext namespace that are used -// with CompletionCallbackWithOutput. This class doesn't do anything itself, -// but it affects the behavior of CallbackOutputTraits for all its subclasses. -// -// TODO(yzshen): Within pp::ext, basic types such as std::string or double may -// be used with CompletionCallbackWithOutput as well. This approach doesn't -// work for them. One way is to refactor CallbackOutputTraits to consider not -// only the output C++ object type, but also the output parameter type that the -// C interface uses. And then we can remove this class. -class OutputObjectBase { -}; - -template -class VarOutputAdapterWithStorage { - public: - VarOutputAdapterWithStorage() : pp_var_(PP_MakeUndefined()) { - } - - ~VarOutputAdapterWithStorage() { - PP_DCHECK(pp_var_.type == PP_VARTYPE_UNDEFINED); - } - - PP_Var& pp_var() { return pp_var_; } - - T& output() { - converter_.Set(PASS_REF, pp_var_); - pp_var_ = PP_MakeUndefined(); - return converter_.value(); - } - - private: - PP_Var pp_var_; - FromVarConverter converter_; - - // Disallow copying and assignment. - VarOutputAdapterWithStorage(const VarOutputAdapterWithStorage&); - VarOutputAdapterWithStorage& operator=( - const VarOutputAdapterWithStorage&); -}; - -template -struct ExtensionsCallbackOutputTraits { - typedef PP_Var* APIArgType; - typedef VarOutputAdapterWithStorage StorageType; - - static inline APIArgType StorageToAPIArg(StorageType& t) { - return &t.pp_var(); - } - - // This must be called exactly once to consume the one PP_Var reference - // assigned to us by the browser. - static inline T& StorageToPluginArg(StorageType& t) { - return t.output(); - } -}; - -// This class provides storage for a PP_Var and a vector of objects which are -// of type T. The PP_Var is used as an output parameter to recevie an array var -// from the browser. Each element in the array var is converted to a T object, -// using FromVarConverter, and stores in the vector. -template -class ArrayVarOutputAdapterWithStorage { - public: - ArrayVarOutputAdapterWithStorage() : pp_var_(PP_MakeUndefined()) { - } - - ~ArrayVarOutputAdapterWithStorage() { - PP_DCHECK(pp_var_.type == PP_VARTYPE_UNDEFINED); - } - - PP_Var& pp_var() { return pp_var_; } - - std::vector& output() { - PP_DCHECK(output_storage_.empty()); - - // TODO(yzshen): Add support for ArrayVar and read the contents from - // |pp_var_| and put into |output_storage_|. - Var auto_release(PASS_REF, pp_var_); - pp_var_ = PP_MakeUndefined(); - - return output_storage_; - } - - private: - PP_Var pp_var_; - std::vector output_storage_; - - // Disallow copying and assignment. - ArrayVarOutputAdapterWithStorage(const ArrayVarOutputAdapterWithStorage&); - ArrayVarOutputAdapterWithStorage& operator=( - const ArrayVarOutputAdapterWithStorage&); -}; - -template -struct ExtensionsVectorCallbackOutputTraits { - typedef PP_Var* APIArgType; - typedef ArrayVarOutputAdapterWithStorage StorageType; - - static inline APIArgType StorageToAPIArg(StorageType& t) { - return &t.pp_var(); - } - - // This must be called exactly once to consume the one PP_Var reference - // assigned to us by the browser. - static inline std::vector& StorageToPluginArg(StorageType& t) { - return t.output(); - } -}; - -} // namespace internal -} // namespace ext -} // namespace pp - -#endif // PPAPI_CPP_EXTENSIONS_OUTPUT_TRAITS_H_ diff --git a/ppapi/cpp/extensions/from_var_converter.h b/ppapi/cpp/extensions/from_var_converter.h deleted file mode 100644 index 7fe0ac5..0000000 --- a/ppapi/cpp/extensions/from_var_converter.h +++ /dev/null @@ -1,100 +0,0 @@ -// 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_EXTENSIONS_FROM_VAR_CONVERTOR_H_ -#define PPAPI_CPP_EXTENSIONS_FROM_VAR_CONVERTOR_H_ - -#include - -#include "ppapi/c/pp_var.h" -#include "ppapi/cpp/logging.h" -#include "ppapi/cpp/pass_ref.h" -#include "ppapi/cpp/var.h" - -namespace pp { -namespace ext { -namespace internal { - -template -class FromVarConverterBase { - public: - T& value() { return value_; } - - protected: - FromVarConverterBase() : value_() { - } - - explicit FromVarConverterBase(const T& value) : value_(value) { - } - - ~FromVarConverterBase() { - } - - T value_; -}; - -template -class FromVarConverter : public FromVarConverterBase { - public: - FromVarConverter() { - } - - FromVarConverter(const PP_Var& var) { - Set(PASS_REF, Var(var).Detach()); - } - - ~FromVarConverter() { - } - - void Set(PassRef pass_ref, const PP_Var& var) { - Var auto_release(pass_ref, var); - - bool succeeded = FromVarConverterBase::value_.Populate(var); - // Suppress unused variable warnings. - static_cast(succeeded); - PP_DCHECK(succeeded); - } -}; - -template <> -class FromVarConverter : public FromVarConverterBase { - public: - FromVarConverter() { - } - - FromVarConverter(const PP_Var& var) { - Set(PASS_REF, Var(var).Detach()); - } - - ~FromVarConverter() { - } - - void Set(PassRef pass_ref, const PP_Var& var) { - FromVarConverterBase::value_ = Var(pass_ref, var).AsString(); - } -}; - -template <> -class FromVarConverter : public FromVarConverterBase { - public: - FromVarConverter() { - } - - FromVarConverter(const PP_Var& var) { - Set(PASS_REF, Var(var).Detach()); - } - - ~FromVarConverter() { - } - - void Set(PassRef pass_ref, const PP_Var& var) { - FromVarConverterBase::value_ = Var(pass_ref, var).AsDouble(); - } -}; - -} // namespace internal -} // namespace ext -} // namespace pp - -#endif // PPAPI_CPP_EXTENSIONS_FROM_VAR_CONVERTOR_H_ diff --git a/ppapi/cpp/extensions/optional.h b/ppapi/cpp/extensions/optional.h deleted file mode 100644 index cd6f40b..0000000 --- a/ppapi/cpp/extensions/optional.h +++ /dev/null @@ -1,91 +0,0 @@ -// 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_EXTENSIONS_OPTIONAL_H_ -#define PPAPI_CPP_EXTENSIONS_OPTIONAL_H_ - -namespace pp { -namespace ext { - -template -class Optional { - public: - Optional() : value_(NULL) { - } - // Takes ownership of |value|. - explicit Optional(T* value) : value_(value) { - } - Optional(const T& value) : value_(new T(value)) { - } - Optional(const Optional& other) - : value_(other.value_ ? new T(*other.value_) : NULL) { - } - - ~Optional() { - Reset(); - } - - Optional& operator=(const T& other) { - if (value_ == &other) - return *this; - - Reset(); - value_ = new T(other); - - return *this; - } - - Optional& operator=(const Optional& other) { - if (value_ == other.value_) - return *this; - - Reset(); - if (other.value_) - value_ = new T(*other.value_); - - return *this; - } - - bool IsSet() const { - return !!value_; - } - - T* Get() const { - return value_; - } - - // Should only be used when IsSet() is true. - T& operator*() const { - return *value_; - } - - // Should only be used when IsSet() is true. - T* operator->() const { - PP_DCHECK(value_); - return value_; - } - - // Takes ownership of |value|. - void Set(T* value) { - if (value == value_) - return; - - Reset(); - *value_ = value; - } - - void Reset() { - T* value = value_; - value_ = NULL; - delete value; - } - - private: - T* value_; -}; - -} // namespace ext -} // namespace pp - -#endif // PPAPI_CPP_EXTENSIONS_OPTIONAL_H_ diff --git a/ppapi/cpp/extensions/to_var_converter.h b/ppapi/cpp/extensions/to_var_converter.h deleted file mode 100644 index e221ab9..0000000 --- a/ppapi/cpp/extensions/to_var_converter.h +++ /dev/null @@ -1,89 +0,0 @@ -// 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_EXTENSIONS_TO_VAR_CONVERTOR_H_ -#define PPAPI_CPP_EXTENSIONS_TO_VAR_CONVERTOR_H_ - -#include - -#include "ppapi/c/pp_var.h" -#include "ppapi/cpp/extensions/optional.h" -#include "ppapi/cpp/var.h" - -namespace pp { -namespace ext { -namespace internal { - -class ToVarConverterBase { - public: - PP_Var pp_var() const { - return var_.pp_var(); - } - - protected: - ToVarConverterBase() { - } - - explicit ToVarConverterBase(const PP_Var& var) : var_(var) { - } - - explicit ToVarConverterBase(const Var& var): var_(var) { - } - - ~ToVarConverterBase() { - } - - Var var_; -}; - -template -class ToVarConverter : public ToVarConverterBase { - public: - explicit ToVarConverter(const T& object) - : ToVarConverterBase(object.CreateVar()) { - } - - ~ToVarConverter() { - } -}; - -template -class ToVarConverter > : public ToVarConverterBase { - public: - explicit ToVarConverter(const Optional& object) - : ToVarConverterBase( - object.IsSet() ? ToVarConverter(*object).pp_var() : - PP_MakeUndefined()) { - } - - ~ToVarConverter() { - } -}; - -template <> -class ToVarConverter : public ToVarConverterBase { - public: - explicit ToVarConverter(const std::string& object) - : ToVarConverterBase(Var(object)) { - } - - ~ToVarConverter() { - } -}; - -template <> -class ToVarConverter : public ToVarConverterBase { - public: - explicit ToVarConverter(double object) : ToVarConverterBase(Var(object)) { - } - - ~ToVarConverter() { - } -}; - -} // namespace internal -} // namespace ext -} // namespace pp - -#endif // PPAPI_CPP_EXTENSIONS_TO_VAR_CONVERTOR_H_ diff --git a/ppapi/cpp/output_traits.h b/ppapi/cpp/output_traits.h index 889c612..cc04330 100644 --- a/ppapi/cpp/output_traits.h +++ b/ppapi/cpp/output_traits.h @@ -10,8 +10,6 @@ #include "ppapi/c/pp_resource.h" #include "ppapi/cpp/array_output.h" #include "ppapi/cpp/dev/directory_entry_dev.h" -#include "ppapi/cpp/extensions/ext_output_traits.h" -#include "ppapi/cpp/resource.h" /// @file /// This file defines internal templates for defining how data is passed to the @@ -25,6 +23,7 @@ struct PP_Var; namespace pp { +class Resource; class Var; namespace internal { @@ -118,20 +117,16 @@ struct ResourceCallbackOutputTraits { }; // The general templatized base class for all CallbackOutputTraits. This class -// covers resources, extensions API output objects and POD (ints, structs, etc.) -// by inheriting from the appropriate base class depending on whether the given -// type derives from pp::Resource or ext::internal::OutputObjectBase. This trick -// allows us to do this once rather than writing specializations for every -// object type. +// covers both resources and POD (ints, structs, etc.) by inheriting from the +// appropriate base class depending on whether the given type derives from +// pp::Resource. This trick allows us to do this once rather than writing +// specializations for every resource object type. template struct CallbackOutputTraits - : public InheritIf, - IsBaseOf::value>, - public InheritIf, - IsBaseOf::value>, - public InheritIf, - !IsBaseOf::value && - !IsBaseOf::value> { + : public InheritIf, + !IsBaseOf::value>, + public InheritIf, + IsBaseOf::value> { }; // A specialization of CallbackOutputTraits for pp::Var output parameters. @@ -204,21 +199,17 @@ struct ResourceVectorCallbackOutputTraits { } }; -// Specialization of CallbackOutputTraits for vectors. This struct covers arrays -// of resources, extensions API output objects and POD (ints, structs, etc.) by -// inheriting from the appropriate base class depending on whether the given -// type derives from pp::Resource or ext::internal::OutputObjectBase. This trick -// allows us to do this once rather than writing specializations for every -// object type. +// Specialization of CallbackOutputTraits for vectors. This struct covers both +// arrays of resources and arrays of POD (ints, structs, etc.) by inheriting +// from the appropriate base class depending on whether the given type derives +// from pp::Resource. This trick allows us to do this once rather than writing +// specializations for every resource object type. template struct CallbackOutputTraits< std::vector > - : public InheritIf, - IsBaseOf::value>, - public InheritIf, - IsBaseOf::value>, - public InheritIf, - !IsBaseOf::value && - !IsBaseOf::value> { + : public InheritIf, + !IsBaseOf::value>, + public InheritIf, + IsBaseOf::value> { }; // A specialization of CallbackOutputTraits to provide the callback system diff --git a/ppapi/cpp/var.cc b/ppapi/cpp/var.cc index 09a8fe3..7fc67f5 100644 --- a/ppapi/cpp/var.cc +++ b/ppapi/cpp/var.cc @@ -101,18 +101,6 @@ Var::Var(const std::string& utf8_str) { is_managed_ = true; } - -Var::Var(const PP_Var& var) { - var_ = var; - is_managed_ = true; - if (NeedsRefcounting(var_)) { - if (has_interface()) - get_interface()->AddRef(var_); - else - var_.type = PP_VARTYPE_NULL; - } -} - Var::Var(const Var& other) { var_ = other.var_; is_managed_ = true; diff --git a/ppapi/cpp/var.h b/ppapi/cpp/var.h index d114054..437eed9 100644 --- a/ppapi/cpp/var.h +++ b/ppapi/cpp/var.h @@ -55,14 +55,11 @@ class Var { /// /// You will not normally need to use this constructor because /// the reference count will not normally be incremented for you. - Var(PassRef, const PP_Var& var) { + Var(PassRef, PP_Var var) { var_ = var; is_managed_ = true; } - /// A constructor that increments the reference count. - explicit Var(const PP_Var& var); - struct DontManage {}; // TODO(brettw): remove DontManage when this bug is fixed @@ -73,7 +70,7 @@ class Var { /// increased or decreased by this class instance. /// /// @param[in] var A Var. - Var(DontManage, const PP_Var& var) { + Var(DontManage, PP_Var var) { var_ = var; is_managed_ = false; } diff --git a/ppapi/generators/idl_parser.py b/ppapi/generators/idl_parser.py index 95b0ddb..b027a63 100755 --- a/ppapi/generators/idl_parser.py +++ b/ppapi/generators/idl_parser.py @@ -1170,8 +1170,7 @@ def TestVersionFiles(filter): return errs -default_dirs = ['.', 'trusted', 'dev', 'private', 'extensions', - 'extensions/dev'] +default_dirs = ['.', 'trusted', 'dev', 'private'] def ParseFiles(filenames): parser = IDLParser() filenodes = [] diff --git a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c index 5177097..57cfc8e 100644 --- a/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c +++ b/ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c @@ -41,8 +41,6 @@ #include "ppapi/c/dev/ppp_video_decoder_dev.h" #include "ppapi/c/dev/ppp_widget_dev.h" #include "ppapi/c/dev/ppp_zoom_dev.h" -#include "ppapi/c/extensions/dev/ppb_alarms_dev.h" -#include "ppapi/c/extensions/dev/ppb_events_dev.h" #include "ppapi/c/ppb_audio.h" #include "ppapi/c/ppb_audio_config.h" #include "ppapi/c/ppb_console.h" @@ -265,8 +263,6 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_Flash_BrowserOperations_1 static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_Flash_BrowserOperations_1_2; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_Flash_BrowserOperations_1_3; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_Instance_Private_0_1; -static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Ext_Alarms_Dev_0_1; -static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Ext_Events_Dev_0_1; /* END Declarations for all Wrapper Infos. */ /* Not generating wrapper methods for PPB_Audio_1_0 */ @@ -3621,56 +3617,6 @@ static struct PP_Var Pnacl_M18_PPP_Instance_Private_GetInstanceObject(PP_Instanc /* End wrapper methods for PPP_Instance_Private_0_1 */ -/* Begin wrapper methods for PPB_Ext_Alarms_Dev_0_1 */ - -static __attribute__((pnaclcall)) -void Pnacl_M27_PPB_Ext_Alarms_Dev_Create(PP_Instance instance, struct PP_Var name, PP_Ext_Alarms_AlarmCreateInfo_Dev alarm_info) { - const struct PPB_Ext_Alarms_Dev_0_1 *iface = Pnacl_WrapperInfo_PPB_Ext_Alarms_Dev_0_1.real_iface; - iface->Create(instance, name, alarm_info); -} - -static __attribute__((pnaclcall)) -int32_t Pnacl_M27_PPB_Ext_Alarms_Dev_Get(PP_Instance instance, struct PP_Var name, PP_Ext_Alarms_Alarm_Dev* alarm, struct PP_CompletionCallback callback) { - const struct PPB_Ext_Alarms_Dev_0_1 *iface = Pnacl_WrapperInfo_PPB_Ext_Alarms_Dev_0_1.real_iface; - return iface->Get(instance, name, alarm, callback); -} - -static __attribute__((pnaclcall)) -int32_t Pnacl_M27_PPB_Ext_Alarms_Dev_GetAll(PP_Instance instance, PP_Ext_Alarms_Alarm_Dev_Array* alarms, struct PP_CompletionCallback callback) { - const struct PPB_Ext_Alarms_Dev_0_1 *iface = Pnacl_WrapperInfo_PPB_Ext_Alarms_Dev_0_1.real_iface; - return iface->GetAll(instance, alarms, callback); -} - -static __attribute__((pnaclcall)) -void Pnacl_M27_PPB_Ext_Alarms_Dev_Clear(PP_Instance instance, struct PP_Var name) { - const struct PPB_Ext_Alarms_Dev_0_1 *iface = Pnacl_WrapperInfo_PPB_Ext_Alarms_Dev_0_1.real_iface; - iface->Clear(instance, name); -} - -static __attribute__((pnaclcall)) -void Pnacl_M27_PPB_Ext_Alarms_Dev_ClearAll(PP_Instance instance) { - const struct PPB_Ext_Alarms_Dev_0_1 *iface = Pnacl_WrapperInfo_PPB_Ext_Alarms_Dev_0_1.real_iface; - iface->ClearAll(instance); -} - -/* End wrapper methods for PPB_Ext_Alarms_Dev_0_1 */ - -/* Begin wrapper methods for PPB_Ext_Events_Dev_0_1 */ - -static __attribute__((pnaclcall)) -uint32_t Pnacl_M27_PPB_Ext_Events_Dev_AddListener(PP_Instance instance, struct PP_Ext_EventListener listener) { - const struct PPB_Ext_Events_Dev_0_1 *iface = Pnacl_WrapperInfo_PPB_Ext_Events_Dev_0_1.real_iface; - return iface->AddListener(instance, listener); -} - -static __attribute__((pnaclcall)) -void Pnacl_M27_PPB_Ext_Events_Dev_RemoveListener(PP_Instance instance, uint32_t listener_id) { - const struct PPB_Ext_Events_Dev_0_1 *iface = Pnacl_WrapperInfo_PPB_Ext_Events_Dev_0_1.real_iface; - iface->RemoveListener(instance, listener_id); -} - -/* End wrapper methods for PPB_Ext_Events_Dev_0_1 */ - /* Not generating wrapper interface for PPB_Audio_1_0 */ /* Not generating wrapper interface for PPB_AudioConfig_1_0 */ @@ -4510,19 +4456,6 @@ struct PPP_Instance_Private_0_1 Pnacl_Wrappers_PPP_Instance_Private_0_1 = { .GetInstanceObject = (struct PP_Var (*)(PP_Instance instance))&Pnacl_M18_PPP_Instance_Private_GetInstanceObject }; -struct PPB_Ext_Alarms_Dev_0_1 Pnacl_Wrappers_PPB_Ext_Alarms_Dev_0_1 = { - .Create = (void (*)(PP_Instance instance, struct PP_Var name, PP_Ext_Alarms_AlarmCreateInfo_Dev alarm_info))&Pnacl_M27_PPB_Ext_Alarms_Dev_Create, - .Get = (int32_t (*)(PP_Instance instance, struct PP_Var name, PP_Ext_Alarms_Alarm_Dev* alarm, struct PP_CompletionCallback callback))&Pnacl_M27_PPB_Ext_Alarms_Dev_Get, - .GetAll = (int32_t (*)(PP_Instance instance, PP_Ext_Alarms_Alarm_Dev_Array* alarms, struct PP_CompletionCallback callback))&Pnacl_M27_PPB_Ext_Alarms_Dev_GetAll, - .Clear = (void (*)(PP_Instance instance, struct PP_Var name))&Pnacl_M27_PPB_Ext_Alarms_Dev_Clear, - .ClearAll = (void (*)(PP_Instance instance))&Pnacl_M27_PPB_Ext_Alarms_Dev_ClearAll -}; - -struct PPB_Ext_Events_Dev_0_1 Pnacl_Wrappers_PPB_Ext_Events_Dev_0_1 = { - .AddListener = (uint32_t (*)(PP_Instance instance, struct PP_Ext_EventListener listener))&Pnacl_M27_PPB_Ext_Events_Dev_AddListener, - .RemoveListener = (void (*)(PP_Instance instance, uint32_t listener_id))&Pnacl_M27_PPB_Ext_Events_Dev_RemoveListener -}; - static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Audio_1_0 = { .iface_macro = PPB_AUDIO_INTERFACE_1_0, .wrapped_iface = NULL /* Still need slot for real_iface */, @@ -5345,18 +5278,6 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPP_Instance_Private_0_1 = { .real_iface = NULL }; -static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Ext_Alarms_Dev_0_1 = { - .iface_macro = PPB_EXT_ALARMS_DEV_INTERFACE_0_1, - .wrapped_iface = (void *) &Pnacl_Wrappers_PPB_Ext_Alarms_Dev_0_1, - .real_iface = NULL -}; - -static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Ext_Events_Dev_0_1 = { - .iface_macro = PPB_EXT_EVENTS_DEV_INTERFACE_0_1, - .wrapped_iface = (void *) &Pnacl_Wrappers_PPB_Ext_Events_Dev_0_1, - .real_iface = NULL -}; - static struct __PnaclWrapperInfo *s_ppb_wrappers[] = { &Pnacl_WrapperInfo_PPB_Audio_1_0, &Pnacl_WrapperInfo_PPB_AudioConfig_1_0, @@ -5472,8 +5393,6 @@ static struct __PnaclWrapperInfo *s_ppb_wrappers[] = { &Pnacl_WrapperInfo_PPB_UDPSocket_Private_0_4, &Pnacl_WrapperInfo_PPB_UMA_Private_0_1, &Pnacl_WrapperInfo_PPB_X509Certificate_Private_0_1, - &Pnacl_WrapperInfo_PPB_Ext_Alarms_Dev_0_1, - &Pnacl_WrapperInfo_PPB_Ext_Events_Dev_0_1, NULL }; diff --git a/ppapi/ppapi_sources.gypi b/ppapi/ppapi_sources.gypi index fad4e19..39d42d8 100644 --- a/ppapi/ppapi_sources.gypi +++ b/ppapi/ppapi_sources.gypi @@ -131,10 +131,6 @@ 'c/trusted/ppb_image_data_trusted.h', 'c/trusted/ppb_url_loader_trusted.h', 'c/trusted/ppp_broker.h', - - # Extensions dev interfaces. - 'c/extensions/dev/ppb_alarms_dev.h', - 'c/extensions/dev/ppb_events_dev.h', ], 'cpp_source_files': [ 'cpp/array_output.cc', @@ -309,21 +305,6 @@ 'cpp/trusted/file_io_trusted.cc', 'cpp/trusted/file_io_trusted.h', - # Extensions interfaces. - 'cpp/extensions/dict_field.h', - 'cpp/extensions/event_base.cc', - 'cpp/extensions/event_base.h', - 'cpp/extensions/ext_output_traits.h', - 'cpp/extensions/from_var_converter.h', - 'cpp/extensions/optional.h', - 'cpp/extensions/to_var_converter.h', - - # Extensions dev interfaces. - 'cpp/extensions/dev/alarms_dev.cc', - 'cpp/extensions/dev/alarms_dev.h', - 'cpp/extensions/dev/events_dev.cc', - 'cpp/extensions/dev/events_dev.h', - # Utility sources. 'utility/completion_callback_factory.h', 'utility/completion_callback_factory_thread_traits.h', diff --git a/ppapi/tests/all_c_includes.h b/ppapi/tests/all_c_includes.h index bd6911c..8eb8d2f 100644 --- a/ppapi/tests/all_c_includes.h +++ b/ppapi/tests/all_c_includes.h @@ -44,8 +44,6 @@ #include "ppapi/c/dev/ppp_video_decoder_dev.h" #include "ppapi/c/dev/ppp_widget_dev.h" #include "ppapi/c/dev/ppp_zoom_dev.h" -#include "ppapi/c/extensions/dev/ppb_alarms_dev.h" -#include "ppapi/c/extensions/dev/ppb_events_dev.h" #include "ppapi/c/pp_bool.h" #include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_errors.h" diff --git a/ppapi/tests/all_cpp_includes.h b/ppapi/tests/all_cpp_includes.h index e00e53a..69fa0d9 100644 --- a/ppapi/tests/all_cpp_includes.h +++ b/ppapi/tests/all_cpp_includes.h @@ -34,7 +34,6 @@ #include "ppapi/cpp/dev/widget_client_dev.h" #include "ppapi/cpp/dev/widget_dev.h" #include "ppapi/cpp/dev/zoom_dev.h" -#include "ppapi/cpp/extensions/dev/alarms_dev.h" #include "ppapi/cpp/file_io.h" #include "ppapi/cpp/file_ref.h" #include "ppapi/cpp/file_system.h" -- cgit v1.1