summaryrefslogtreecommitdiffstats
path: root/components/nacl
diff options
context:
space:
mode:
Diffstat (limited to 'components/nacl')
-rw-r--r--components/nacl/browser/nacl_browser_delegate.h7
-rw-r--r--components/nacl/browser/nacl_host_message_filter.cc10
-rw-r--r--components/nacl/browser/nacl_host_message_filter.h2
-rw-r--r--components/nacl/browser/test_nacl_browser_delegate.cc5
-rw-r--r--components/nacl/browser/test_nacl_browser_delegate.h5
-rw-r--r--components/nacl/common/nacl_host_messages.h8
-rw-r--r--components/nacl/renderer/ppb_nacl_private_impl.cc75
7 files changed, 73 insertions, 39 deletions
diff --git a/components/nacl/browser/nacl_browser_delegate.h b/components/nacl/browser/nacl_browser_delegate.h
index 30bf467..2cdff83 100644
--- a/components/nacl/browser/nacl_browser_delegate.h
+++ b/components/nacl/browser/nacl_browser_delegate.h
@@ -28,9 +28,10 @@ class NaClBrowserDelegate {
public:
virtual ~NaClBrowserDelegate() {}
- // Show an infobar to the user.
- virtual void ShowNaClInfobar(int render_process_id, int render_view_id,
- int error_id) = 0;
+ // Show an infobar to the user to indicate the client architecture was not
+ // covered by the manifest.
+ virtual void ShowMissingArchInfobar(int render_process_id,
+ int render_view_id) = 0;
// Returns whether dialogs are allowed. This is used to decide if to add the
// command line switch kNoErrorDialogs.
virtual bool DialogsAreSuppressed() = 0;
diff --git a/components/nacl/browser/nacl_host_message_filter.cc b/components/nacl/browser/nacl_host_message_filter.cc
index cef4fdc..de4d1d4 100644
--- a/components/nacl/browser/nacl_host_message_filter.cc
+++ b/components/nacl/browser/nacl_host_message_filter.cc
@@ -50,7 +50,8 @@ bool NaClHostMessageFilter::OnMessageReceived(const IPC::Message& message,
OnGetNexeFd)
IPC_MESSAGE_HANDLER(NaClHostMsg_ReportTranslationFinished,
OnTranslationFinished)
- IPC_MESSAGE_HANDLER(NaClHostMsg_NaClErrorStatus, OnNaClErrorStatus)
+ IPC_MESSAGE_HANDLER(NaClHostMsg_MissingArchError,
+ OnMissingArchError)
IPC_MESSAGE_HANDLER_DELAY_REPLY(NaClHostMsg_OpenNaClExecutable,
OnOpenNaClExecutable)
IPC_MESSAGE_HANDLER(NaClHostMsg_NaClGetNumProcessors,
@@ -167,10 +168,9 @@ void NaClHostMessageFilter::OnTranslationFinished(int instance, bool success) {
render_process_id_, instance, success);
}
-void NaClHostMessageFilter::OnNaClErrorStatus(int render_view_id,
- int error_id) {
- nacl::NaClBrowser::GetDelegate()->ShowNaClInfobar(render_process_id_,
- render_view_id, error_id);
+void NaClHostMessageFilter::OnMissingArchError(int render_view_id) {
+ nacl::NaClBrowser::GetDelegate()->
+ ShowMissingArchInfobar(render_process_id_, render_view_id);
}
void NaClHostMessageFilter::OnOpenNaClExecutable(int render_view_id,
diff --git a/components/nacl/browser/nacl_host_message_filter.h b/components/nacl/browser/nacl_host_message_filter.h
index 843a340..71bd9d2 100644
--- a/components/nacl/browser/nacl_host_message_filter.h
+++ b/components/nacl/browser/nacl_host_message_filter.h
@@ -59,7 +59,7 @@ class NaClHostMessageFilter : public content::BrowserMessageFilter {
int pp_instance,
const PnaclCacheInfo& cache_info);
void OnTranslationFinished(int instance, bool success);
- void OnNaClErrorStatus(int render_view_id, int error_id);
+ void OnMissingArchError(int render_view_id);
void OnOpenNaClExecutable(int render_view_id,
const GURL& file_url,
IPC::Message* reply_msg);
diff --git a/components/nacl/browser/test_nacl_browser_delegate.cc b/components/nacl/browser/test_nacl_browser_delegate.cc
index d0b5607..e89548f 100644
--- a/components/nacl/browser/test_nacl_browser_delegate.cc
+++ b/components/nacl/browser/test_nacl_browser_delegate.cc
@@ -8,9 +8,8 @@ TestNaClBrowserDelegate::TestNaClBrowserDelegate() {}
TestNaClBrowserDelegate::~TestNaClBrowserDelegate() {}
-void TestNaClBrowserDelegate::ShowNaClInfobar(int render_process_id,
- int render_view_id,
- int error_id) {}
+void TestNaClBrowserDelegate::ShowMissingArchInfobar(int render_process_id,
+ int render_view_id) {}
bool TestNaClBrowserDelegate::DialogsAreSuppressed() {
return false;
diff --git a/components/nacl/browser/test_nacl_browser_delegate.h b/components/nacl/browser/test_nacl_browser_delegate.h
index 2e8e5f6..5c58350 100644
--- a/components/nacl/browser/test_nacl_browser_delegate.h
+++ b/components/nacl/browser/test_nacl_browser_delegate.h
@@ -22,9 +22,8 @@ class TestNaClBrowserDelegate : public NaClBrowserDelegate {
public:
TestNaClBrowserDelegate();
virtual ~TestNaClBrowserDelegate();
- virtual void ShowNaClInfobar(int render_process_id,
- int render_view_id,
- int error_id) OVERRIDE;
+ virtual void ShowMissingArchInfobar(int render_process_id,
+ int render_view_id) OVERRIDE;
virtual bool DialogsAreSuppressed() OVERRIDE;
virtual bool GetCacheDirectory(base::FilePath* cache_dir) OVERRIDE;
virtual bool GetPluginDirectory(base::FilePath* plugin_dir) OVERRIDE;
diff --git a/components/nacl/common/nacl_host_messages.h b/components/nacl/common/nacl_host_messages.h
index db3b8c8..3565b8c 100644
--- a/components/nacl/common/nacl_host_messages.h
+++ b/components/nacl/common/nacl_host_messages.h
@@ -88,10 +88,10 @@ IPC_MESSAGE_CONTROL2(NaClHostMsg_ReportTranslationFinished,
int /* instance */,
bool /* success */)
-// A renderer sends this to the browser process to report an error.
-IPC_MESSAGE_CONTROL2(NaClHostMsg_NaClErrorStatus,
- int /* render_view_id */,
- int /* Error ID */)
+// A renderer sends this to the browser process to report when the client
+// architecture is not listed in the manifest.
+IPC_MESSAGE_CONTROL1(NaClHostMsg_MissingArchError,
+ int /* render_view_id */)
// A renderer sends this to the browser process when it wants to
// open a NaCl executable file from an installed application directory.
diff --git a/components/nacl/renderer/ppb_nacl_private_impl.cc b/components/nacl/renderer/ppb_nacl_private_impl.cc
index 5c32d4c..0c9eeb5 100644
--- a/components/nacl/renderer/ppb_nacl_private_impl.cc
+++ b/components/nacl/renderer/ppb_nacl_private_impl.cc
@@ -9,6 +9,7 @@
#include "base/command_line.h"
#include "base/lazy_instance.h"
#include "base/logging.h"
+#include "base/metrics/histogram.h"
#include "base/rand_util.h"
#include "components/nacl/common/nacl_host_messages.h"
#include "components/nacl/common/nacl_types.h"
@@ -68,6 +69,19 @@ typedef std::map<PP_Instance, InstanceInfo> InstanceInfoMap;
base::LazyInstance<InstanceInfoMap> g_instance_info =
LAZY_INSTANCE_INITIALIZER;
+void HistogramEnumerate(const std::string& name,
+ int32_t sample,
+ int32_t boundary_value) {
+ base::HistogramBase* counter =
+ base::LinearHistogram::FactoryGet(
+ name,
+ 1,
+ boundary_value,
+ boundary_value + 1,
+ base::HistogramBase::kUmaTargetedHistogramFlag);
+ counter->Add(sample);
+}
+
static int GetRoutingID(PP_Instance instance) {
// Check that we are on the main renderer thread.
DCHECK(content::RenderThread::Get());
@@ -320,21 +334,6 @@ void ReportTranslationFinished(PP_Instance instance, PP_Bool success) {
g_pnacl_resource_host.Get()->ReportTranslationFinished(instance, success);
}
-PP_ExternalPluginResult ReportNaClError(PP_Instance instance,
- PP_NaClError error_id) {
- IPC::Sender* sender = content::RenderThread::Get();
-
- if (!sender->Send(
- new NaClHostMsg_NaClErrorStatus(
- // TODO(dschuff): does this enum need to be sent as an int,
- // or is it safe to include the appropriate headers in
- // render_messages.h?
- GetRoutingID(instance), static_cast<int>(error_id)))) {
- return PP_EXTERNAL_PLUGIN_FAILED;
- }
- return PP_EXTERNAL_PLUGIN_OK;
-}
-
PP_FileHandle OpenNaClExecutable(PP_Instance instance,
const char* file_url,
uint64_t* nonce_lo,
@@ -385,6 +384,14 @@ blink::WebString EventTypeToString(PP_NaClEventType event_type) {
}
struct ProgressEvent {
+ explicit ProgressEvent(PP_Instance instance_param,
+ PP_NaClEventType event_type_param)
+ : instance(instance_param),
+ event_type(event_type_param),
+ length_is_computable(false),
+ loaded_bytes(0),
+ total_bytes(0) {
+ }
PP_Instance instance;
PP_NaClEventType event_type;
std::string resource_url;
@@ -401,9 +408,7 @@ void DispatchEvent(PP_Instance instance,
PP_Bool length_is_computable,
uint64_t loaded_bytes,
uint64_t total_bytes) {
- ProgressEvent p;
- p.instance = instance;
- p.event_type = event_type;
+ ProgressEvent p(instance, event_type);
p.length_is_computable = PP_ToBool(length_is_computable);
p.loaded_bytes = loaded_bytes;
p.total_bytes = total_bytes;
@@ -471,6 +476,36 @@ void SetReadOnlyProperty(PP_Instance instance,
plugin_instance->SetEmbedProperty(key, value);
}
+void ReportLoadError(PP_Instance instance,
+ PP_NaClError error,
+ PP_Bool is_installed) {
+ // Check that we are on the main renderer thread.
+ DCHECK(content::RenderThread::Get());
+
+ if (error == PP_NACL_ERROR_MANIFEST_PROGRAM_MISSING_ARCH) {
+ // A special case: the manifest may otherwise be valid but is missing
+ // a program/file compatible with the user's sandbox.
+ IPC::Sender* sender = content::RenderThread::Get();
+ sender->Send(
+ new NaClHostMsg_MissingArchError(GetRoutingID(instance)));
+ }
+ // TODO(dmichael): Move the following actions here:
+ // - Set ready state to DONE.
+ // - Set last error string.
+ // - Print error message to JavaScript console.
+
+ // Inform JavaScript that loading encountered an error and is complete.
+ DispatchEvent(instance, PP_NACL_EVENT_ERROR, NULL, PP_FALSE, 0, 0);
+ DispatchEvent(instance, PP_NACL_EVENT_LOADEND, NULL, PP_FALSE, 0, 0);
+
+ HistogramEnumerate("NaCl.LoadStatus.Plugin", error,
+ PP_NACL_ERROR_MAX);
+ std::string uma_name = (is_installed == PP_TRUE) ?
+ "NaCl.LoadStatus.Plugin.InstalledApp" :
+ "NaCl.LoadStatus.Plugin.NotInstalledApp";
+ HistogramEnumerate(uma_name, error, PP_NACL_ERROR_MAX);
+}
+
const PPB_NaCl_Private nacl_interface = {
&LaunchSelLdr,
&StartPpapiProxy,
@@ -482,10 +517,10 @@ const PPB_NaCl_Private nacl_interface = {
&GetNumberOfProcessors,
&GetNexeFd,
&ReportTranslationFinished,
- &ReportNaClError,
&OpenNaClExecutable,
&DispatchEvent,
- &SetReadOnlyProperty
+ &SetReadOnlyProperty,
+ &ReportLoadError
};
} // namespace