diff options
author | elijahtaylor@chromium.org <elijahtaylor@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-21 22:44:01 +0000 |
---|---|---|
committer | elijahtaylor@chromium.org <elijahtaylor@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-21 22:44:01 +0000 |
commit | 1ef13cf522915b73185907981d10802f1e45fdb5 (patch) | |
tree | 3b98db85e311ff0ab99cfa03efb42215c10ad5be /ppapi | |
parent | bca4951052ae6cea48d405eeb002de704de08cfa (diff) | |
download | chromium_src-1ef13cf522915b73185907981d10802f1e45fdb5.zip chromium_src-1ef13cf522915b73185907981d10802f1e45fdb5.tar.gz chromium_src-1ef13cf522915b73185907981d10802f1e45fdb5.tar.bz2 |
Add IsCrashReportingEnabled call to Pepper UMA API
This mirrors the existing metricsPrivate JS API.
BUG=341130
Review URL: https://codereview.chromium.org/195793026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@258702 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/api/private/ppb_uma_private.idl | 12 | ||||
-rw-r--r-- | ppapi/c/private/ppb_uma_private.h | 19 | ||||
-rw-r--r-- | ppapi/cpp/private/uma_private.cc | 21 | ||||
-rw-r--r-- | ppapi/cpp/private/uma_private.h | 4 | ||||
-rw-r--r-- | ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c | 40 | ||||
-rw-r--r-- | ppapi/proxy/ppapi_messages.h | 2 | ||||
-rw-r--r-- | ppapi/proxy/uma_private_resource.cc | 21 | ||||
-rw-r--r-- | ppapi/proxy/uma_private_resource.h | 8 | ||||
-rw-r--r-- | ppapi/thunk/interfaces_ppb_private_no_permissions.h | 4 | ||||
-rw-r--r-- | ppapi/thunk/ppb_uma_private_thunk.cc | 23 | ||||
-rw-r--r-- | ppapi/thunk/ppb_uma_singleton_api.h | 4 |
11 files changed, 122 insertions, 36 deletions
diff --git a/ppapi/api/private/ppb_uma_private.idl b/ppapi/api/private/ppb_uma_private.idl index a115cee..2d9b950 100644 --- a/ppapi/api/private/ppb_uma_private.idl +++ b/ppapi/api/private/ppb_uma_private.idl @@ -10,7 +10,7 @@ [generate_thunk,thunk_include="ppapi/thunk/ppb_uma_singleton_api.h"] label Chrome { - M33 = 0.2 + M35 = 0.3 }; /** @@ -54,4 +54,14 @@ interface PPB_UMA_Private { [in] PP_Var name, [in] int32_t sample, [in] int32_t boundary_value); + + /** + * IsCrashReportingEnabled returns PP_OK to the completion callback to + * indicate that the current user has opted-in to crash reporting, or + * PP_ERROR_* on failure or when a user has not opted-in. This can be used to + * gate other reporting processes such as analytics and crash reporting. + */ + [singleton,api=PPB_UMA_Singleton_API] + int32_t IsCrashReportingEnabled([in] PP_Instance instance, + [in] PP_CompletionCallback callback); }; diff --git a/ppapi/c/private/ppb_uma_private.h b/ppapi/c/private/ppb_uma_private.h index c23ba99..04cad42 100644 --- a/ppapi/c/private/ppb_uma_private.h +++ b/ppapi/c/private/ppb_uma_private.h @@ -3,19 +3,20 @@ * found in the LICENSE file. */ -/* From private/ppb_uma_private.idl modified Mon Nov 18 14:39:43 2013. */ +/* From private/ppb_uma_private.idl modified Fri Mar 14 16:59:33 2014. */ #ifndef PPAPI_C_PRIVATE_PPB_UMA_PRIVATE_H_ #define PPAPI_C_PRIVATE_PPB_UMA_PRIVATE_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_UMA_PRIVATE_INTERFACE_0_2 "PPB_UMA_Private;0.2" -#define PPB_UMA_PRIVATE_INTERFACE PPB_UMA_PRIVATE_INTERFACE_0_2 +#define PPB_UMA_PRIVATE_INTERFACE_0_3 "PPB_UMA_Private;0.3" +#define PPB_UMA_PRIVATE_INTERFACE PPB_UMA_PRIVATE_INTERFACE_0_3 /** * @file @@ -30,7 +31,7 @@ /** * Contains functions for plugins to report UMA usage stats. */ -struct PPB_UMA_Private_0_2 { +struct PPB_UMA_Private_0_3 { /** * HistogramCustomTimes is a pointer to a function which records a time * sample given in milliseconds in the histogram given by |name|, possibly @@ -63,9 +64,17 @@ struct PPB_UMA_Private_0_2 { struct PP_Var name, int32_t sample, int32_t boundary_value); + /** + * IsCrashReportingEnabled returns PP_OK to the completion callback to + * indicate that the current user has opted-in to crash reporting, or + * PP_ERROR_* on failure or when a user has not opted-in. This can be used to + * gate other reporting processes such as analytics and crash reporting. + */ + int32_t (*IsCrashReportingEnabled)(PP_Instance instance, + struct PP_CompletionCallback callback); }; -typedef struct PPB_UMA_Private_0_2 PPB_UMA_Private; +typedef struct PPB_UMA_Private_0_3 PPB_UMA_Private; /** * @} */ diff --git a/ppapi/cpp/private/uma_private.cc b/ppapi/cpp/private/uma_private.cc index ed8b6e9..3ec0872 100644 --- a/ppapi/cpp/private/uma_private.cc +++ b/ppapi/cpp/private/uma_private.cc @@ -6,6 +6,7 @@ #include "ppapi/c/pp_errors.h" #include "ppapi/c/private/ppb_uma_private.h" +#include "ppapi/cpp/completion_callback.h" #include "ppapi/cpp/module_impl.h" #include "ppapi/cpp/var.h" @@ -13,8 +14,8 @@ namespace pp { namespace { -template <> const char* interface_name<PPB_UMA_Private_0_2>() { - return PPB_UMA_PRIVATE_INTERFACE_0_2; +template <> const char* interface_name<PPB_UMA_Private_0_3>() { + return PPB_UMA_PRIVATE_INTERFACE_0_3; } } // namespace @@ -30,7 +31,7 @@ UMAPrivate::~UMAPrivate() { } bool UMAPrivate::IsAvailable() { - return has_interface<PPB_UMA_Private_0_2>(); + return has_interface<PPB_UMA_Private_0_3>(); } void UMAPrivate::HistogramCustomTimes(const std::string& name, @@ -40,7 +41,7 @@ void UMAPrivate::HistogramCustomTimes(const std::string& name, uint32_t bucket_count) { if (!IsAvailable()) return; - get_interface<PPB_UMA_Private_0_2>()-> + get_interface<PPB_UMA_Private_0_3>()-> HistogramCustomTimes(instance_, pp::Var(name).pp_var(), sample, min, max, bucket_count); } @@ -52,7 +53,7 @@ void UMAPrivate::HistogramCustomCounts(const std::string& name, uint32_t bucket_count) { if (!IsAvailable()) return; - get_interface<PPB_UMA_Private_0_2>()-> + get_interface<PPB_UMA_Private_0_3>()-> HistogramCustomCounts(instance_, pp::Var(name).pp_var(), sample, min, max, bucket_count); } @@ -62,9 +63,17 @@ void UMAPrivate::HistogramEnumeration(const std::string& name, int32_t boundary_value) { if (!IsAvailable()) return; - get_interface<PPB_UMA_Private_0_2>()-> + get_interface<PPB_UMA_Private_0_3>()-> HistogramEnumeration(instance_, pp::Var(name).pp_var(), sample, boundary_value); } +int32_t UMAPrivate::IsCrashReportingEnabled(const CompletionCallback& cc) { + if (!IsAvailable()) + return PP_ERROR_NOINTERFACE; + + return get_interface<PPB_UMA_Private_0_3>()-> + IsCrashReportingEnabled(instance_, cc.pp_completion_callback()); +} + } // namespace pp diff --git a/ppapi/cpp/private/uma_private.h b/ppapi/cpp/private/uma_private.h index 23de400..78d526d 100644 --- a/ppapi/cpp/private/uma_private.h +++ b/ppapi/cpp/private/uma_private.h @@ -12,6 +12,8 @@ namespace pp { +class CompletionCallback; + class UMAPrivate { public: UMAPrivate(); @@ -36,6 +38,8 @@ class UMAPrivate { int32_t sample, int32_t boundary_value); + int32_t IsCrashReportingEnabled(const CompletionCallback& cc); + private: PP_Instance instance_; }; 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 1a6fbb7..cdf6126 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 @@ -190,7 +190,7 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_Testing_Private_1_0; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_UDPSocket_Private_0_2; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_UDPSocket_Private_0_3; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_UDPSocket_Private_0_4; -static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_UMA_Private_0_2; +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_UMA_Private_0_3; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoDestination_Private_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_VideoSource_Private_0_1; static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_X509Certificate_Private_0_1; @@ -3839,24 +3839,29 @@ static void Pnacl_M23_PPB_UDPSocket_Private_Close(PP_Resource udp_socket) { /* End wrapper methods for PPB_UDPSocket_Private_0_4 */ -/* Begin wrapper methods for PPB_UMA_Private_0_2 */ +/* Begin wrapper methods for PPB_UMA_Private_0_3 */ -static void Pnacl_M33_PPB_UMA_Private_HistogramCustomTimes(PP_Instance instance, struct PP_Var* name, int64_t sample, int64_t min, int64_t max, uint32_t bucket_count) { - const struct PPB_UMA_Private_0_2 *iface = Pnacl_WrapperInfo_PPB_UMA_Private_0_2.real_iface; +static void Pnacl_M35_PPB_UMA_Private_HistogramCustomTimes(PP_Instance instance, struct PP_Var* name, int64_t sample, int64_t min, int64_t max, uint32_t bucket_count) { + const struct PPB_UMA_Private_0_3 *iface = Pnacl_WrapperInfo_PPB_UMA_Private_0_3.real_iface; iface->HistogramCustomTimes(instance, *name, sample, min, max, bucket_count); } -static void Pnacl_M33_PPB_UMA_Private_HistogramCustomCounts(PP_Instance instance, struct PP_Var* name, int32_t sample, int32_t min, int32_t max, uint32_t bucket_count) { - const struct PPB_UMA_Private_0_2 *iface = Pnacl_WrapperInfo_PPB_UMA_Private_0_2.real_iface; +static void Pnacl_M35_PPB_UMA_Private_HistogramCustomCounts(PP_Instance instance, struct PP_Var* name, int32_t sample, int32_t min, int32_t max, uint32_t bucket_count) { + const struct PPB_UMA_Private_0_3 *iface = Pnacl_WrapperInfo_PPB_UMA_Private_0_3.real_iface; iface->HistogramCustomCounts(instance, *name, sample, min, max, bucket_count); } -static void Pnacl_M33_PPB_UMA_Private_HistogramEnumeration(PP_Instance instance, struct PP_Var* name, int32_t sample, int32_t boundary_value) { - const struct PPB_UMA_Private_0_2 *iface = Pnacl_WrapperInfo_PPB_UMA_Private_0_2.real_iface; +static void Pnacl_M35_PPB_UMA_Private_HistogramEnumeration(PP_Instance instance, struct PP_Var* name, int32_t sample, int32_t boundary_value) { + const struct PPB_UMA_Private_0_3 *iface = Pnacl_WrapperInfo_PPB_UMA_Private_0_3.real_iface; iface->HistogramEnumeration(instance, *name, sample, boundary_value); } -/* End wrapper methods for PPB_UMA_Private_0_2 */ +static int32_t Pnacl_M35_PPB_UMA_Private_IsCrashReportingEnabled(PP_Instance instance, struct PP_CompletionCallback* callback) { + const struct PPB_UMA_Private_0_3 *iface = Pnacl_WrapperInfo_PPB_UMA_Private_0_3.real_iface; + return iface->IsCrashReportingEnabled(instance, *callback); +} + +/* End wrapper methods for PPB_UMA_Private_0_3 */ /* Begin wrapper methods for PPB_VideoDestination_Private_0_1 */ @@ -5252,10 +5257,11 @@ static const struct PPB_UDPSocket_Private_0_4 Pnacl_Wrappers_PPB_UDPSocket_Priva .Close = (void (*)(PP_Resource udp_socket))&Pnacl_M23_PPB_UDPSocket_Private_Close }; -static const struct PPB_UMA_Private_0_2 Pnacl_Wrappers_PPB_UMA_Private_0_2 = { - .HistogramCustomTimes = (void (*)(PP_Instance instance, struct PP_Var name, int64_t sample, int64_t min, int64_t max, uint32_t bucket_count))&Pnacl_M33_PPB_UMA_Private_HistogramCustomTimes, - .HistogramCustomCounts = (void (*)(PP_Instance instance, struct PP_Var name, int32_t sample, int32_t min, int32_t max, uint32_t bucket_count))&Pnacl_M33_PPB_UMA_Private_HistogramCustomCounts, - .HistogramEnumeration = (void (*)(PP_Instance instance, struct PP_Var name, int32_t sample, int32_t boundary_value))&Pnacl_M33_PPB_UMA_Private_HistogramEnumeration +static const struct PPB_UMA_Private_0_3 Pnacl_Wrappers_PPB_UMA_Private_0_3 = { + .HistogramCustomTimes = (void (*)(PP_Instance instance, struct PP_Var name, int64_t sample, int64_t min, int64_t max, uint32_t bucket_count))&Pnacl_M35_PPB_UMA_Private_HistogramCustomTimes, + .HistogramCustomCounts = (void (*)(PP_Instance instance, struct PP_Var name, int32_t sample, int32_t min, int32_t max, uint32_t bucket_count))&Pnacl_M35_PPB_UMA_Private_HistogramCustomCounts, + .HistogramEnumeration = (void (*)(PP_Instance instance, struct PP_Var name, int32_t sample, int32_t boundary_value))&Pnacl_M35_PPB_UMA_Private_HistogramEnumeration, + .IsCrashReportingEnabled = (int32_t (*)(PP_Instance instance, struct PP_CompletionCallback callback))&Pnacl_M35_PPB_UMA_Private_IsCrashReportingEnabled }; static const struct PPB_VideoDestination_Private_0_1 Pnacl_Wrappers_PPB_VideoDestination_Private_0_1 = { @@ -5922,9 +5928,9 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_UDPSocket_Private_0_4 = { .real_iface = NULL }; -static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_UMA_Private_0_2 = { - .iface_macro = PPB_UMA_PRIVATE_INTERFACE_0_2, - .wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_UMA_Private_0_2, +static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_UMA_Private_0_3 = { + .iface_macro = PPB_UMA_PRIVATE_INTERFACE_0_3, + .wrapped_iface = (const void *) &Pnacl_Wrappers_PPB_UMA_Private_0_3, .real_iface = NULL }; @@ -6065,7 +6071,7 @@ static struct __PnaclWrapperInfo *s_ppb_wrappers[] = { &Pnacl_WrapperInfo_PPB_UDPSocket_Private_0_2, &Pnacl_WrapperInfo_PPB_UDPSocket_Private_0_3, &Pnacl_WrapperInfo_PPB_UDPSocket_Private_0_4, - &Pnacl_WrapperInfo_PPB_UMA_Private_0_2, + &Pnacl_WrapperInfo_PPB_UMA_Private_0_3, &Pnacl_WrapperInfo_PPB_VideoDestination_Private_0_1, &Pnacl_WrapperInfo_PPB_VideoSource_Private_0_1, &Pnacl_WrapperInfo_PPB_X509Certificate_Private_0_1, diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h index ead5680..5691b0c 100644 --- a/ppapi/proxy/ppapi_messages.h +++ b/ppapi/proxy/ppapi_messages.h @@ -1277,6 +1277,8 @@ IPC_MESSAGE_CONTROL3(PpapiHostMsg_UMA_HistogramEnumeration, std::string /* name */, int32_t /* sample */, int32_t /* boundary_value */) +IPC_MESSAGE_CONTROL0(PpapiHostMsg_UMA_IsCrashReportingEnabled); +IPC_MESSAGE_CONTROL0(PpapiPluginMsg_UMA_IsCrashReportingEnabledReply); // File chooser. IPC_MESSAGE_CONTROL0(PpapiHostMsg_FileChooser_Create) diff --git a/ppapi/proxy/uma_private_resource.cc b/ppapi/proxy/uma_private_resource.cc index d17a005..2932e6c 100644 --- a/ppapi/proxy/uma_private_resource.cc +++ b/ppapi/proxy/uma_private_resource.cc @@ -84,6 +84,27 @@ void UMAPrivateResource::HistogramEnumeration( boundary_value)); } +int32_t UMAPrivateResource::IsCrashReportingEnabled( + PP_Instance instance, + scoped_refptr<TrackedCallback> callback) { + if (pending_callback_ != NULL) + return PP_ERROR_INPROGRESS; + pending_callback_ = callback; + Call<PpapiPluginMsg_UMA_IsCrashReportingEnabledReply>( + RENDERER, + PpapiHostMsg_UMA_IsCrashReportingEnabled(), + base::Bind(&UMAPrivateResource::OnPluginMsgIsCrashReportingEnabled, + this)); + return PP_OK_COMPLETIONPENDING; +} + +void UMAPrivateResource::OnPluginMsgIsCrashReportingEnabled( + const ResourceMessageReplyParams& params) { + if (TrackedCallback::IsPending(pending_callback_)) + pending_callback_->Run(params.result()); + pending_callback_ = NULL; +} + } // namespace proxy } // namespace ppapi diff --git a/ppapi/proxy/uma_private_resource.h b/ppapi/proxy/uma_private_resource.h index 94c7d3c..93328e8 100644 --- a/ppapi/proxy/uma_private_resource.h +++ b/ppapi/proxy/uma_private_resource.h @@ -44,7 +44,15 @@ class PPAPI_PROXY_EXPORT UMAPrivateResource int32_t sample, int32_t boundary_value) OVERRIDE; + virtual int32_t IsCrashReportingEnabled( + PP_Instance instance, + scoped_refptr<TrackedCallback> callback) OVERRIDE; + private: + void OnPluginMsgIsCrashReportingEnabled( + const ResourceMessageReplyParams& params); + scoped_refptr<TrackedCallback> pending_callback_; + DISALLOW_COPY_AND_ASSIGN(UMAPrivateResource); }; diff --git a/ppapi/thunk/interfaces_ppb_private_no_permissions.h b/ppapi/thunk/interfaces_ppb_private_no_permissions.h index 83e8243..6c224fe 100644 --- a/ppapi/thunk/interfaces_ppb_private_no_permissions.h +++ b/ppapi/thunk/interfaces_ppb_private_no_permissions.h @@ -48,7 +48,7 @@ PROXIED_IFACE(PPB_VIDEODESTINATION_PRIVATE_INTERFACE_0_1, PROXIED_IFACE(PPB_VIDEOSOURCE_PRIVATE_INTERFACE_0_1, PPB_VideoSource_Private_0_1) -PROXIED_IFACE(PPB_UMA_PRIVATE_INTERFACE_0_2, - PPB_UMA_Private_0_2) +PROXIED_IFACE(PPB_UMA_PRIVATE_INTERFACE_0_3, + PPB_UMA_Private_0_3) #include "ppapi/thunk/interfaces_postamble.h" diff --git a/ppapi/thunk/ppb_uma_private_thunk.cc b/ppapi/thunk/ppb_uma_private_thunk.cc index 1171d19..299b643 100644 --- a/ppapi/thunk/ppb_uma_private_thunk.cc +++ b/ppapi/thunk/ppb_uma_private_thunk.cc @@ -2,8 +2,9 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// From private/ppb_uma_private.idl modified Fri Jan 24 13:23:21 2014. +// From private/ppb_uma_private.idl modified Thu Mar 13 11:54:51 2014. +#include "ppapi/c/pp_completion_callback.h" #include "ppapi/c/pp_errors.h" #include "ppapi/c/private/ppb_uma_private.h" #include "ppapi/shared_impl/tracked_callback.h" @@ -66,16 +67,28 @@ void HistogramEnumeration(PP_Instance instance, boundary_value); } -const PPB_UMA_Private_0_2 g_ppb_uma_private_thunk_0_2 = { +int32_t IsCrashReportingEnabled(PP_Instance instance, + struct PP_CompletionCallback callback) { + VLOG(4) << "PPB_UMA_Private::IsCrashReportingEnabled()"; + EnterInstanceAPI<PPB_UMA_Singleton_API> enter(instance, callback); + if (enter.failed()) + return enter.retval(); + return enter.SetResult(enter.functions()->IsCrashReportingEnabled( + instance, + enter.callback())); +} + +const PPB_UMA_Private_0_3 g_ppb_uma_private_thunk_0_3 = { &HistogramCustomTimes, &HistogramCustomCounts, - &HistogramEnumeration + &HistogramEnumeration, + &IsCrashReportingEnabled }; } // namespace -PPAPI_THUNK_EXPORT const PPB_UMA_Private_0_2* GetPPB_UMA_Private_0_2_Thunk() { - return &g_ppb_uma_private_thunk_0_2; +PPAPI_THUNK_EXPORT const PPB_UMA_Private_0_3* GetPPB_UMA_Private_0_3_Thunk() { + return &g_ppb_uma_private_thunk_0_3; } } // namespace thunk diff --git a/ppapi/thunk/ppb_uma_singleton_api.h b/ppapi/thunk/ppb_uma_singleton_api.h index efb6736..f8414b9 100644 --- a/ppapi/thunk/ppb_uma_singleton_api.h +++ b/ppapi/thunk/ppb_uma_singleton_api.h @@ -34,6 +34,10 @@ class PPAPI_THUNK_EXPORT PPB_UMA_Singleton_API { int32_t sample, int32_t boundary_value) = 0; + virtual int32_t IsCrashReportingEnabled( + PP_Instance instance, + scoped_refptr<TrackedCallback> cc) = 0; + static const SingletonResourceID kSingletonResourceID = UMA_SINGLETON_ID; }; |