summaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorteravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-08 16:16:52 +0000
committerteravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-08 16:16:52 +0000
commit427a8dc283ddf52f319914f4762ca0cfdb5d4124 (patch)
tree1b339fed9ed5b1bb7f8ca8d6aed2c8a63bf3944e /components
parenta7219f143f378c665ca2f412c2c5d6a2d2acb03e (diff)
downloadchromium_src-427a8dc283ddf52f319914f4762ca0cfdb5d4124.zip
chromium_src-427a8dc283ddf52f319914f4762ca0cfdb5d4124.tar.gz
chromium_src-427a8dc283ddf52f319914f4762ca0cfdb5d4124.tar.bz2
Pepper: Move some reporting into StartPpapiProxy.
Now that we're doing more error reporting and histogramming in NexeLoadManager, we can move some of that type of logic into PPB_NaCl_Private.StartPpapiProxy. BUG=239656 Review URL: https://codereview.chromium.org/226593002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@262433 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components')
-rw-r--r--components/nacl/renderer/nexe_load_manager.cc18
-rw-r--r--components/nacl/renderer/nexe_load_manager.h13
-rw-r--r--components/nacl/renderer/ppb_nacl_private_impl.cc62
3 files changed, 88 insertions, 5 deletions
diff --git a/components/nacl/renderer/nexe_load_manager.cc b/components/nacl/renderer/nexe_load_manager.cc
index 2e3ac30..f8316e6 100644
--- a/components/nacl/renderer/nexe_load_manager.cc
+++ b/components/nacl/renderer/nexe_load_manager.cc
@@ -124,6 +124,17 @@ void HistogramTimeLarge(const std::string& name, int64_t sample) {
counter->AddTime(base::TimeDelta::FromMilliseconds(sample));
}
+void HistogramStartupTimeMedium(const std::string& name,
+ base::TimeDelta td,
+ int64_t nexe_size) {
+ HistogramTimeMedium(name, static_cast<int64_t>(td.InMilliseconds()));
+ if (nexe_size > 0) {
+ float size_in_MB = static_cast<float>(nexe_size) / (1024.f * 1024.f);
+ HistogramTimeMedium(name + "PerMB",
+ static_cast<int64_t>(td.InMilliseconds() / size_in_MB));
+ }
+}
+
blink::WebString EventTypeToString(PP_NaClEventType event_type) {
switch (event_type) {
case PP_NACL_EVENT_LOADSTART:
@@ -166,6 +177,7 @@ NexeLoadManager::NexeLoadManager(
nexe_error_reported_(false),
is_installed_(false),
exit_status_(-1),
+ nexe_size_(0),
plugin_instance_(content::PepperPluginInstance::Get(pp_instance)),
weak_factory_(this) {
SetLastError("");
@@ -388,6 +400,12 @@ void NexeLoadManager::set_exit_status(int exit_status) {
SetReadOnlyProperty(exit_status_name_var.get(), PP_MakeInt32(exit_status));
}
+void NexeLoadManager::ReportStartupOverhead() const {
+ base::TimeDelta overhead = base::Time::Now() - init_time_;
+ HistogramStartupTimeMedium(
+ "NaCl.Perf.StartupTime.NaClOverhead", overhead, nexe_size_);
+}
+
void NexeLoadManager::ReportDeadNexe() {
if (nacl_ready_state_ == PP_NACL_READY_STATE_DONE && // After loadEnd
!nexe_error_reported_) {
diff --git a/components/nacl/renderer/nexe_load_manager.h b/components/nacl/renderer/nexe_load_manager.h
index 8f221bf5..e771730 100644
--- a/components/nacl/renderer/nexe_load_manager.h
+++ b/components/nacl/renderer/nexe_load_manager.h
@@ -84,6 +84,13 @@ class NexeLoadManager {
int32_t exit_status() const { return exit_status_; }
void set_exit_status(int32_t exit_status);
+ void set_init_time() { init_time_ = base::Time::Now(); }
+
+ void ReportStartupOverhead() const;
+
+ int64_t nexe_size() const { return nexe_size_; }
+ void set_nexe_size(int64_t nexe_size) { nexe_size_ = nexe_size; }
+
private:
DISALLOW_COPY_AND_ASSIGN(NexeLoadManager);
@@ -110,11 +117,17 @@ class NexeLoadManager {
// Time of a successful nexe load.
base::Time ready_time_;
+ // Time of plugin initialization.
+ base::Time init_time_;
+
// The exit status of the plugin process.
// This will have a value in the range (0x00-0xff) if the exit status is set,
// or -1 if set_exit_status() has never been called.
int32_t exit_status_;
+ // Size of the downloaded nexe, in bytes.
+ int64_t nexe_size_;
+
// Non-owning.
content::PepperPluginInstance* plugin_instance_;
diff --git a/components/nacl/renderer/ppb_nacl_private_impl.cc b/components/nacl/renderer/ppb_nacl_private_impl.cc
index c848610..1a3f204 100644
--- a/components/nacl/renderer/ppb_nacl_private_impl.cc
+++ b/components/nacl/renderer/ppb_nacl_private_impl.cc
@@ -217,12 +217,18 @@ void LaunchSelLdr(PP_Instance instance,
}
}
-PP_ExternalPluginResult StartPpapiProxy(PP_Instance instance) {
+// Forward declaration.
+void ReportLoadError(PP_Instance instance,
+ PP_NaClError error,
+ const char* error_message,
+ const char* console_message);
+
+PP_Bool StartPpapiProxy(PP_Instance instance) {
InstanceInfoMap& map = g_instance_info.Get();
InstanceInfoMap::iterator it = map.find(instance);
if (it == map.end()) {
DLOG(ERROR) << "Could not find instance ID";
- return PP_EXTERNAL_PLUGIN_FAILED;
+ return PP_FALSE;
}
InstanceInfo instance_info = it->second;
map.erase(it);
@@ -231,15 +237,36 @@ PP_ExternalPluginResult StartPpapiProxy(PP_Instance instance) {
content::PepperPluginInstance::Get(instance);
if (!plugin_instance) {
DLOG(ERROR) << "GetInstance() failed";
- return PP_EXTERNAL_PLUGIN_ERROR_MODULE;
+ return PP_FALSE;
}
- return plugin_instance->SwitchToOutOfProcessProxy(
+ PP_ExternalPluginResult result = plugin_instance->SwitchToOutOfProcessProxy(
base::FilePath().AppendASCII(instance_info.url.spec()),
instance_info.permissions,
instance_info.channel_handle,
instance_info.plugin_pid,
instance_info.plugin_child_id);
+
+ if (result == PP_EXTERNAL_PLUGIN_OK) {
+ // Log the amound of time that has passed between the trusted plugin being
+ // initialized and the untrusted plugin being initialized. This is
+ // (roughly) the cost of using NaCl, in terms of startup time.
+ nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance);
+ if (load_manager)
+ load_manager->ReportStartupOverhead();
+ return PP_TRUE;
+ } else if (result == PP_EXTERNAL_PLUGIN_ERROR_MODULE) {
+ ReportLoadError(instance,
+ PP_NACL_ERROR_START_PROXY_MODULE,
+ "could not initialize module.",
+ "could not initialize module.");
+ } else if (result == PP_EXTERNAL_PLUGIN_ERROR_INSTANCE) {
+ ReportLoadError(instance,
+ PP_NACL_ERROR_START_PROXY_MODULE,
+ "could not create instance.",
+ "could not create instance.");
+ }
+ return PP_FALSE;
}
int UrandomFD(void) {
@@ -587,6 +614,28 @@ void Vlog(const char* message) {
VLOG(1) << message;
}
+void SetInitTime(PP_Instance instance) {
+ nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance);
+ DCHECK(load_manager);
+ if (load_manager)
+ return load_manager->set_init_time();
+}
+
+int64_t GetNexeSize(PP_Instance instance) {
+ nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance);
+ DCHECK(load_manager);
+ if (load_manager)
+ return load_manager->nexe_size();
+ return 0;
+}
+
+void SetNexeSize(PP_Instance instance, int64_t nexe_size) {
+ nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance);
+ DCHECK(load_manager);
+ if (load_manager)
+ return load_manager->set_nexe_size(nexe_size);
+}
+
const PPB_NaCl_Private nacl_interface = {
&LaunchSelLdr,
&StartPpapiProxy,
@@ -618,7 +667,10 @@ const PPB_NaCl_Private nacl_interface = {
&SetReadyTime,
&GetExitStatus,
&SetExitStatus,
- &Vlog
+ &Vlog,
+ &SetInitTime,
+ &GetNexeSize,
+ &SetNexeSize
};
} // namespace