summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorelijahtaylor@chromium.org <elijahtaylor@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-24 20:49:34 +0000
committerelijahtaylor@chromium.org <elijahtaylor@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-24 20:49:34 +0000
commit4564949f87f10dc504993080785fa1fbb60bb978 (patch)
tree18b622d0656fb4c7a2f7ecce39a596a0b43b80a7
parentcba826490cd939ae2f22363c5163517017c5a7d0 (diff)
downloadchromium_src-4564949f87f10dc504993080785fa1fbb60bb978.zip
chromium_src-4564949f87f10dc504993080785fa1fbb60bb978.tar.gz
chromium_src-4564949f87f10dc504993080785fa1fbb60bb978.tar.bz2
Proxy private UMA pepper interface for out-of-process and NaCl plugins.
BUG=317833 Review URL: https://codereview.chromium.org/61643022 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@246962 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/chrome_renderer.gypi2
-rw-r--r--chrome/renderer/chrome_content_renderer_client.cc8
-rw-r--r--chrome/renderer/chrome_content_renderer_client.h8
-rw-r--r--chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc12
-rw-r--r--chrome/renderer/pepper/pepper_uma_host.cc162
-rw-r--r--chrome/renderer/pepper/pepper_uma_host.h75
-rw-r--r--chrome/test/ppapi/ppapi_browsertest.cc4
-rw-r--r--content/browser/renderer_host/pepper/browser_ppapi_host_impl.h1
-rw-r--r--content/content_renderer.gypi2
-rw-r--r--content/renderer/pepper/pepper_plugin_instance_impl.cc13
-rw-r--r--content/renderer/pepper/pepper_plugin_instance_impl.h1
-rw-r--r--content/renderer/pepper/plugin_module.cc1
-rw-r--r--content/renderer/pepper/ppb_uma_private_impl.cc97
-rw-r--r--content/renderer/pepper/ppb_uma_private_impl.h19
-rw-r--r--native_client_sdk/src/libraries/ppapi_cpp_private/library.dsc3
-rw-r--r--ppapi/api/private/ppb_uma_private.idl17
-rw-r--r--ppapi/c/private/ppb_uma_private.h20
-rw-r--r--ppapi/cpp/private/uma_private.cc70
-rw-r--r--ppapi/cpp/private/uma_private.h45
-rw-r--r--ppapi/native_client/src/trusted/plugin/plugin.cc250
-rw-r--r--ppapi/native_client/src/trusted/plugin/plugin.h21
-rw-r--r--ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc122
-rw-r--r--ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c40
-rw-r--r--ppapi/ppapi_proxy.gypi2
-rw-r--r--ppapi/ppapi_shared.gypi2
-rw-r--r--ppapi/ppapi_sources.gypi7
-rw-r--r--ppapi/proxy/interface_list.cc1
-rw-r--r--ppapi/proxy/ppapi_messages.h19
-rw-r--r--ppapi/proxy/ppb_instance_proxy.cc4
-rw-r--r--ppapi/proxy/uma_private_resource.cc89
-rw-r--r--ppapi/proxy/uma_private_resource.h54
-rw-r--r--ppapi/shared_impl/resource.h1
-rw-r--r--ppapi/shared_impl/singleton_resource_id.h1
-rw-r--r--ppapi/tests/test_uma.cc29
-rw-r--r--ppapi/thunk/interfaces_legacy.h1
-rw-r--r--ppapi/thunk/interfaces_ppb_private_no_permissions.h3
-rw-r--r--ppapi/thunk/ppb_uma_private_thunk.cc84
-rw-r--r--ppapi/thunk/ppb_uma_singleton_api.h43
38 files changed, 952 insertions, 381 deletions
diff --git a/chrome/chrome_renderer.gypi b/chrome/chrome_renderer.gypi
index 9edb7b9..59bffeb 100644
--- a/chrome/chrome_renderer.gypi
+++ b/chrome/chrome_renderer.gypi
@@ -273,6 +273,8 @@
'renderer/pepper/pepper_pdf_host.h',
'renderer/pepper/pepper_shared_memory_message_filter.cc',
'renderer/pepper/pepper_shared_memory_message_filter.h',
+ 'renderer/pepper/pepper_uma_host.cc',
+ 'renderer/pepper/pepper_uma_host.h',
'renderer/pepper/ppb_pdf_impl.cc',
'renderer/pepper/ppb_pdf_impl.h',
'renderer/plugins/chrome_plugin_placeholder.cc',
diff --git a/chrome/renderer/chrome_content_renderer_client.cc b/chrome/renderer/chrome_content_renderer_client.cc
index 3e000ac..943cab3 100644
--- a/chrome/renderer/chrome_content_renderer_client.cc
+++ b/chrome/renderer/chrome_content_renderer_client.cc
@@ -1316,6 +1316,14 @@ bool ChromeContentRendererClient::IsExternalPepperPlugin(
return module_name == "Native Client";
}
+bool ChromeContentRendererClient::IsExtensionOrSharedModuleWhitelisted(
+ const GURL& url, const std::set<std::string>& whitelist) {
+ const extensions::ExtensionSet* extension_set =
+ g_current_client->extension_dispatcher_->extensions();
+ return chrome::IsExtensionOrSharedModuleWhitelisted(url, extension_set,
+ whitelist);
+}
+
blink::WebSpeechSynthesizer*
ChromeContentRendererClient::OverrideSpeechSynthesizer(
blink::WebSpeechSynthesizerClient* client) {
diff --git a/chrome/renderer/chrome_content_renderer_client.h b/chrome/renderer/chrome_content_renderer_client.h
index 71e07c5..d31e1c3 100644
--- a/chrome/renderer/chrome_content_renderer_client.h
+++ b/chrome/renderer/chrome_content_renderer_client.h
@@ -5,13 +5,10 @@
#ifndef CHROME_RENDERER_CHROME_CONTENT_RENDERER_CLIENT_H_
#define CHROME_RENDERER_CHROME_CONTENT_RENDERER_CLIENT_H_
+#include <set>
#include <string>
#include <vector>
-#if defined(ENABLE_PLUGINS)
-#include <set>
-#endif
-
#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/string16.h"
@@ -155,6 +152,9 @@ class ChromeContentRendererClient : public content::ContentRendererClient {
const blink::WebPluginParams& params,
const ChromeViewHostMsg_GetPluginInfo_Output& output);
+ static bool IsExtensionOrSharedModuleWhitelisted(
+ const GURL& url, const std::set<std::string>& whitelist);
+
// TODO(mpcomplete): remove after we collect histogram data.
// http://crbug.com/100411
static bool IsAdblockInstalled();
diff --git a/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc b/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc
index 6873b7a..3469001 100644
--- a/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc
+++ b/chrome/renderer/pepper/chrome_renderer_pepper_host_factory.cc
@@ -12,6 +12,7 @@
#include "chrome/renderer/pepper/pepper_flash_menu_host.h"
#include "chrome/renderer/pepper/pepper_flash_renderer_host.h"
#include "chrome/renderer/pepper/pepper_pdf_host.h"
+#include "chrome/renderer/pepper/pepper_uma_host.h"
#include "content/public/renderer/renderer_ppapi_host.h"
#include "ppapi/host/ppapi_host.h"
#include "ppapi/host/resource_host.h"
@@ -109,5 +110,16 @@ ChromeRendererPepperHostFactory::CreateResourceHost(
}
}
+ // Permissions for the following interfaces will be checked at the
+ // time of the corresponding instance's method calls. Currently these
+ // interfaces are available only for whitelisted apps which may not have
+ // access to the other private interfaces.
+ switch (message.type()) {
+ case PpapiHostMsg_UMA_Create::ID: {
+ return scoped_ptr<ResourceHost>(new PepperUMAHost(
+ host_, instance, params.pp_resource()));
+ }
+ }
+
return scoped_ptr<ResourceHost>();
}
diff --git a/chrome/renderer/pepper/pepper_uma_host.cc b/chrome/renderer/pepper/pepper_uma_host.cc
new file mode 100644
index 0000000..04a5429
--- /dev/null
+++ b/chrome/renderer/pepper/pepper_uma_host.cc
@@ -0,0 +1,162 @@
+// Copyright 2014 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 "chrome/renderer/pepper/pepper_uma_host.h"
+
+#include "base/metrics/histogram.h"
+#include "base/sha1.h"
+#include "base/strings/string_number_conversions.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/renderer/chrome_content_renderer_client.h"
+#include "content/public/renderer/renderer_ppapi_host.h"
+#include "extensions/common/constants.h"
+#include "extensions/common/extension.h"
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/host/dispatch_host_message.h"
+#include "ppapi/host/host_message_context.h"
+#include "ppapi/host/ppapi_host.h"
+#include "ppapi/proxy/ppapi_messages.h"
+
+namespace {
+
+const char* kPredefinedAllowedUMAOrigins[] = {
+ "6EAED1924DB611B6EEF2A664BD077BE7EAD33B8F", // see crbug.com/317833
+ "4EB74897CB187C7633357C2FE832E0AD6A44883A" // see crbug.com/317833
+};
+
+const char* kWhitelistedHistogramHashes[] = {
+ "F131550DAB7A7C6E6633EF81FB5998CC0482AC63", // see crbug.com/317833
+ "13955AB4DAD798384DFB4304734FCF2A95F353CC", // see crbug.com/317833
+ "404E800582901F1B937B8E287235FC603A5DEDFB" // see crbug.com/317833
+};
+
+std::string HashHistogram(const std::string& histogram) {
+ const std::string id_hash = base::SHA1HashString(histogram);
+ DCHECK_EQ(id_hash.length(), base::kSHA1Length);
+ return base::HexEncode(id_hash.c_str(), id_hash.length());
+}
+
+} // namespace
+
+PepperUMAHost::PepperUMAHost(
+ content::RendererPpapiHost* host,
+ PP_Instance instance,
+ PP_Resource resource)
+ : ResourceHost(host->GetPpapiHost(), instance, resource),
+ document_url_(host->GetDocumentURL(instance)),
+ is_plugin_in_process_(host->IsRunningInProcess()) {
+ for (size_t i = 0; i < arraysize(kPredefinedAllowedUMAOrigins); ++i)
+ allowed_origins_.insert(kPredefinedAllowedUMAOrigins[i]);
+ for (size_t i = 0; i < arraysize(kWhitelistedHistogramHashes); ++i)
+ allowed_histograms_.insert(kWhitelistedHistogramHashes[i]);
+}
+
+PepperUMAHost::~PepperUMAHost() {
+}
+
+int32_t PepperUMAHost::OnResourceMessageReceived(
+ const IPC::Message& msg,
+ ppapi::host::HostMessageContext* context) {
+ IPC_BEGIN_MESSAGE_MAP(PepperUMAHost, msg)
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_UMA_HistogramCustomTimes,
+ OnHistogramCustomTimes);
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_UMA_HistogramCustomCounts,
+ OnHistogramCustomCounts);
+ PPAPI_DISPATCH_HOST_RESOURCE_CALL(PpapiHostMsg_UMA_HistogramEnumeration,
+ OnHistogramEnumeration);
+ IPC_END_MESSAGE_MAP()
+ return PP_ERROR_FAILED;
+}
+
+bool PepperUMAHost::IsHistogramAllowed(const std::string& histogram) {
+ if (is_plugin_in_process_ && histogram.find("NaCl.") == 0) {
+ return true;
+ }
+
+ bool is_whitelisted =
+ ChromeContentRendererClient::IsExtensionOrSharedModuleWhitelisted(
+ document_url_, allowed_origins_);
+ if (is_whitelisted &&
+ allowed_histograms_.find(HashHistogram(histogram)) !=
+ allowed_histograms_.end()) {
+ return true;
+ }
+
+ LOG(ERROR) << "Host or histogram name is not allowed to use the UMA API.";
+ return false;
+}
+
+#define RETURN_IF_BAD_ARGS(_min, _max, _buckets) \
+ do { \
+ if (_min >= _max || _buckets <= 1) \
+ return PP_ERROR_BADARGUMENT; \
+ } while (0)
+
+int32_t PepperUMAHost::OnHistogramCustomTimes(
+ ppapi::host::HostMessageContext* context,
+ const std::string& name,
+ int64_t sample,
+ int64_t min,
+ int64_t max,
+ uint32_t bucket_count) {
+ if (!IsHistogramAllowed(name)) {
+ return PP_ERROR_NOACCESS;
+ }
+ RETURN_IF_BAD_ARGS(min, max, bucket_count);
+
+ base::HistogramBase* counter =
+ base::Histogram::FactoryTimeGet(
+ name,
+ base::TimeDelta::FromMilliseconds(min),
+ base::TimeDelta::FromMilliseconds(max),
+ bucket_count,
+ base::HistogramBase::kUmaTargetedHistogramFlag);
+ counter->AddTime(base::TimeDelta::FromMilliseconds(sample));
+ return PP_OK;
+}
+
+int32_t PepperUMAHost::OnHistogramCustomCounts(
+ ppapi::host::HostMessageContext* context,
+ const std::string& name,
+ int32_t sample,
+ int32_t min,
+ int32_t max,
+ uint32_t bucket_count) {
+ if (!IsHistogramAllowed(name)) {
+ return PP_ERROR_NOACCESS;
+ }
+ RETURN_IF_BAD_ARGS(min, max, bucket_count);
+
+ base::HistogramBase* counter =
+ base::Histogram::FactoryGet(
+ name,
+ min,
+ max,
+ bucket_count,
+ base::HistogramBase::kUmaTargetedHistogramFlag);
+ counter->Add(sample);
+ return PP_OK;
+}
+
+int32_t PepperUMAHost::OnHistogramEnumeration(
+ ppapi::host::HostMessageContext* context,
+ const std::string& name,
+ int32_t sample,
+ int32_t boundary_value) {
+ if (!IsHistogramAllowed(name)) {
+ return PP_ERROR_NOACCESS;
+ }
+ RETURN_IF_BAD_ARGS(0, boundary_value, boundary_value + 1);
+
+ base::HistogramBase* counter =
+ base::LinearHistogram::FactoryGet(
+ name,
+ 1,
+ boundary_value,
+ boundary_value + 1,
+ base::HistogramBase::kUmaTargetedHistogramFlag);
+ counter->Add(sample);
+ return PP_OK;
+}
+
diff --git a/chrome/renderer/pepper/pepper_uma_host.h b/chrome/renderer/pepper/pepper_uma_host.h
new file mode 100644
index 0000000..4fed57b
--- /dev/null
+++ b/chrome/renderer/pepper/pepper_uma_host.h
@@ -0,0 +1,75 @@
+// Copyright 2014 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 CHROME_RENDERER_PEPPER_PEPPER_UMA_HOST_H_
+#define CHROME_RENDERER_PEPPER_PEPPER_UMA_HOST_H_
+
+#include <set>
+#include <string>
+
+#include "ppapi/c/pp_instance.h"
+#include "ppapi/c/pp_resource.h"
+#include "ppapi/host/resource_host.h"
+#include "url/gurl.h"
+
+namespace content {
+class RendererPpapiHost;
+}
+
+namespace ppapi {
+namespace host {
+struct HostMessageContext;
+} // namespace host
+} // namespace ppapi
+
+class PepperUMAHost : public ppapi::host::ResourceHost {
+ public:
+ PepperUMAHost(content::RendererPpapiHost* host,
+ PP_Instance instance,
+ PP_Resource resource);
+
+ virtual ~PepperUMAHost();
+
+ // ppapi::host::ResourceMessageHandler implementation.
+ virtual int32_t OnResourceMessageReceived(
+ const IPC::Message& msg,
+ ppapi::host::HostMessageContext* context) OVERRIDE;
+
+ private:
+ bool IsHistogramAllowed(const std::string& histogram);
+
+ int32_t OnHistogramCustomTimes(
+ ppapi::host::HostMessageContext* context,
+ const std::string& name,
+ int64_t sample,
+ int64_t min,
+ int64_t max,
+ uint32_t bucket_count);
+
+ int32_t OnHistogramCustomCounts(
+ ppapi::host::HostMessageContext* context,
+ const std::string& name,
+ int32_t sample,
+ int32_t min,
+ int32_t max,
+ uint32_t bucket_count);
+
+ int32_t OnHistogramEnumeration(
+ ppapi::host::HostMessageContext* context,
+ const std::string& name,
+ int32_t sample,
+ int32_t boundary_value);
+
+ const GURL document_url_;
+ bool is_plugin_in_process_;
+
+ // Set of origins that can use UMA private APIs from NaCl.
+ std::set<std::string> allowed_origins_;
+ // Set of histograms that can be used from this interface.
+ std::set<std::string> allowed_histograms_;
+
+ DISALLOW_COPY_AND_ASSIGN(PepperUMAHost);
+};
+
+#endif // CHROME_RENDERER_PEPPER_PEPPER_UMA_HOST_H_
diff --git a/chrome/test/ppapi/ppapi_browsertest.cc b/chrome/test/ppapi/ppapi_browsertest.cc
index 733022b..65cc3b8 100644
--- a/chrome/test/ppapi/ppapi_browsertest.cc
+++ b/chrome/test/ppapi/ppapi_browsertest.cc
@@ -1098,9 +1098,9 @@ TEST_PPAPI_NACL(MAYBE_Fullscreen)
TEST_PPAPI_OUT_OF_PROCESS(X509CertificatePrivate)
-// There is no proxy. This is used for PDF metrics reporting, and PDF only
-// runs in process, so there's currently no need for a proxy.
TEST_PPAPI_IN_PROCESS(UMA)
+TEST_PPAPI_OUT_OF_PROCESS(UMA)
+TEST_PPAPI_NACL(UMA)
// NetAddress tests
IN_PROC_BROWSER_TEST_F(OutOfProcessPPAPITest, NetAddress) {
diff --git a/content/browser/renderer_host/pepper/browser_ppapi_host_impl.h b/content/browser/renderer_host/pepper/browser_ppapi_host_impl.h
index 3f05c96..744a750 100644
--- a/content/browser/renderer_host/pepper/browser_ppapi_host_impl.h
+++ b/content/browser/renderer_host/pepper/browser_ppapi_host_impl.h
@@ -57,7 +57,6 @@ class CONTENT_EXPORT BrowserPpapiHostImpl : public BrowserPpapiHost {
virtual void SetOnKeepaliveCallback(
const BrowserPpapiHost::OnKeepaliveCallback& callback) OVERRIDE;
-
void set_plugin_process_handle(base::ProcessHandle handle) {
plugin_process_handle_ = handle;
}
diff --git a/content/content_renderer.gypi b/content/content_renderer.gypi
index 86aa9ea..fe0735d 100644
--- a/content/content_renderer.gypi
+++ b/content/content_renderer.gypi
@@ -412,8 +412,6 @@
'renderer/pepper/ppb_proxy_impl.h',
'renderer/pepper/ppb_scrollbar_impl.cc',
'renderer/pepper/ppb_scrollbar_impl.h',
- 'renderer/pepper/ppb_uma_private_impl.cc',
- 'renderer/pepper/ppb_uma_private_impl.h',
'renderer/pepper/ppb_var_deprecated_impl.cc',
'renderer/pepper/ppb_var_deprecated_impl.h',
'renderer/pepper/ppb_video_decoder_impl.cc',
diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.cc b/content/renderer/pepper/pepper_plugin_instance_impl.cc
index ccc766d..e2f588d 100644
--- a/content/renderer/pepper/pepper_plugin_instance_impl.cc
+++ b/content/renderer/pepper/pepper_plugin_instance_impl.cc
@@ -69,6 +69,7 @@
#include "ppapi/c/private/ppp_instance_private.h"
#include "ppapi/host/ppapi_host.h"
#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/proxy/uma_private_resource.h"
#include "ppapi/proxy/url_loader_resource.h"
#include "ppapi/shared_impl/ppapi_permissions.h"
#include "ppapi/shared_impl/ppapi_preferences.h"
@@ -508,6 +509,7 @@ PepperPluginInstanceImpl::PepperPluginInstanceImpl(
checked_for_plugin_messaging_interface_(false),
checked_for_plugin_pdf_interface_(false),
gamepad_impl_(new GamepadImpl()),
+ uma_private_impl_(NULL),
plugin_print_interface_(NULL),
plugin_graphics_3d_interface_(NULL),
always_on_top_(false),
@@ -2412,6 +2414,17 @@ ppapi::Resource* PepperPluginInstanceImpl::GetSingletonResource(
return NULL;
case ppapi::GAMEPAD_SINGLETON_ID:
return gamepad_impl_.get();
+ case ppapi::UMA_SINGLETON_ID: {
+ if (!uma_private_impl_) {
+ RendererPpapiHostImpl* host_impl = module_->renderer_ppapi_host();
+ if (host_impl->in_process_router()) {
+ uma_private_impl_ = new ppapi::proxy::UMAPrivateResource(
+ host_impl->in_process_router()->GetPluginConnection(instance),
+ instance);
+ }
+ }
+ return uma_private_impl_.get();
+ }
}
NOTREACHED();
diff --git a/content/renderer/pepper/pepper_plugin_instance_impl.h b/content/renderer/pepper/pepper_plugin_instance_impl.h
index 85a6094..b7b09b9 100644
--- a/content/renderer/pepper/pepper_plugin_instance_impl.h
+++ b/content/renderer/pepper/pepper_plugin_instance_impl.h
@@ -751,6 +751,7 @@ class CONTENT_EXPORT PepperPluginInstanceImpl
std::vector<PP_PrintPageNumberRange_Dev> ranges_;
scoped_refptr<ppapi::Resource> gamepad_impl_;
+ scoped_refptr<ppapi::Resource> uma_private_impl_;
// The plugin print interface.
const PPP_Printing_Dev* plugin_print_interface_;
diff --git a/content/renderer/pepper/plugin_module.cc b/content/renderer/pepper/plugin_module.cc
index 63bdc0b..60de434 100644
--- a/content/renderer/pepper/plugin_module.cc
+++ b/content/renderer/pepper/plugin_module.cc
@@ -25,7 +25,6 @@
#include "content/renderer/pepper/ppb_image_data_impl.h"
#include "content/renderer/pepper/ppb_proxy_impl.h"
#include "content/renderer/pepper/ppb_scrollbar_impl.h"
-#include "content/renderer/pepper/ppb_uma_private_impl.h"
#include "content/renderer/pepper/ppb_var_deprecated_impl.h"
#include "content/renderer/pepper/ppb_video_decoder_impl.h"
#include "content/renderer/pepper/renderer_ppapi_host_impl.h"
diff --git a/content/renderer/pepper/ppb_uma_private_impl.cc b/content/renderer/pepper/ppb_uma_private_impl.cc
deleted file mode 100644
index ae9fe10..0000000
--- a/content/renderer/pepper/ppb_uma_private_impl.cc
+++ /dev/null
@@ -1,97 +0,0 @@
-// Copyright (c) 2011 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 "content/renderer/pepper/ppb_uma_private_impl.h"
-
-#include "base/metrics/histogram.h"
-#include "ppapi/c/pp_var.h"
-#include "ppapi/c/private/ppb_uma_private.h"
-#include "ppapi/shared_impl/var.h"
-
-using ppapi::StringVar;
-
-namespace content {
-
-namespace {
-
-#define RETURN_IF_BAD_ARGS(_name, _sample, _min, _max, _bucket_count) \
- do { \
- if (_name.type != PP_VARTYPE_STRING || _name.value.as_id == 0) \
- return; \
- if (_min >= _max) \
- return; \
- if (_bucket_count <= 1) \
- return; \
- } while (0)
-
-void HistogramCustomTimes(PP_Var name,
- int64_t sample,
- int64_t min, int64_t max,
- uint32_t bucket_count) {
- RETURN_IF_BAD_ARGS(name, sample, min, max, bucket_count);
-
- StringVar* name_string = StringVar::FromPPVar(name);
- if (name_string == NULL)
- return;
- base::HistogramBase* counter =
- base::Histogram::FactoryTimeGet(
- name_string->value(),
- base::TimeDelta::FromMilliseconds(min),
- base::TimeDelta::FromMilliseconds(max),
- bucket_count,
- base::HistogramBase::kUmaTargetedHistogramFlag);
- counter->AddTime(base::TimeDelta::FromMilliseconds(sample));
-}
-
-void HistogramCustomCounts(PP_Var name,
- int32_t sample,
- int32_t min, int32_t max,
- uint32_t bucket_count) {
- RETURN_IF_BAD_ARGS(name, sample, min, max, bucket_count);
-
- StringVar* name_string = StringVar::FromPPVar(name);
- if (name_string == NULL)
- return;
- base::HistogramBase* counter =
- base::Histogram::FactoryGet(
- name_string->value(),
- min,
- max,
- bucket_count,
- base::HistogramBase::kUmaTargetedHistogramFlag);
- counter->Add(sample);
-}
-
-void HistogramEnumeration(PP_Var name,
- int32_t sample,
- int32_t boundary_value) {
- RETURN_IF_BAD_ARGS(name, sample, 1, boundary_value, boundary_value + 1);
-
- StringVar* name_string = StringVar::FromPPVar(name);
- if (name_string == NULL)
- return;
- base::HistogramBase* counter =
- base::LinearHistogram::FactoryGet(
- name_string->value(),
- 1,
- boundary_value,
- boundary_value + 1,
- base::HistogramBase::kUmaTargetedHistogramFlag);
- counter->Add(sample);
-}
-
-} // namespace
-
-const PPB_UMA_Private ppb_uma = {
- &HistogramCustomTimes,
- &HistogramCustomCounts,
- &HistogramEnumeration,
-};
-
-// static
-const PPB_UMA_Private* PPB_UMA_Private_Impl::GetInterface() {
- return &ppb_uma;
-}
-
-} // namespace content
diff --git a/content/renderer/pepper/ppb_uma_private_impl.h b/content/renderer/pepper/ppb_uma_private_impl.h
deleted file mode 100644
index 91eae47..0000000
--- a/content/renderer/pepper/ppb_uma_private_impl.h
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright (c) 2011 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 CONTENT_RENDERER_PEPPER_PPB_UMA_PRIVATE_IMPL_H_
-#define CONTENT_RENDERER_PEPPER_PPB_UMA_PRIVATE_IMPL_H_
-
-#include "ppapi/c/private/ppb_uma_private.h"
-
-namespace content {
-
-class PPB_UMA_Private_Impl {
- public:
- static const PPB_UMA_Private* GetInterface();
-};
-
-} // namespace content
-
-#endif // CONTENT_RENDERER_PEPPER_PPB_UMA_PRIVATE_IMPL_H_
diff --git a/native_client_sdk/src/libraries/ppapi_cpp_private/library.dsc b/native_client_sdk/src/libraries/ppapi_cpp_private/library.dsc
index 1c5c7cf..19d9fb5 100644
--- a/native_client_sdk/src/libraries/ppapi_cpp_private/library.dsc
+++ b/native_client_sdk/src/libraries/ppapi_cpp_private/library.dsc
@@ -19,6 +19,7 @@
'tcp_socket_private.cc',
'tcp_server_socket_private.cc',
'udp_socket_private.cc',
+ 'uma_private.cc',
'x509_certificate_private.cc',
],
}
@@ -37,6 +38,7 @@
'ppb_tcp_server_socket_private.h',
'ppb_tcp_socket_private.h',
'ppb_udp_socket_private.h',
+ 'ppb_uma_private.h',
'ppb_x509_certificate_private.h',
'pp_file_handle.h',
],
@@ -56,6 +58,7 @@
'tcp_server_socket_private.h',
'tcp_socket_private.h',
'udp_socket_private.h',
+ 'uma_private.h',
'x509_certificate_private.h',
],
'DEST': 'include/ppapi/cpp/private',
diff --git a/ppapi/api/private/ppb_uma_private.idl b/ppapi/api/private/ppb_uma_private.idl
index cdb3908..a115cee 100644
--- a/ppapi/api/private/ppb_uma_private.idl
+++ b/ppapi/api/private/ppb_uma_private.idl
@@ -6,8 +6,11 @@
/**
* This file defines the <code>PPB_UMA_Private</code> interface.
*/
+
+[generate_thunk,thunk_include="ppapi/thunk/ppb_uma_singleton_api.h"]
+
label Chrome {
- M18 = 0.1
+ M33 = 0.2
};
/**
@@ -19,7 +22,9 @@ interface PPB_UMA_Private {
* sample given in milliseconds in the histogram given by |name|, possibly
* creating the histogram if it does not exist.
*/
- void HistogramCustomTimes([in] PP_Var name,
+ [singleton,api=PPB_UMA_Singleton_API]
+ void HistogramCustomTimes([in] PP_Instance instance,
+ [in] PP_Var name,
[in] int64_t sample,
[in] int64_t min,
[in] int64_t max,
@@ -30,7 +35,9 @@ interface PPB_UMA_Private {
* in the histogram given by |name|, possibly creating the histogram if it
* does not exist.
*/
- void HistogramCustomCounts([in] PP_Var name,
+ [singleton,api=PPB_UMA_Singleton_API]
+ void HistogramCustomCounts([in] PP_Instance instance,
+ [in] PP_Var name,
[in] int32_t sample,
[in] int32_t min,
[in] int32_t max,
@@ -42,7 +49,9 @@ interface PPB_UMA_Private {
* does not exist. The sample represents a value in an enumeration bounded
* by |boundary_value|, that is, sample < boundary_value always.
*/
- void HistogramEnumeration([in] PP_Var name,
+ [singleton,api=PPB_UMA_Singleton_API]
+ void HistogramEnumeration([in] PP_Instance instance,
+ [in] PP_Var name,
[in] int32_t sample,
[in] int32_t boundary_value);
};
diff --git a/ppapi/c/private/ppb_uma_private.h b/ppapi/c/private/ppb_uma_private.h
index b681add..c23ba99 100644
--- a/ppapi/c/private/ppb_uma_private.h
+++ b/ppapi/c/private/ppb_uma_private.h
@@ -3,18 +3,19 @@
* found in the LICENSE file.
*/
-/* From private/ppb_uma_private.idl modified Tue Oct 2 13:17:06 2012. */
+/* From private/ppb_uma_private.idl modified Mon Nov 18 14:39:43 2013. */
#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_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_1 "PPB_UMA_Private;0.1"
-#define PPB_UMA_PRIVATE_INTERFACE PPB_UMA_PRIVATE_INTERFACE_0_1
+#define PPB_UMA_PRIVATE_INTERFACE_0_2 "PPB_UMA_Private;0.2"
+#define PPB_UMA_PRIVATE_INTERFACE PPB_UMA_PRIVATE_INTERFACE_0_2
/**
* @file
@@ -29,13 +30,14 @@
/**
* Contains functions for plugins to report UMA usage stats.
*/
-struct PPB_UMA_Private_0_1 {
+struct PPB_UMA_Private_0_2 {
/**
* HistogramCustomTimes is a pointer to a function which records a time
* sample given in milliseconds in the histogram given by |name|, possibly
* creating the histogram if it does not exist.
*/
- void (*HistogramCustomTimes)(struct PP_Var name,
+ void (*HistogramCustomTimes)(PP_Instance instance,
+ struct PP_Var name,
int64_t sample,
int64_t min,
int64_t max,
@@ -45,7 +47,8 @@ struct PPB_UMA_Private_0_1 {
* in the histogram given by |name|, possibly creating the histogram if it
* does not exist.
*/
- void (*HistogramCustomCounts)(struct PP_Var name,
+ void (*HistogramCustomCounts)(PP_Instance instance,
+ struct PP_Var name,
int32_t sample,
int32_t min,
int32_t max,
@@ -56,12 +59,13 @@ struct PPB_UMA_Private_0_1 {
* does not exist. The sample represents a value in an enumeration bounded
* by |boundary_value|, that is, sample < boundary_value always.
*/
- void (*HistogramEnumeration)(struct PP_Var name,
+ void (*HistogramEnumeration)(PP_Instance instance,
+ struct PP_Var name,
int32_t sample,
int32_t boundary_value);
};
-typedef struct PPB_UMA_Private_0_1 PPB_UMA_Private;
+typedef struct PPB_UMA_Private_0_2 PPB_UMA_Private;
/**
* @}
*/
diff --git a/ppapi/cpp/private/uma_private.cc b/ppapi/cpp/private/uma_private.cc
new file mode 100644
index 0000000..ed8b6e9
--- /dev/null
+++ b/ppapi/cpp/private/uma_private.cc
@@ -0,0 +1,70 @@
+// Copyright 2014 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/private/uma_private.h"
+
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/private/ppb_uma_private.h"
+#include "ppapi/cpp/module_impl.h"
+#include "ppapi/cpp/var.h"
+
+namespace pp {
+
+namespace {
+
+template <> const char* interface_name<PPB_UMA_Private_0_2>() {
+ return PPB_UMA_PRIVATE_INTERFACE_0_2;
+}
+
+} // namespace
+
+UMAPrivate::UMAPrivate() {
+}
+
+UMAPrivate::UMAPrivate(
+ const InstanceHandle& instance) : instance_(instance.pp_instance()) {
+}
+
+UMAPrivate::~UMAPrivate() {
+}
+
+bool UMAPrivate::IsAvailable() {
+ return has_interface<PPB_UMA_Private_0_2>();
+}
+
+void UMAPrivate::HistogramCustomTimes(const std::string& name,
+ int64_t sample,
+ int64_t min,
+ int64_t max,
+ uint32_t bucket_count) {
+ if (!IsAvailable())
+ return;
+ get_interface<PPB_UMA_Private_0_2>()->
+ HistogramCustomTimes(instance_, pp::Var(name).pp_var(),
+ sample, min, max, bucket_count);
+}
+
+void UMAPrivate::HistogramCustomCounts(const std::string& name,
+ int32_t sample,
+ int32_t min,
+ int32_t max,
+ uint32_t bucket_count) {
+ if (!IsAvailable())
+ return;
+ get_interface<PPB_UMA_Private_0_2>()->
+ HistogramCustomCounts(instance_, pp::Var(name).pp_var(),
+ sample, min, max, bucket_count);
+}
+
+void UMAPrivate::HistogramEnumeration(const std::string& name,
+ int32_t sample,
+ int32_t boundary_value) {
+ if (!IsAvailable())
+ return;
+ get_interface<PPB_UMA_Private_0_2>()->
+ HistogramEnumeration(instance_, pp::Var(name).pp_var(),
+ sample, boundary_value);
+}
+
+} // namespace pp
diff --git a/ppapi/cpp/private/uma_private.h b/ppapi/cpp/private/uma_private.h
new file mode 100644
index 0000000..23de400
--- /dev/null
+++ b/ppapi/cpp/private/uma_private.h
@@ -0,0 +1,45 @@
+// Copyright 2014 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_PRIVATE_UMA_PRIVATE_H_
+#define PPAPI_CPP_PRIVATE_UMA_PRIVATE_H_
+
+#include <string>
+
+#include "ppapi/c/pp_instance.h"
+#include "ppapi/cpp/instance_handle.h"
+
+namespace pp {
+
+class UMAPrivate {
+ public:
+ UMAPrivate();
+ explicit UMAPrivate(const InstanceHandle& instance);
+ ~UMAPrivate();
+
+ static bool IsAvailable();
+
+ void HistogramCustomTimes(const std::string& name,
+ int64_t sample,
+ int64_t min,
+ int64_t max,
+ uint32_t bucket_count);
+
+ void HistogramCustomCounts(const std::string& name,
+ int32_t sample,
+ int32_t min,
+ int32_t max,
+ uint32_t bucket_count);
+
+ void HistogramEnumeration(const std::string& name,
+ int32_t sample,
+ int32_t boundary_value);
+
+ private:
+ PP_Instance instance_;
+};
+
+} // namespace pp
+
+#endif // PPAPI_CPP_PRIVATE_UMA_PRIVATE_H_
diff --git a/ppapi/native_client/src/trusted/plugin/plugin.cc b/ppapi/native_client/src/trusted/plugin/plugin.cc
index 2bf3021..3309d65 100644
--- a/ppapi/native_client/src/trusted/plugin/plugin.cc
+++ b/ppapi/native_client/src/trusted/plugin/plugin.cc
@@ -34,7 +34,6 @@
#include "ppapi/c/ppb_var.h"
#include "ppapi/c/ppp_instance.h"
#include "ppapi/c/private/ppb_nacl_private.h"
-#include "ppapi/c/private/ppb_uma_private.h"
#include "ppapi/cpp/dev/url_util_dev.h"
#include "ppapi/cpp/module.h"
#include "ppapi/cpp/text_input_controller.h"
@@ -104,63 +103,108 @@ const PPB_NaCl_Private* GetNaClInterface() {
module->GetBrowserInterface(PPB_NACL_PRIVATE_INTERFACE));
}
-const PPB_UMA_Private* GetUMAInterface() {
- pp::Module *module = pp::Module::Get();
- CHECK(module);
- return static_cast<const PPB_UMA_Private*>(
- module->GetBrowserInterface(PPB_UMA_PRIVATE_INTERFACE));
-}
+} // namespace
-void HistogramTimeSmall(const std::string& name, int64_t ms) {
- if (ms < 0) return;
+bool Plugin::EarlyInit(int argc, const char* argn[], const char* argv[]) {
+ PLUGIN_PRINTF(("Plugin::EarlyInit (instance=%p)\n",
+ static_cast<void*>(this)));
+
+#ifdef NACL_OSX
+ // TODO(kochi): For crbug.com/102808, this is a stopgap solution for Lion
+ // until we expose IME API to .nexe. This disables any IME interference
+ // against key inputs, so you cannot use off-the-spot IME input for NaCl apps.
+ // This makes discrepancy among platforms and therefore we should remove
+ // this hack when IME API is made available.
+ // The default for non-Mac platforms is still off-the-spot IME mode.
+ pp::TextInputController(this).SetTextInputType(PP_TEXTINPUT_TYPE_NONE);
+#endif
+
+ // Remember the embed/object argn/argv pairs.
+ argn_ = new char*[argc];
+ argv_ = new char*[argc];
+ argc_ = 0;
+ for (int i = 0; i < argc; ++i) {
+ if (NULL != argn_ && NULL != argv_) {
+ argn_[argc_] = strdup(argn[i]);
+ argv_[argc_] = strdup(argv[i]);
+ if (NULL == argn_[argc_] || NULL == argv_[argc_]) {
+ // Give up on passing arguments.
+ free(argn_[argc_]);
+ free(argv_[argc_]);
+ continue;
+ }
+ ++argc_;
+ }
+ }
+ // TODO(sehr): this leaks strings if there is a subsequent failure.
- const PPB_UMA_Private* ptr = GetUMAInterface();
- if (ptr == NULL) return;
+ // Set up the factory used to produce DescWrappers.
+ wrapper_factory_ = new nacl::DescWrapperFactory();
+ if (NULL == wrapper_factory_) {
+ return false;
+ }
+ PLUGIN_PRINTF(("Plugin::Init (wrapper_factory=%p)\n",
+ static_cast<void*>(wrapper_factory_)));
- ptr->HistogramCustomTimes(pp::Var(name).pp_var(),
- ms,
- kTimeSmallMin, kTimeSmallMax,
- kTimeSmallBuckets);
+ PLUGIN_PRINTF(("Plugin::Init (return 1)\n"));
+ // Return success.
+ return true;
}
-void HistogramTimeMedium(const std::string& name, int64_t ms) {
- if (ms < 0) return;
+void Plugin::ShutDownSubprocesses() {
+ PLUGIN_PRINTF(("Plugin::ShutDownSubprocesses (this=%p)\n",
+ static_cast<void*>(this)));
+ PLUGIN_PRINTF(("Plugin::ShutDownSubprocesses (%s)\n",
+ main_subprocess_.detailed_description().c_str()));
- const PPB_UMA_Private* ptr = GetUMAInterface();
- if (ptr == NULL) return;
+ // Shut down service runtime. This must be done before all other calls so
+ // they don't block forever when waiting for the upcall thread to exit.
+ main_subprocess_.Shutdown();
- ptr->HistogramCustomTimes(pp::Var(name).pp_var(),
- ms,
- kTimeMediumMin, kTimeMediumMax,
- kTimeMediumBuckets);
+ PLUGIN_PRINTF(("Plugin::ShutDownSubprocess (this=%p, return)\n",
+ static_cast<void*>(this)));
}
-void HistogramTimeLarge(const std::string& name, int64_t ms) {
+void Plugin::HistogramTimeSmall(const std::string& name,
+ int64_t ms) {
if (ms < 0) return;
+ uma_interface_.HistogramCustomTimes(name,
+ ms,
+ kTimeSmallMin, kTimeSmallMax,
+ kTimeSmallBuckets);
+}
- const PPB_UMA_Private* ptr = GetUMAInterface();
- if (ptr == NULL) return;
+void Plugin::HistogramTimeMedium(const std::string& name,
+ int64_t ms) {
+ if (ms < 0) return;
+ uma_interface_.HistogramCustomTimes(name,
+ ms,
+ kTimeMediumMin, kTimeMediumMax,
+ kTimeMediumBuckets);
+}
- ptr->HistogramCustomTimes(pp::Var(name).pp_var(),
- ms,
- kTimeLargeMin, kTimeLargeMax,
- kTimeLargeBuckets);
+void Plugin::HistogramTimeLarge(const std::string& name,
+ int64_t ms) {
+ if (ms < 0) return;
+ uma_interface_.HistogramCustomTimes(name,
+ ms,
+ kTimeLargeMin, kTimeLargeMax,
+ kTimeLargeBuckets);
}
-void HistogramSizeKB(const std::string& name, int32_t sample) {
+void Plugin::HistogramSizeKB(const std::string& name,
+ int32_t sample) {
if (sample < 0) return;
-
- const PPB_UMA_Private* ptr = GetUMAInterface();
- if (ptr == NULL) return;
-
- ptr->HistogramCustomCounts(pp::Var(name).pp_var(),
- sample,
- kSizeKBMin, kSizeKBMax,
- kSizeKBBuckets);
+ uma_interface_.HistogramCustomCounts(name,
+ sample,
+ kSizeKBMin, kSizeKBMax,
+ kSizeKBBuckets);
}
-void HistogramEnumerate(const std::string& name, int sample, int maximum,
- int out_of_range_replacement) {
+void Plugin::HistogramEnumerate(const std::string& name,
+ int sample,
+ int maximum,
+ int out_of_range_replacement) {
if (sample < 0 || sample >= maximum) {
if (out_of_range_replacement < 0)
// No replacement for bad input, abort.
@@ -169,12 +213,10 @@ void HistogramEnumerate(const std::string& name, int sample, int maximum,
// Use a specific value to signal a bad input.
sample = out_of_range_replacement;
}
- const PPB_UMA_Private* ptr = GetUMAInterface();
- if (ptr == NULL) return;
- ptr->HistogramEnumeration(pp::Var(name).pp_var(), sample, maximum);
+ uma_interface_.HistogramEnumeration(name, sample, maximum);
}
-void HistogramEnumerateOsArch(const std::string& sandbox_isa) {
+void Plugin::HistogramEnumerateOsArch(const std::string& sandbox_isa) {
enum NaClOSArch {
kNaClLinux32 = 0,
kNaClLinux64,
@@ -205,22 +247,21 @@ void HistogramEnumerateOsArch(const std::string& sandbox_isa) {
HistogramEnumerate("NaCl.Client.OSArch", os_arch, kNaClOSArchMax, -1);
}
-void HistogramEnumerateLoadStatus(PluginErrorCode error_code,
- bool is_installed) {
+void Plugin::HistogramEnumerateLoadStatus(PluginErrorCode error_code,
+ bool is_installed) {
HistogramEnumerate("NaCl.LoadStatus.Plugin", error_code, ERROR_MAX,
ERROR_UNKNOWN);
// Gather data to see if being installed changes load outcomes.
const char* name = is_installed ? "NaCl.LoadStatus.Plugin.InstalledApp" :
"NaCl.LoadStatus.Plugin.NotInstalledApp";
- HistogramEnumerate(name, error_code, ERROR_MAX,
- ERROR_UNKNOWN);
+ HistogramEnumerate(name, error_code, ERROR_MAX, ERROR_UNKNOWN);
}
-void HistogramEnumerateSelLdrLoadStatus(NaClErrorCode error_code,
- bool is_installed) {
- HistogramEnumerate("NaCl.LoadStatus.SelLdr", error_code, NACL_ERROR_CODE_MAX,
- LOAD_STATUS_UNKNOWN);
+void Plugin::HistogramEnumerateSelLdrLoadStatus(NaClErrorCode error_code,
+ bool is_installed) {
+ HistogramEnumerate("NaCl.LoadStatus.SelLdr", error_code,
+ NACL_ERROR_CODE_MAX, LOAD_STATUS_UNKNOWN);
// Gather data to see if being installed changes load outcomes.
const char* name = is_installed ? "NaCl.LoadStatus.SelLdr.InstalledApp" :
@@ -229,11 +270,12 @@ void HistogramEnumerateSelLdrLoadStatus(NaClErrorCode error_code,
LOAD_STATUS_UNKNOWN);
}
-void HistogramEnumerateManifestIsDataURI(bool is_data_uri) {
+void Plugin::HistogramEnumerateManifestIsDataURI(bool is_data_uri) {
HistogramEnumerate("NaCl.Manifest.IsDataURI", is_data_uri, 2, -1);
}
-void HistogramHTTPStatusCode(const std::string& name, int status) {
+void Plugin::HistogramHTTPStatusCode(const std::string& name,
+ int status) {
// Log the status codes in rough buckets - 1XX, 2XX, etc.
int sample = status / 100;
// HTTP status codes only go up to 5XX, using "6" to indicate an internal
@@ -244,84 +286,6 @@ void HistogramHTTPStatusCode(const std::string& name, int status) {
HistogramEnumerate(name, sample, 7, 6);
}
-} // namespace
-
-bool Plugin::EarlyInit(int argc, const char* argn[], const char* argv[]) {
- PLUGIN_PRINTF(("Plugin::EarlyInit (instance=%p)\n",
- static_cast<void*>(this)));
-
-#ifdef NACL_OSX
- // TODO(kochi): For crbug.com/102808, this is a stopgap solution for Lion
- // until we expose IME API to .nexe. This disables any IME interference
- // against key inputs, so you cannot use off-the-spot IME input for NaCl apps.
- // This makes discrepancy among platforms and therefore we should remove
- // this hack when IME API is made available.
- // The default for non-Mac platforms is still off-the-spot IME mode.
- pp::TextInputController(this).SetTextInputType(PP_TEXTINPUT_TYPE_NONE);
-#endif
-
- // Remember the embed/object argn/argv pairs.
- argn_ = new char*[argc];
- argv_ = new char*[argc];
- argc_ = 0;
- for (int i = 0; i < argc; ++i) {
- if (NULL != argn_ && NULL != argv_) {
- argn_[argc_] = strdup(argn[i]);
- argv_[argc_] = strdup(argv[i]);
- if (NULL == argn_[argc_] || NULL == argv_[argc_]) {
- // Give up on passing arguments.
- free(argn_[argc_]);
- free(argv_[argc_]);
- continue;
- }
- ++argc_;
- }
- }
- // TODO(sehr): this leaks strings if there is a subsequent failure.
-
- // Set up the factory used to produce DescWrappers.
- wrapper_factory_ = new nacl::DescWrapperFactory();
- if (NULL == wrapper_factory_) {
- return false;
- }
- PLUGIN_PRINTF(("Plugin::Init (wrapper_factory=%p)\n",
- static_cast<void*>(wrapper_factory_)));
-
- PLUGIN_PRINTF(("Plugin::Init (return 1)\n"));
- // Return success.
- return true;
-}
-
-void Plugin::ShutDownSubprocesses() {
- PLUGIN_PRINTF(("Plugin::ShutDownSubprocesses (this=%p)\n",
- static_cast<void*>(this)));
- PLUGIN_PRINTF(("Plugin::ShutDownSubprocesses (%s)\n",
- main_subprocess_.detailed_description().c_str()));
-
- // Shut down service runtime. This must be done before all other calls so
- // they don't block forever when waiting for the upcall thread to exit.
- main_subprocess_.Shutdown();
-
- PLUGIN_PRINTF(("Plugin::ShutDownSubprocess (this=%p, return)\n",
- static_cast<void*>(this)));
-}
-
-void Plugin::StartSelLdrOnMainThread(int32_t pp_error,
- ServiceRuntime* service_runtime,
- const SelLdrStartParams& params,
- bool* success) {
- if (pp_error != PP_OK) {
- PLUGIN_PRINTF(("Plugin::StartSelLdrOnMainThread: non-PP_OK arg "
- "-- SHOULD NOT HAPPEN\n"));
- *success = false;
- return;
- }
- *success = service_runtime->StartSelLdr(params);
- // Signal outside of StartSelLdr here, so that the write to *success
- // is done before signaling.
- service_runtime->SignalStartSelLdrDone();
-}
-
bool Plugin::LoadNaClModuleCommon(nacl::DescWrapper* wrapper,
NaClSubprocess* subprocess,
const Manifest* manifest,
@@ -374,6 +338,22 @@ bool Plugin::LoadNaClModuleCommon(nacl::DescWrapper* wrapper,
return true;
}
+void Plugin::StartSelLdrOnMainThread(int32_t pp_error,
+ ServiceRuntime* service_runtime,
+ const SelLdrStartParams& params,
+ bool* success) {
+ if (pp_error != PP_OK) {
+ PLUGIN_PRINTF(("Plugin::StartSelLdrOnMainThread: non-PP_OK arg "
+ "-- SHOULD NOT HAPPEN\n"));
+ *success = false;
+ return;
+ }
+ *success = service_runtime->StartSelLdr(params);
+ // Signal outside of StartSelLdr here, so that the write to *success
+ // is done before signaling.
+ service_runtime->SignalStartSelLdrDone();
+}
+
bool Plugin::LoadNaClModule(nacl::DescWrapper* wrapper,
ErrorInfo* error_info,
bool enable_dyncode_syscalls,
@@ -651,7 +631,8 @@ Plugin::Plugin(PP_Instance pp_instance)
nexe_size_(0),
time_of_last_progress_event_(0),
exit_status_(-1),
- nacl_interface_(NULL) {
+ nacl_interface_(NULL),
+ uma_interface_(this) {
PLUGIN_PRINTF(("Plugin::Plugin (this=%p, pp_instance=%"
NACL_PRId32 ")\n", static_cast<void*>(this), pp_instance));
callback_factory_.Initialize(this);
@@ -1309,7 +1290,6 @@ void Plugin::ReportLoadSuccess(LengthComputable length_computable,
}
-// TODO(ncbray): report UMA stats
void Plugin::ReportLoadError(const ErrorInfo& error_info) {
PLUGIN_PRINTF(("Plugin::ReportLoadError (error='%s')\n",
error_info.message().c_str()));
diff --git a/ppapi/native_client/src/trusted/plugin/plugin.h b/ppapi/native_client/src/trusted/plugin/plugin.h
index ca83489..240d314 100644
--- a/ppapi/native_client/src/trusted/plugin/plugin.h
+++ b/ppapi/native_client/src/trusted/plugin/plugin.h
@@ -23,6 +23,7 @@
#include "ppapi/c/private/ppb_nacl_private.h"
#include "ppapi/cpp/private/instance_private.h"
+#include "ppapi/cpp/private/uma_private.h"
#include "ppapi/cpp/url_loader.h"
#include "ppapi/cpp/var.h"
#include "ppapi/cpp/view.h"
@@ -253,6 +254,7 @@ class Plugin : public pp::InstancePrivate {
void set_exit_status(int exit_status);
const PPB_NaCl_Private* nacl_interface() const { return nacl_interface_; }
+ pp::UMAPrivate& uma_interface() { return uma_interface_; }
private:
NACL_DISALLOW_COPY_AND_ASSIGN(Plugin);
@@ -278,6 +280,24 @@ class Plugin : public pp::InstancePrivate {
return main_subprocess_.service_runtime();
}
+ // Histogram helper functions, internal to Plugin so they can use
+ // uma_interface_ normally.
+ void HistogramTimeSmall(const std::string& name, int64_t ms);
+ void HistogramTimeMedium(const std::string& name, int64_t ms);
+ void HistogramTimeLarge(const std::string& name, int64_t ms);
+ void HistogramSizeKB(const std::string& name, int32_t sample);
+ void HistogramEnumerate(const std::string& name,
+ int sample,
+ int maximum,
+ int out_of_range_replacement);
+ void HistogramEnumerateOsArch(const std::string& sandbox_isa);
+ void HistogramEnumerateLoadStatus(PluginErrorCode error_code,
+ bool is_installed);
+ void HistogramEnumerateSelLdrLoadStatus(NaClErrorCode error_code,
+ bool is_installed);
+ void HistogramEnumerateManifestIsDataURI(bool is_data_uri);
+ void HistogramHTTPStatusCode(const std::string& name, int status);
+
// Help load a nacl module, from the file specified in wrapper.
// This will fully initialize the |subprocess| if the load was successful.
bool LoadNaClModuleCommon(nacl::DescWrapper* wrapper,
@@ -465,6 +485,7 @@ class Plugin : public pp::InstancePrivate {
int exit_status_;
const PPB_NaCl_Private* nacl_interface_;
+ pp::UMAPrivate uma_interface_;
};
} // namespace plugin
diff --git a/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc b/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc
index f892059..9e96f0d 100644
--- a/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc
+++ b/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc
@@ -121,85 +121,56 @@ const int32_t kKBPSMin = 1;
const int32_t kKBPSMax = 30*1000; // max of 30 MB / sec.
const uint32_t kKBPSBuckets = 100;
-const PPB_UMA_Private* uma_interface = NULL;
-
-const PPB_UMA_Private* GetUMAInterface() {
- if (uma_interface != NULL) {
- return uma_interface;
- }
- pp::Module *module = pp::Module::Get();
- DCHECK(module);
- uma_interface = static_cast<const PPB_UMA_Private*>(
- module->GetBrowserInterface(PPB_UMA_PRIVATE_INTERFACE));
- return uma_interface;
-}
-
-void HistogramTime(const std::string& name, int64_t ms) {
+void HistogramTime(pp::UMAPrivate& uma,
+ const std::string& name, int64_t ms) {
if (ms < 0) return;
-
- const PPB_UMA_Private* ptr = GetUMAInterface();
- if (ptr == NULL) return;
-
- ptr->HistogramCustomTimes(pp::Var(name).pp_var(),
- ms,
- kTimeLargeMin, kTimeLargeMax,
- kTimeLargeBuckets);
+ uma.HistogramCustomTimes(name,
+ ms,
+ kTimeLargeMin, kTimeLargeMax,
+ kTimeLargeBuckets);
}
-void HistogramSizeKB(const std::string& name, int32_t kb) {
+void HistogramSizeKB(pp::UMAPrivate& uma,
+ const std::string& name, int32_t kb) {
if (kb < 0) return;
-
- const PPB_UMA_Private* ptr = GetUMAInterface();
- if (ptr == NULL) return;
-
- ptr->HistogramCustomCounts(pp::Var(name).pp_var(),
- kb,
- kSizeKBMin, kSizeKBMax,
- kSizeKBBuckets);
+ uma.HistogramCustomCounts(name,
+ kb,
+ kSizeKBMin, kSizeKBMax,
+ kSizeKBBuckets);
}
-void HistogramRatio(const std::string& name, int64_t a, int64_t b) {
+void HistogramRatio(pp::UMAPrivate& uma,
+ const std::string& name, int64_t a, int64_t b) {
if (a < 0 || b <= 0) return;
-
- const PPB_UMA_Private* ptr = GetUMAInterface();
- if (ptr == NULL) return;
-
- ptr->HistogramCustomCounts(pp::Var(name).pp_var(),
- 100 * a / b,
- kRatioMin, kRatioMax,
- kRatioBuckets);
+ uma.HistogramCustomCounts(name,
+ 100 * a / b,
+ kRatioMin, kRatioMax,
+ kRatioBuckets);
}
-void HistogramKBPerSec(const std::string& name, double kb, double s) {
+void HistogramKBPerSec(pp::UMAPrivate& uma,
+ const std::string& name, double kb, double s) {
if (kb < 0.0 || s <= 0.0) return;
-
- const PPB_UMA_Private* ptr = GetUMAInterface();
- if (ptr == NULL) return;
-
- ptr->HistogramCustomCounts(pp::Var(name).pp_var(),
- static_cast<int64_t>(kb / s),
- kKBPSMin, kKBPSMax,
- kKBPSBuckets);
+ uma.HistogramCustomCounts(name,
+ static_cast<int64_t>(kb / s),
+ kKBPSMin, kKBPSMax,
+ kKBPSBuckets);
}
-void HistogramEnumerateTranslationCache(bool hit) {
- const PPB_UMA_Private* ptr = GetUMAInterface();
- if (ptr == NULL) return;
- ptr->HistogramEnumeration(pp::Var("NaCl.Perf.PNaClCache.IsHit").pp_var(),
- hit, 2);
+void HistogramEnumerateTranslationCache(pp::UMAPrivate& uma, bool hit) {
+ uma.HistogramEnumeration("NaCl.Perf.PNaClCache.IsHit",
+ hit, 2);
}
// Opt level is expected to be 0 to 3. Treating 4 as unknown.
const int8_t kOptUnknown = 4;
-void HistogramOptLevel(int8_t opt_level) {
- const PPB_UMA_Private* ptr = GetUMAInterface();
- if (ptr == NULL) return;
+void HistogramOptLevel(pp::UMAPrivate& uma, int8_t opt_level) {
if (opt_level < 0 || opt_level > 3) {
opt_level = kOptUnknown;
}
- ptr->HistogramEnumeration(pp::Var("NaCl.Options.PNaCl.OptLevel").pp_var(),
- opt_level, kOptUnknown+1);
+ uma.HistogramEnumeration("NaCl.Options.PNaCl.OptLevel",
+ opt_level, kOptUnknown+1);
}
} // namespace
@@ -347,20 +318,22 @@ void PnaclCoordinator::TranslateFinished(int32_t pp_error) {
}
// If there are no errors, report stats from this thread (the main thread).
- HistogramOptLevel(pnacl_options_.opt_level());
+ HistogramOptLevel(plugin_->uma_interface(), pnacl_options_.opt_level());
const plugin::PnaclTimeStats& time_stats = translate_thread_->GetTimeStats();
- HistogramTime("NaCl.Perf.PNaClLoadTime.LoadCompiler",
+ HistogramTime(plugin_->uma_interface(),
+ "NaCl.Perf.PNaClLoadTime.LoadCompiler",
time_stats.pnacl_llc_load_time / NACL_MICROS_PER_MILLI);
- HistogramTime("NaCl.Perf.PNaClLoadTime.CompileTime",
+ HistogramTime(plugin_->uma_interface(), "NaCl.Perf.PNaClLoadTime.CompileTime",
time_stats.pnacl_compile_time / NACL_MICROS_PER_MILLI);
- HistogramKBPerSec("NaCl.Perf.PNaClLoadTime.CompileKBPerSec",
+ HistogramKBPerSec(plugin_->uma_interface(),
+ "NaCl.Perf.PNaClLoadTime.CompileKBPerSec",
pexe_size_ / 1024.0,
time_stats.pnacl_compile_time / 1000000.0);
- HistogramTime("NaCl.Perf.PNaClLoadTime.LoadLinker",
+ HistogramTime(plugin_->uma_interface(), "NaCl.Perf.PNaClLoadTime.LoadLinker",
time_stats.pnacl_ld_load_time / NACL_MICROS_PER_MILLI);
- HistogramTime("NaCl.Perf.PNaClLoadTime.LinkTime",
+ HistogramTime(plugin_->uma_interface(), "NaCl.Perf.PNaClLoadTime.LinkTime",
time_stats.pnacl_link_time / NACL_MICROS_PER_MILLI);
- HistogramSizeKB("NaCl.Perf.Size.Pexe",
+ HistogramSizeKB(plugin_->uma_interface(), "NaCl.Perf.Size.Pexe",
static_cast<int64_t>(pexe_size_ / 1024));
struct nacl_abi_stat stbuf;
@@ -371,15 +344,19 @@ void PnaclCoordinator::TranslateFinished(int32_t pp_error) {
PLUGIN_PRINTF(("PnaclCoordinator::TranslateFinished can't stat nexe.\n"));
} else {
size_t nexe_size = stbuf.nacl_abi_st_size;
- HistogramSizeKB("NaCl.Perf.Size.PNaClTranslatedNexe",
+ HistogramSizeKB(plugin_->uma_interface(),
+ "NaCl.Perf.Size.PNaClTranslatedNexe",
static_cast<int64_t>(nexe_size / 1024));
- HistogramRatio("NaCl.Perf.Size.PexeNexeSizePct", pexe_size_, nexe_size);
+ HistogramRatio(plugin_->uma_interface(),
+ "NaCl.Perf.Size.PexeNexeSizePct", pexe_size_, nexe_size);
}
int64_t total_time = NaClGetTimeOfDayMicroseconds() - pnacl_init_time_;
- HistogramTime("NaCl.Perf.PNaClLoadTime.TotalUncachedTime",
+ HistogramTime(plugin_->uma_interface(),
+ "NaCl.Perf.PNaClLoadTime.TotalUncachedTime",
total_time / NACL_MICROS_PER_MILLI);
- HistogramKBPerSec("NaCl.Perf.PNaClLoadTime.TotalUncachedKBPerSec",
+ HistogramKBPerSec(plugin_->uma_interface(),
+ "NaCl.Perf.PNaClLoadTime.TotalUncachedKBPerSec",
pexe_size_ / 1024.0,
total_time / 1000000.0);
@@ -542,7 +519,7 @@ void PnaclCoordinator::NexeFdDidOpen(int32_t pp_error) {
"PnaclCoordinator: Got bad temp file handle from GetNexeFd"));
return;
}
- HistogramEnumerateTranslationCache(is_cache_hit_);
+ HistogramEnumerateTranslationCache(plugin_->uma_interface(), is_cache_hit_);
if (is_cache_hit_ == PP_TRUE) {
// Cache hit -- no need to stream the rest of the file.
@@ -592,7 +569,8 @@ void PnaclCoordinator::BitcodeStreamDidFinish(int32_t pp_error) {
translate_thread_->AbortSubprocesses();
} else {
// Compare download completion pct (100% now), to compile completion pct.
- HistogramRatio("NaCl.Perf.PNaClLoadTime.PctCompiledWhenFullyDownloaded",
+ HistogramRatio(plugin_->uma_interface(),
+ "NaCl.Perf.PNaClLoadTime.PctCompiledWhenFullyDownloaded",
pexe_bytes_compiled_, pexe_size_);
}
}
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 ecc08a4..fdb9434 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
@@ -233,7 +233,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_1;
+static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_UMA_Private_0_2;
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;
@@ -3762,24 +3762,24 @@ 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_1 */
+/* Begin wrapper methods for PPB_UMA_Private_0_2 */
-static void Pnacl_M18_PPB_UMA_Private_HistogramCustomTimes(struct PP_Var* name, int64_t sample, int64_t min, int64_t max, uint32_t bucket_count) {
- const struct PPB_UMA_Private_0_1 *iface = Pnacl_WrapperInfo_PPB_UMA_Private_0_1.real_iface;
- iface->HistogramCustomTimes(*name, sample, min, max, bucket_count);
+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;
+ iface->HistogramCustomTimes(instance, *name, sample, min, max, bucket_count);
}
-static void Pnacl_M18_PPB_UMA_Private_HistogramCustomCounts(struct PP_Var* name, int32_t sample, int32_t min, int32_t max, uint32_t bucket_count) {
- const struct PPB_UMA_Private_0_1 *iface = Pnacl_WrapperInfo_PPB_UMA_Private_0_1.real_iface;
- iface->HistogramCustomCounts(*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;
+ iface->HistogramCustomCounts(instance, *name, sample, min, max, bucket_count);
}
-static void Pnacl_M18_PPB_UMA_Private_HistogramEnumeration(struct PP_Var* name, int32_t sample, int32_t boundary_value) {
- const struct PPB_UMA_Private_0_1 *iface = Pnacl_WrapperInfo_PPB_UMA_Private_0_1.real_iface;
- iface->HistogramEnumeration(*name, sample, boundary_value);
+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;
+ iface->HistogramEnumeration(instance, *name, sample, boundary_value);
}
-/* End wrapper methods for PPB_UMA_Private_0_1 */
+/* End wrapper methods for PPB_UMA_Private_0_2 */
/* Begin wrapper methods for PPB_VideoDestination_Private_0_1 */
@@ -5138,10 +5138,10 @@ static struct PPB_UDPSocket_Private_0_4 Pnacl_Wrappers_PPB_UDPSocket_Private_0_4
.Close = (void (*)(PP_Resource udp_socket))&Pnacl_M23_PPB_UDPSocket_Private_Close
};
-static struct PPB_UMA_Private_0_1 Pnacl_Wrappers_PPB_UMA_Private_0_1 = {
- .HistogramCustomTimes = (void (*)(struct PP_Var name, int64_t sample, int64_t min, int64_t max, uint32_t bucket_count))&Pnacl_M18_PPB_UMA_Private_HistogramCustomTimes,
- .HistogramCustomCounts = (void (*)(struct PP_Var name, int32_t sample, int32_t min, int32_t max, uint32_t bucket_count))&Pnacl_M18_PPB_UMA_Private_HistogramCustomCounts,
- .HistogramEnumeration = (void (*)(struct PP_Var name, int32_t sample, int32_t boundary_value))&Pnacl_M18_PPB_UMA_Private_HistogramEnumeration
+static 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 struct PPB_VideoDestination_Private_0_1 Pnacl_Wrappers_PPB_VideoDestination_Private_0_1 = {
@@ -5795,9 +5795,9 @@ static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_UDPSocket_Private_0_4 = {
.real_iface = NULL
};
-static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_UMA_Private_0_1 = {
- .iface_macro = PPB_UMA_PRIVATE_INTERFACE_0_1,
- .wrapped_iface = (void *) &Pnacl_Wrappers_PPB_UMA_Private_0_1,
+static struct __PnaclWrapperInfo Pnacl_WrapperInfo_PPB_UMA_Private_0_2 = {
+ .iface_macro = PPB_UMA_PRIVATE_INTERFACE_0_2,
+ .wrapped_iface = (void *) &Pnacl_Wrappers_PPB_UMA_Private_0_2,
.real_iface = NULL
};
@@ -5936,7 +5936,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_1,
+ &Pnacl_WrapperInfo_PPB_UMA_Private_0_2,
&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/ppapi_proxy.gypi b/ppapi/ppapi_proxy.gypi
index 6821ea4..1edd49a 100644
--- a/ppapi/ppapi_proxy.gypi
+++ b/ppapi/ppapi_proxy.gypi
@@ -204,6 +204,8 @@
'proxy/udp_socket_resource.h',
'proxy/udp_socket_resource_base.cc',
'proxy/udp_socket_resource_base.h',
+ 'proxy/uma_private_resource.cc',
+ 'proxy/uma_private_resource.h',
'proxy/url_loader_resource.cc',
'proxy/url_loader_resource.h',
'proxy/url_request_info_resource.cc',
diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi
index 18bcc1b..eda3de1 100644
--- a/ppapi/ppapi_shared.gypi
+++ b/ppapi/ppapi_shared.gypi
@@ -250,6 +250,8 @@
'thunk/ppb_udp_socket_thunk.cc',
'thunk/ppb_udp_socket_private_api.h',
'thunk/ppb_udp_socket_private_thunk.cc',
+ 'thunk/ppb_uma_private_thunk.cc',
+ 'thunk/ppb_uma_singleton_api.h',
'thunk/ppb_url_loader_api.h',
'thunk/ppb_url_loader_thunk.cc',
'thunk/ppb_url_loader_trusted_thunk.cc',
diff --git a/ppapi/ppapi_sources.gypi b/ppapi/ppapi_sources.gypi
index faff951..c231418 100644
--- a/ppapi/ppapi_sources.gypi
+++ b/ppapi/ppapi_sources.gypi
@@ -129,6 +129,7 @@
'c/private/ppb_tcp_server_socket_private.h',
'c/private/ppb_tcp_socket_private.h',
'c/private/ppb_udp_socket_private.h',
+ 'c/private/ppb_uma_private.h',
'c/private/ppb_video_destination_private.h',
'c/private/ppb_video_source_private.h',
'c/private/ppb_x509_certificate_private.h',
@@ -359,6 +360,8 @@
'cpp/private/tcp_socket_private.h',
'cpp/private/udp_socket_private.cc',
'cpp/private/udp_socket_private.h',
+ 'cpp/private/uma_private.cc',
+ 'cpp/private/uma_private.h',
'cpp/private/var_private.cc',
'cpp/private/var_private.h',
'cpp/private/video_destination_private.cc',
@@ -494,6 +497,8 @@
'tests/test_udp_socket.h',
'tests/test_udp_socket_private.cc',
'tests/test_udp_socket_private.h',
+ 'tests/test_uma.cc',
+ 'tests/test_uma.h',
'tests/test_url_loader.cc',
'tests/test_url_loader.h',
'tests/test_url_request.cc',
@@ -568,8 +573,6 @@
'tests/test_talk_private.h',
'tests/test_tcp_socket_private_trusted.cc',
'tests/test_tcp_socket_private_trusted.h',
- 'tests/test_uma.cc',
- 'tests/test_uma.h',
'tests/test_url_util.cc',
'tests/test_url_util.h',
'tests/test_utils.cc',
diff --git a/ppapi/proxy/interface_list.cc b/ppapi/proxy/interface_list.cc
index f88d33c..e4a697a 100644
--- a/ppapi/proxy/interface_list.cc
+++ b/ppapi/proxy/interface_list.cc
@@ -93,6 +93,7 @@
#include "ppapi/c/private/ppb_tcp_socket_private.h"
#include "ppapi/c/private/ppb_testing_private.h"
#include "ppapi/c/private/ppb_udp_socket_private.h"
+#include "ppapi/c/private/ppb_uma_private.h"
#include "ppapi/c/private/ppb_video_destination_private.h"
#include "ppapi/c/private/ppb_video_source_private.h"
#include "ppapi/c/private/ppb_x509_certificate_private.h"
diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h
index f1d0ead..f3cd9d0 100644
--- a/ppapi/proxy/ppapi_messages.h
+++ b/ppapi/proxy/ppapi_messages.h
@@ -1211,6 +1211,25 @@ IPC_MESSAGE_CONTROL2(PpapiHostMsg_ExtensionsCommon_Call,
IPC_MESSAGE_CONTROL1(PpapiPluginMsg_ExtensionsCommon_CallReply,
base::ListValue /* output */)
+// UMA
+IPC_MESSAGE_CONTROL0(PpapiHostMsg_UMA_Create)
+IPC_MESSAGE_CONTROL5(PpapiHostMsg_UMA_HistogramCustomTimes,
+ std::string /* name */,
+ int64_t /* sample */,
+ int64_t /* min */,
+ int64_t /* max */,
+ uint32_t /* bucket_count */)
+IPC_MESSAGE_CONTROL5(PpapiHostMsg_UMA_HistogramCustomCounts,
+ std::string /* name */,
+ int32_t /* sample */,
+ int32_t /* min */,
+ int32_t /* max */,
+ uint32_t /* bucket_count */)
+IPC_MESSAGE_CONTROL3(PpapiHostMsg_UMA_HistogramEnumeration,
+ std::string /* name */,
+ int32_t /* sample */,
+ int32_t /* boundary_value */)
+
// File chooser.
IPC_MESSAGE_CONTROL0(PpapiHostMsg_FileChooser_Create)
IPC_MESSAGE_CONTROL4(PpapiHostMsg_FileChooser_Show,
diff --git a/ppapi/proxy/ppb_instance_proxy.cc b/ppapi/proxy/ppb_instance_proxy.cc
index 324f342..6429f50 100644
--- a/ppapi/proxy/ppb_instance_proxy.cc
+++ b/ppapi/proxy/ppb_instance_proxy.cc
@@ -32,6 +32,7 @@
#include "ppapi/proxy/ppapi_messages.h"
#include "ppapi/proxy/serialized_var.h"
#include "ppapi/proxy/truetype_font_singleton_resource.h"
+#include "ppapi/proxy/uma_private_resource.h"
#include "ppapi/shared_impl/ppapi_globals.h"
#include "ppapi/shared_impl/ppb_url_util_shared.h"
#include "ppapi/shared_impl/ppb_view_shared.h"
@@ -375,6 +376,9 @@ Resource* PPB_Instance_Proxy::GetSingletonResource(PP_Instance instance,
case TRUETYPE_FONT_SINGLETON_ID:
new_singleton = new TrueTypeFontSingletonResource(connection, instance);
break;
+ case UMA_SINGLETON_ID:
+ new_singleton = new UMAPrivateResource(connection, instance);
+ break;
// Flash/trusted resources aren't needed for NaCl.
#if !defined(OS_NACL) && !defined(NACL_WIN64)
case BROWSER_FONT_SINGLETON_ID:
diff --git a/ppapi/proxy/uma_private_resource.cc b/ppapi/proxy/uma_private_resource.cc
new file mode 100644
index 0000000..d17a005
--- /dev/null
+++ b/ppapi/proxy/uma_private_resource.cc
@@ -0,0 +1,89 @@
+// Copyright 2014 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/proxy/uma_private_resource.h"
+
+#include "base/bind.h"
+#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/proxy/resource_message_params.h"
+#include "ppapi/shared_impl/var.h"
+
+namespace {
+
+std::string StringFromPPVar(const PP_Var& var) {
+ scoped_refptr<ppapi::StringVar> name_stringvar =
+ ppapi::StringVar::FromPPVar(var);
+ if (!name_stringvar.get())
+ return std::string();
+ return name_stringvar->value();
+}
+
+}
+
+namespace ppapi {
+namespace proxy {
+
+UMAPrivateResource::UMAPrivateResource(
+ Connection connection, PP_Instance instance)
+ : PluginResource(connection, instance) {
+ SendCreate(RENDERER, PpapiHostMsg_UMA_Create());
+}
+
+UMAPrivateResource::~UMAPrivateResource() {
+}
+
+thunk::PPB_UMA_Singleton_API* UMAPrivateResource::AsPPB_UMA_Singleton_API() {
+ return this;
+}
+
+void UMAPrivateResource::HistogramCustomTimes(
+ PP_Instance instance,
+ struct PP_Var name,
+ int64_t sample,
+ int64_t min,
+ int64_t max,
+ uint32_t bucket_count) {
+ if (name.type != PP_VARTYPE_STRING)
+ return;
+
+ Post(RENDERER, PpapiHostMsg_UMA_HistogramCustomTimes(StringFromPPVar(name),
+ sample,
+ min,
+ max,
+ bucket_count));
+}
+
+void UMAPrivateResource::HistogramCustomCounts(
+ PP_Instance instance,
+ struct PP_Var name,
+ int32_t sample,
+ int32_t min,
+ int32_t max,
+ uint32_t bucket_count) {
+ if (name.type != PP_VARTYPE_STRING)
+ return;
+
+ Post(RENDERER, PpapiHostMsg_UMA_HistogramCustomCounts(StringFromPPVar(name),
+ sample,
+ min,
+ max,
+ bucket_count));
+}
+
+void UMAPrivateResource::HistogramEnumeration(
+ PP_Instance instance,
+ struct PP_Var name,
+ int32_t sample,
+ int32_t boundary_value) {
+ if (name.type != PP_VARTYPE_STRING)
+ return;
+
+ Post(RENDERER, PpapiHostMsg_UMA_HistogramEnumeration(StringFromPPVar(name),
+ sample,
+ boundary_value));
+}
+
+} // namespace proxy
+} // namespace ppapi
+
diff --git a/ppapi/proxy/uma_private_resource.h b/ppapi/proxy/uma_private_resource.h
new file mode 100644
index 0000000..94c7d3c
--- /dev/null
+++ b/ppapi/proxy/uma_private_resource.h
@@ -0,0 +1,54 @@
+// Copyright 2014 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_PROXY_UMA_PRIVATE_RESOURCE_H_
+#define PPAPI_PROXY_UMA_PRIVATE_RESOURCE_H_
+
+#include "ppapi/proxy/connection.h"
+#include "ppapi/proxy/plugin_resource.h"
+#include "ppapi/proxy/ppapi_proxy_export.h"
+#include "ppapi/thunk/ppb_uma_singleton_api.h"
+
+namespace ppapi {
+
+namespace proxy {
+
+class PPAPI_PROXY_EXPORT UMAPrivateResource
+ : public PluginResource,
+ public thunk::PPB_UMA_Singleton_API {
+ public:
+ UMAPrivateResource(Connection connection, PP_Instance instance);
+ virtual ~UMAPrivateResource();
+
+ // Resource overrides.
+ virtual thunk::PPB_UMA_Singleton_API* AsPPB_UMA_Singleton_API() OVERRIDE;
+
+ // PPB_UMA_Singleton_API implementation.
+ virtual void HistogramCustomTimes(PP_Instance instance,
+ struct PP_Var name,
+ int64_t sample,
+ int64_t min,
+ int64_t max,
+ uint32_t bucket_count) OVERRIDE;
+
+ virtual void HistogramCustomCounts(PP_Instance instance,
+ struct PP_Var name,
+ int32_t sample,
+ int32_t min,
+ int32_t max,
+ uint32_t bucket_count) OVERRIDE;
+
+ virtual void HistogramEnumeration(PP_Instance instance,
+ struct PP_Var name,
+ int32_t sample,
+ int32_t boundary_value) OVERRIDE;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(UMAPrivateResource);
+};
+
+} // namespace proxy
+} // namespace ppapi
+
+#endif // PPAPI_PROXY_UMA_PRIVATE_RESOURCE_H_
diff --git a/ppapi/shared_impl/resource.h b/ppapi/shared_impl/resource.h
index 8c6e7d6..8d15cd2 100644
--- a/ppapi/shared_impl/resource.h
+++ b/ppapi/shared_impl/resource.h
@@ -74,6 +74,7 @@
F(PPB_TCPSocket_Private_API) \
F(PPB_UDPSocket_API) \
F(PPB_UDPSocket_Private_API) \
+ F(PPB_UMA_Singleton_API) \
F(PPB_URLLoader_API) \
F(PPB_URLRequestInfo_API) \
F(PPB_URLResponseInfo_API) \
diff --git a/ppapi/shared_impl/singleton_resource_id.h b/ppapi/shared_impl/singleton_resource_id.h
index 90b0e6f..1094c69 100644
--- a/ppapi/shared_impl/singleton_resource_id.h
+++ b/ppapi/shared_impl/singleton_resource_id.h
@@ -25,6 +25,7 @@ enum SingletonResourceID {
NETWORK_PROXY_SINGLETON_ID,
PDF_SINGLETON_ID,
TRUETYPE_FONT_SINGLETON_ID,
+ UMA_SINGLETON_ID,
};
} // namespace ppapi
diff --git a/ppapi/tests/test_uma.cc b/ppapi/tests/test_uma.cc
index 8892bea..ef21005 100644
--- a/ppapi/tests/test_uma.cc
+++ b/ppapi/tests/test_uma.cc
@@ -25,31 +25,34 @@ void TestUMA::RunTests(const std::string& filter) {
std::string TestUMA::TestCount() {
pp::Var name_var = pp::Var("Test.CountHistogram");
PP_Var name = name_var.pp_var();
- uma_interface_->HistogramCustomCounts(name, 10, 1, 100, 50);
- uma_interface_->HistogramCustomCounts(name, 30, 1, 100, 50);
- uma_interface_->HistogramCustomCounts(name, 20, 1, 100, 50);
- uma_interface_->HistogramCustomCounts(name, 40, 1, 100, 50);
+ PP_Instance instance = instance_->pp_instance();
+ uma_interface_->HistogramCustomCounts(instance, name, 10, 1, 100, 50);
+ uma_interface_->HistogramCustomCounts(instance, name, 30, 1, 100, 50);
+ uma_interface_->HistogramCustomCounts(instance, name, 20, 1, 100, 50);
+ uma_interface_->HistogramCustomCounts(instance, name, 40, 1, 100, 50);
PASS();
}
std::string TestUMA::TestTime() {
pp::Var name_var = pp::Var("Test.TimeHistogram");
PP_Var name = name_var.pp_var();
- uma_interface_->HistogramCustomTimes(name, 100, 1, 10000, 50);
- uma_interface_->HistogramCustomTimes(name, 1000, 1, 10000, 50);
- uma_interface_->HistogramCustomTimes(name, 5000, 1, 10000, 50);
- uma_interface_->HistogramCustomTimes(name, 10, 1, 10000, 50);
+ PP_Instance instance = instance_->pp_instance();
+ uma_interface_->HistogramCustomTimes(instance, name, 100, 1, 10000, 50);
+ uma_interface_->HistogramCustomTimes(instance, name, 1000, 1, 10000, 50);
+ uma_interface_->HistogramCustomTimes(instance, name, 5000, 1, 10000, 50);
+ uma_interface_->HistogramCustomTimes(instance, name, 10, 1, 10000, 50);
PASS();
}
std::string TestUMA::TestEnum() {
pp::Var name_var = pp::Var("Test.EnumHistogram");
PP_Var name = name_var.pp_var();
- uma_interface_->HistogramEnumeration(name, 0, 5);
- uma_interface_->HistogramEnumeration(name, 3, 5);
- uma_interface_->HistogramEnumeration(name, 3, 5);
- uma_interface_->HistogramEnumeration(name, 1, 5);
- uma_interface_->HistogramEnumeration(name, 2, 5);
+ PP_Instance instance = instance_->pp_instance();
+ uma_interface_->HistogramEnumeration(instance, name, 0, 5);
+ uma_interface_->HistogramEnumeration(instance, name, 3, 5);
+ uma_interface_->HistogramEnumeration(instance, name, 3, 5);
+ uma_interface_->HistogramEnumeration(instance, name, 1, 5);
+ uma_interface_->HistogramEnumeration(instance, name, 2, 5);
PASS();
}
diff --git a/ppapi/thunk/interfaces_legacy.h b/ppapi/thunk/interfaces_legacy.h
index 6051824..c9f7a3c 100644
--- a/ppapi/thunk/interfaces_legacy.h
+++ b/ppapi/thunk/interfaces_legacy.h
@@ -28,7 +28,6 @@ LEGACY_IFACE(PPB_OPENGLES2_CHROMIUMMAPSUB_DEV_INTERFACE_1_0,
LEGACY_IFACE(PPB_OPENGLES2_QUERY_INTERFACE,
::ppapi::PPB_OpenGLES2_Shared::GetQueryInterface())
LEGACY_IFACE(PPB_PROXY_PRIVATE_INTERFACE, PPB_Proxy_Impl::GetInterface())
-LEGACY_IFACE(PPB_UMA_PRIVATE_INTERFACE, PPB_UMA_Private_Impl::GetInterface())
LEGACY_IFACE(PPB_VAR_DEPRECATED_INTERFACE,
PPB_Var_Deprecated_Impl::GetVarDeprecatedInterface())
LEGACY_IFACE(PPB_VAR_INTERFACE_1_0,
diff --git a/ppapi/thunk/interfaces_ppb_private_no_permissions.h b/ppapi/thunk/interfaces_ppb_private_no_permissions.h
index d89ea04..83e8243 100644
--- a/ppapi/thunk/interfaces_ppb_private_no_permissions.h
+++ b/ppapi/thunk/interfaces_ppb_private_no_permissions.h
@@ -48,4 +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)
+
#include "ppapi/thunk/interfaces_postamble.h"
diff --git a/ppapi/thunk/ppb_uma_private_thunk.cc b/ppapi/thunk/ppb_uma_private_thunk.cc
new file mode 100644
index 0000000..4a0d9d3
--- /dev/null
+++ b/ppapi/thunk/ppb_uma_private_thunk.cc
@@ -0,0 +1,84 @@
+// Copyright 2014 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 private/ppb_uma_private.idl modified Mon Nov 18 14:39:43 2013.
+
+#include "ppapi/c/pp_errors.h"
+#include "ppapi/c/private/ppb_uma_private.h"
+#include "ppapi/shared_impl/tracked_callback.h"
+#include "ppapi/thunk/enter.h"
+#include "ppapi/thunk/ppb_instance_api.h"
+#include "ppapi/thunk/ppb_uma_singleton_api.h"
+#include "ppapi/thunk/resource_creation_api.h"
+#include "ppapi/thunk/thunk.h"
+
+namespace ppapi {
+namespace thunk {
+
+namespace {
+
+void HistogramCustomTimes(PP_Instance instance,
+ struct PP_Var name,
+ int64_t sample,
+ int64_t min,
+ int64_t max,
+ uint32_t bucket_count) {
+ VLOG(4) << "PPB_UMA_Private::HistogramCustomTimes()";
+ EnterInstanceAPI<PPB_UMA_Singleton_API> enter(instance);
+ if (enter.failed())
+ return;
+ enter.functions()->HistogramCustomTimes(instance,
+ name,
+ sample,
+ min,
+ max,
+ bucket_count);
+}
+
+void HistogramCustomCounts(PP_Instance instance,
+ struct PP_Var name,
+ int32_t sample,
+ int32_t min,
+ int32_t max,
+ uint32_t bucket_count) {
+ VLOG(4) << "PPB_UMA_Private::HistogramCustomCounts()";
+ EnterInstanceAPI<PPB_UMA_Singleton_API> enter(instance);
+ if (enter.failed())
+ return;
+ enter.functions()->HistogramCustomCounts(instance,
+ name,
+ sample,
+ min,
+ max,
+ bucket_count);
+}
+
+void HistogramEnumeration(PP_Instance instance,
+ struct PP_Var name,
+ int32_t sample,
+ int32_t boundary_value) {
+ VLOG(4) << "PPB_UMA_Private::HistogramEnumeration()";
+ EnterInstanceAPI<PPB_UMA_Singleton_API> enter(instance);
+ if (enter.failed())
+ return;
+ enter.functions()->HistogramEnumeration(instance,
+ name,
+ sample,
+ boundary_value);
+}
+
+const PPB_UMA_Private_0_2 g_ppb_uma_private_thunk_0_2 = {
+ &HistogramCustomTimes,
+ &HistogramCustomCounts,
+ &HistogramEnumeration
+};
+
+} // namespace
+
+const PPB_UMA_Private_0_2* GetPPB_UMA_Private_0_2_Thunk() {
+ return &g_ppb_uma_private_thunk_0_2;
+}
+
+} // namespace thunk
+} // namespace ppapi
diff --git a/ppapi/thunk/ppb_uma_singleton_api.h b/ppapi/thunk/ppb_uma_singleton_api.h
new file mode 100644
index 0000000..efb6736
--- /dev/null
+++ b/ppapi/thunk/ppb_uma_singleton_api.h
@@ -0,0 +1,43 @@
+// Copyright 2014 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_THUNK_PPB_UMA_PRIVATE_API_H_
+#define PPAPI_THUNK_PPB_UMA_PRIVATE_API_H_
+
+#include "ppapi/shared_impl/singleton_resource_id.h"
+#include "ppapi/thunk/ppapi_thunk_export.h"
+
+namespace ppapi {
+namespace thunk {
+
+class PPAPI_THUNK_EXPORT PPB_UMA_Singleton_API {
+ public:
+ virtual ~PPB_UMA_Singleton_API() {}
+
+ virtual void HistogramCustomTimes(PP_Instance instance,
+ struct PP_Var name,
+ int64_t sample,
+ int64_t min,
+ int64_t max,
+ uint32_t bucket_count) = 0;
+
+ virtual void HistogramCustomCounts(PP_Instance instance,
+ struct PP_Var name,
+ int32_t sample,
+ int32_t min,
+ int32_t max,
+ uint32_t bucket_count) = 0;
+
+ virtual void HistogramEnumeration(PP_Instance instance,
+ struct PP_Var name,
+ int32_t sample,
+ int32_t boundary_value) = 0;
+
+ static const SingletonResourceID kSingletonResourceID = UMA_SINGLETON_ID;
+};
+
+} // namespace thunk
+} // namespace ppapi
+
+#endif // PPAPI_THUNK_PPB_UMA_PRIVATE_API_H_