Commit a1f0c722 authored by teravest@chromium.org's avatar teravest@chromium.org

Pepper: Miscellaneous trusted plugin cleanup.

This removes some more unnecessary methods and moves some more UMA reporting
out of the trusted plugin, reducing the total line count.

It's a little awkward that we have to pass the max value of NaClErrorCode to
the new reporting method, but it keeps that enum out of the public NaCl
interface.

BUG=239656
R=dmichael@chromium.org

Review URL: https://codereview.chromium.org/315753003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274898 0039d316-1c4b-4281-b951-d872f2087c98
parent 384dab94
......@@ -794,14 +794,6 @@ PP_NaClReadyState GetNaClReadyState(PP_Instance instance) {
return PP_NACL_READY_STATE_UNSENT;
}
PP_Bool GetIsInstalled(PP_Instance instance) {
NexeLoadManager* load_manager = GetNexeLoadManager(instance);
DCHECK(load_manager);
if (load_manager)
return PP_FromBool(load_manager->is_installed());
return PP_FALSE;
}
int32_t GetExitStatus(PP_Instance instance) {
NexeLoadManager* load_manager = GetNexeLoadManager(instance);
DCHECK(load_manager);
......@@ -847,7 +839,6 @@ bool CreateJsonManifest(PP_Instance instance,
const std::string& manifest_data);
void RequestNaClManifest(PP_Instance instance,
const char* url,
PP_CompletionCallback callback) {
NexeLoadManager* load_manager = GetNexeLoadManager(instance);
DCHECK(load_manager);
......@@ -859,7 +850,8 @@ void RequestNaClManifest(PP_Instance instance,
return;
}
if (!load_manager->RequestNaClManifest(url)) {
std::string url = load_manager->GetManifestURLArgument();
if (url.empty() || !load_manager->RequestNaClManifest(url)) {
ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask(
FROM_HERE,
base::Bind(callback.func, callback.user_data,
......@@ -911,15 +903,6 @@ void ProcessNaClManifest(PP_Instance instance, const char* program_url) {
load_manager->ProcessNaClManifest(program_url);
}
PP_Var GetManifestURLArgument(PP_Instance instance) {
nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance);
if (load_manager) {
return ppapi::StringVar::StringToPPVar(
load_manager->GetManifestURLArgument());
}
return PP_MakeUndefined();
}
PP_Bool DevInterfacesEnabled(PP_Instance instance) {
nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance);
if (load_manager)
......@@ -1518,6 +1501,22 @@ void DownloadFile(PP_Instance instance,
file_downloader->Load(url_request);
}
void ReportSelLdrStatus(PP_Instance instance,
int32_t load_status,
int32_t max_status) {
HistogramEnumerate("NaCl.LoadStatus.SelLdr", load_status, max_status);
NexeLoadManager* load_manager = GetNexeLoadManager(instance);
DCHECK(load_manager);
if (!load_manager)
return;
// Gather data to see if being installed changes load outcomes.
const char* name = load_manager->is_installed() ?
"NaCl.LoadStatus.SelLdr.InstalledApp" :
"NaCl.LoadStatus.SelLdr.NotInstalledApp";
HistogramEnumerate(name, load_status, max_status);
}
const PPB_NaCl_Private nacl_interface = {
&LaunchSelLdr,
&StartPpapiProxy,
......@@ -1541,7 +1540,6 @@ const PPB_NaCl_Private nacl_interface = {
&GetSandboxArch,
&LogToConsole,
&GetNaClReadyState,
&GetIsInstalled,
&GetExitStatus,
&SetExitStatus,
&Vlog,
......@@ -1550,7 +1548,6 @@ const PPB_NaCl_Private nacl_interface = {
&RequestNaClManifest,
&GetManifestBaseURL,
&ProcessNaClManifest,
&GetManifestURLArgument,
&DevInterfacesEnabled,
&ManifestGetProgramURL,
&ManifestResolveKey,
......@@ -1558,7 +1555,8 @@ const PPB_NaCl_Private nacl_interface = {
&GetCpuFeatureAttrs,
&PostMessageToJavaScript,
&DownloadNexe,
&DownloadFile
&DownloadFile,
&ReportSelLdrStatus
};
} // namespace
......
......@@ -343,9 +343,6 @@ interface PPB_NaCl_Private {
/* Returns the NaCl readiness status for this instance. */
PP_NaClReadyState GetNaClReadyState([in] PP_Instance instance);
/* Returns true if the plugin is an installed app. */
PP_Bool GetIsInstalled([in] PP_Instance instance);
/* Returns the exit status of the plugin process. */
int32_t GetExitStatus([in] PP_Instance instance);
......@@ -365,9 +362,8 @@ interface PPB_NaCl_Private {
/* Returns the size of the nexe. */
int64_t GetNexeSize([in] PP_Instance instance);
/* Performs accounting for requesting the NaCl manifest at the given URL. */
/* Requests the NaCl manifest specified in the plugin arguments. */
void RequestNaClManifest([in] PP_Instance instance,
[in] str_t manifest_url,
[in] PP_CompletionCallback callback);
PP_Var GetManifestBaseURL([in] PP_Instance instance);
......@@ -379,9 +375,6 @@ interface PPB_NaCl_Private {
void ProcessNaClManifest([in] PP_Instance instance,
[in] str_t program_url);
/* Returns the manifest url as passed as a plugin argument. */
PP_Var GetManifestURLArgument([in] PP_Instance instance);
PP_Bool DevInterfacesEnabled([in] PP_Instance instance);
PP_Bool GetManifestProgramURL([in] PP_Instance instance,
......@@ -431,4 +424,12 @@ interface PPB_NaCl_Private {
[in] str_t url,
[out] PP_NaClFileInfo file_info,
[in] PP_CompletionCallback callback);
/* Reports the status of sel_ldr for UMA reporting.
* |max_status| has to be provided because the implementation of this
* interface can't access the NaClErrorCode enum.
*/
void ReportSelLdrStatus([in] PP_Instance instance,
[in] int32_t load_status,
[in] int32_t max_status);
};
......@@ -3,7 +3,7 @@
* found in the LICENSE file.
*/
/* From private/ppb_nacl_private.idl modified Fri May 30 10:50:23 2014. */
/* From private/ppb_nacl_private.idl modified Wed Jun 4 09:50:07 2014. */
#ifndef PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_
#define PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_
......@@ -371,8 +371,6 @@ struct PPB_NaCl_Private_1_0 {
void (*LogToConsole)(PP_Instance instance, const char* message);
/* Returns the NaCl readiness status for this instance. */
PP_NaClReadyState (*GetNaClReadyState)(PP_Instance instance);
/* Returns true if the plugin is an installed app. */
PP_Bool (*GetIsInstalled)(PP_Instance instance);
/* Returns the exit status of the plugin process. */
int32_t (*GetExitStatus)(PP_Instance instance);
/* Sets the exit status of the plugin process. */
......@@ -386,9 +384,8 @@ struct PPB_NaCl_Private_1_0 {
const char* argv[]);
/* Returns the size of the nexe. */
int64_t (*GetNexeSize)(PP_Instance instance);
/* Performs accounting for requesting the NaCl manifest at the given URL. */
/* Requests the NaCl manifest specified in the plugin arguments. */
void (*RequestNaClManifest)(PP_Instance instance,
const char* manifest_url,
struct PP_CompletionCallback callback);
struct PP_Var (*GetManifestBaseURL)(PP_Instance instance);
/* Processes the NaCl manifest once it's been retrieved.
......@@ -396,8 +393,6 @@ struct PPB_NaCl_Private_1_0 {
* plugin.
*/
void (*ProcessNaClManifest)(PP_Instance instance, const char* program_url);
/* Returns the manifest url as passed as a plugin argument. */
struct PP_Var (*GetManifestURLArgument)(PP_Instance instance);
PP_Bool (*DevInterfacesEnabled)(PP_Instance instance);
PP_Bool (*GetManifestProgramURL)(PP_Instance instance,
struct PP_Var* full_url,
......@@ -439,6 +434,13 @@ struct PPB_NaCl_Private_1_0 {
const char* url,
struct PP_NaClFileInfo* file_info,
struct PP_CompletionCallback callback);
/* Reports the status of sel_ldr for UMA reporting.
* |max_status| has to be provided because the implementation of this
* interface can't access the NaClErrorCode enum.
*/
void (*ReportSelLdrStatus)(PP_Instance instance,
int32_t load_status,
int32_t max_status);
};
typedef struct PPB_NaCl_Private_1_0 PPB_NaCl_Private;
......
......@@ -75,21 +75,6 @@ void Plugin::HistogramTimeSmall(const std::string& name,
kTimeSmallBuckets);
}
void Plugin::HistogramEnumerateSelLdrLoadStatus(NaClErrorCode error_code) {
if (error_code < 0 || error_code > NACL_ERROR_CODE_MAX)
error_code = LOAD_STATUS_UNKNOWN;
uma_interface_.HistogramEnumeration("NaCl.LoadStatus.SelLdr",
error_code,
NACL_ERROR_CODE_MAX);
// Gather data to see if being installed changes load outcomes.
const char* name = nacl_interface_->GetIsInstalled(pp_instance()) ?
"NaCl.LoadStatus.SelLdr.InstalledApp" :
"NaCl.LoadStatus.SelLdr.NotInstalledApp";
uma_interface_.HistogramEnumeration(name, error_code, NACL_ERROR_CODE_MAX);
}
bool Plugin::LoadNaClModuleFromBackgroundThread(
PP_FileHandle file_handle,
NaClSubprocess* subprocess,
......@@ -316,10 +301,10 @@ bool Plugin::Init(uint32_t argc, const char* argn[], const char* argv[]) {
PLUGIN_PRINTF(("Plugin::Init (argc=%" NACL_PRIu32 ")\n", argc));
nacl_interface_->InitializePlugin(pp_instance(), argc, argn, argv);
wrapper_factory_ = new nacl::DescWrapperFactory();
pp::Var manifest_url(pp::PASS_REF, nacl_interface_->GetManifestURLArgument(
pp_instance()));
if (manifest_url.is_string() && !manifest_url.AsString().empty())
RequestNaClManifest(manifest_url.AsString());
pp::CompletionCallback open_cb =
callback_factory_.NewCallback(&Plugin::NaClManifestFileDidOpen);
nacl_interface_->RequestNaClManifest(pp_instance(),
open_cb.pp_completion_callback());
return true;
}
......@@ -420,18 +405,14 @@ void Plugin::NexeFileDidOpen(int32_t pp_error) {
}
void Plugin::NexeFileDidOpenContinuation(int32_t pp_error) {
bool was_successful;
UNREFERENCED_PARAMETER(pp_error);
NaClLog(4, "Entered NexeFileDidOpenContinuation\n");
NaClLog(4, "NexeFileDidOpenContinuation: invoking"
" LoadNaClModuleContinuationIntern\n");
was_successful = LoadNaClModuleContinuationIntern();
if (was_successful) {
if (LoadNaClModuleContinuationIntern()) {
NaClLog(4, "NexeFileDidOpenContinuation: success;"
" setting histograms\n");
int64_t nexe_size = nacl_interface_->GetNexeSize(pp_instance());
ReportLoadSuccess(nexe_size, nexe_size);
nacl_interface_->ReportLoadSuccess(
pp_instance(), program_url_.c_str(), nexe_size, nexe_size);
} else {
NaClLog(4, "NexeFileDidOpenContinuation: failed.");
}
......@@ -478,15 +459,16 @@ void Plugin::BitcodeDidTranslate(int32_t pp_error) {
}
void Plugin::BitcodeDidTranslateContinuation(int32_t pp_error) {
bool was_successful = LoadNaClModuleContinuationIntern();
NaClLog(4, "Entered BitcodeDidTranslateContinuation\n");
UNREFERENCED_PARAMETER(pp_error);
if (was_successful) {
if (LoadNaClModuleContinuationIntern()) {
int64_t loaded;
int64_t total;
// TODO(teravest): Tighten this up so we can get rid of
// GetCurrentProgress(). loaded should always equal total.
pnacl_coordinator_->GetCurrentProgress(&loaded, &total);
ReportLoadSuccess(loaded, total);
nacl_interface_->ReportLoadSuccess(
pp_instance(), program_url_.c_str(), loaded, total);
}
}
......@@ -528,21 +510,6 @@ void Plugin::NaClManifestFileDidOpen(int32_t pp_error) {
}
}
void Plugin::RequestNaClManifest(const nacl::string& url) {
PLUGIN_PRINTF(("Plugin::RequestNaClManifest (url='%s')\n", url.c_str()));
pp::CompletionCallback open_callback =
callback_factory_.NewCallback(&Plugin::NaClManifestFileDidOpen);
nacl_interface_->RequestNaClManifest(pp_instance(),
url.c_str(),
open_callback.pp_completion_callback());
}
void Plugin::ReportLoadSuccess(uint64_t loaded_bytes, uint64_t total_bytes) {
nacl_interface_->ReportLoadSuccess(
pp_instance(), program_url_.c_str(), loaded_bytes, total_bytes);
}
void Plugin::ReportLoadError(const ErrorInfo& error_info) {
nacl_interface_->ReportLoadError(pp_instance(),
error_info.error_code(),
......@@ -550,15 +517,6 @@ void Plugin::ReportLoadError(const ErrorInfo& error_info) {
error_info.console_message().c_str());
}
void Plugin::ReportLoadAbort() {
nacl_interface_->ReportLoadAbort(pp_instance());
}
void Plugin::ReportSelLdrLoadStatus(int status) {
HistogramEnumerateSelLdrLoadStatus(static_cast<NaClErrorCode>(status));
}
bool Plugin::DocumentCanRequest(const std::string& url) {
CHECK(pp::Module::Get()->core()->IsMainThread());
CHECK(pp::URLUtil_Dev::Get() != NULL);
......
......@@ -110,21 +110,11 @@ class Plugin : public pp::Instance {
PP_FileHandle file_handle,
ErrorInfo* error_info);
// Report successful loading of a module.
void ReportLoadSuccess(uint64_t loaded_bytes, uint64_t total_bytes);
// Report an error that was encountered while loading a module.
void ReportLoadError(const ErrorInfo& error_info);
// Report loading a module was aborted, typically due to user action.
void ReportLoadAbort();
// Report the error code that sel_ldr produces when starting a nexe.
void ReportSelLdrLoadStatus(int status);
nacl::DescWrapperFactory* wrapper_factory() const { return wrapper_factory_; }
// Requests a NaCl manifest download from a |url| relative to the page origin.
void RequestNaClManifest(const nacl::string& url);
// Called back by CallOnMainThread. Dispatches the first enqueued progress
// event.
void DispatchProgressEvent(int32_t result);
......@@ -153,8 +143,6 @@ class Plugin : public pp::Instance {
// Histogram helper functions, internal to Plugin so they can use
// uma_interface_ normally.
void HistogramTimeSmall(const std::string& name, int64_t ms);
void HistogramEnumerateLoadStatus(PP_NaClError error_code);
void HistogramEnumerateSelLdrLoadStatus(NaClErrorCode error_code);
// Load a nacl module from the file specified in file_handle.
// Only to be used from a background (non-main) thread.
......
......@@ -574,8 +574,13 @@ bool ServiceRuntime::StartModule() {
}
NaClLog(4, "ServiceRuntime::StartModule (load_status=%d)\n", load_status);
if (main_service_runtime_)
plugin_->ReportSelLdrLoadStatus(load_status);
if (main_service_runtime_) {
if (load_status < 0 || load_status > NACL_ERROR_CODE_MAX)
load_status = LOAD_STATUS_UNKNOWN;
GetNaClInterface()->ReportSelLdrStatus(plugin_->pp_instance(),
load_status,
NACL_ERROR_CODE_MAX);
}
if (LOAD_OK != load_status) {
if (main_service_runtime_) {
......
......@@ -3326,11 +3326,6 @@ static PP_NaClReadyState Pnacl_M25_PPB_NaCl_Private_GetNaClReadyState(PP_Instanc
return iface->GetNaClReadyState(instance);
}
static PP_Bool Pnacl_M25_PPB_NaCl_Private_GetIsInstalled(PP_Instance instance) {
const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface;
return iface->GetIsInstalled(instance);
}
static int32_t Pnacl_M25_PPB_NaCl_Private_GetExitStatus(PP_Instance instance) {
const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface;
return iface->GetExitStatus(instance);
......@@ -3356,9 +3351,9 @@ static int64_t Pnacl_M25_PPB_NaCl_Private_GetNexeSize(PP_Instance instance) {
return iface->GetNexeSize(instance);
}
static void Pnacl_M25_PPB_NaCl_Private_RequestNaClManifest(PP_Instance instance, const char* manifest_url, struct PP_CompletionCallback* callback) {
static void Pnacl_M25_PPB_NaCl_Private_RequestNaClManifest(PP_Instance instance, struct PP_CompletionCallback* callback) {
const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface;
iface->RequestNaClManifest(instance, manifest_url, *callback);
iface->RequestNaClManifest(instance, *callback);
}
static void Pnacl_M25_PPB_NaCl_Private_GetManifestBaseURL(struct PP_Var* _struct_result, PP_Instance instance) {
......@@ -3371,11 +3366,6 @@ static void Pnacl_M25_PPB_NaCl_Private_ProcessNaClManifest(PP_Instance instance,
iface->ProcessNaClManifest(instance, program_url);
}
static void Pnacl_M25_PPB_NaCl_Private_GetManifestURLArgument(struct PP_Var* _struct_result, PP_Instance instance) {
const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface;
*_struct_result = iface->GetManifestURLArgument(instance);
}
static PP_Bool Pnacl_M25_PPB_NaCl_Private_DevInterfacesEnabled(PP_Instance instance) {
const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface;
return iface->DevInterfacesEnabled(instance);
......@@ -3416,6 +3406,11 @@ static void Pnacl_M25_PPB_NaCl_Private_DownloadFile(PP_Instance instance, const
iface->DownloadFile(instance, url, file_info, *callback);
}
static void Pnacl_M25_PPB_NaCl_Private_ReportSelLdrStatus(PP_Instance instance, int32_t load_status, int32_t max_status) {
const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface;
iface->ReportSelLdrStatus(instance, load_status, max_status);
}
/* End wrapper methods for PPB_NaCl_Private_1_0 */
/* Begin wrapper methods for PPB_NetAddress_Private_0_1 */
......@@ -5166,16 +5161,14 @@ static const struct PPB_NaCl_Private_1_0 Pnacl_Wrappers_PPB_NaCl_Private_1_0 = {
.GetSandboxArch = (const char* (*)(void))&Pnacl_M25_PPB_NaCl_Private_GetSandboxArch,
.LogToConsole = (void (*)(PP_Instance instance, const char* message))&Pnacl_M25_PPB_NaCl_Private_LogToConsole,
.GetNaClReadyState = (PP_NaClReadyState (*)(PP_Instance instance))&Pnacl_M25_PPB_NaCl_Private_GetNaClReadyState,
.GetIsInstalled = (PP_Bool (*)(PP_Instance instance))&Pnacl_M25_PPB_NaCl_Private_GetIsInstalled,
.GetExitStatus = (int32_t (*)(PP_Instance instance))&Pnacl_M25_PPB_NaCl_Private_GetExitStatus,
.SetExitStatus = (void (*)(PP_Instance instance, int32_t exit_status))&Pnacl_M25_PPB_NaCl_Private_SetExitStatus,
.Vlog = (void (*)(const char* message))&Pnacl_M25_PPB_NaCl_Private_Vlog,
.InitializePlugin = (void (*)(PP_Instance instance, uint32_t argc, const char* argn[], const char* argv[]))&Pnacl_M25_PPB_NaCl_Private_InitializePlugin,
.GetNexeSize = (int64_t (*)(PP_Instance instance))&Pnacl_M25_PPB_NaCl_Private_GetNexeSize,
.RequestNaClManifest = (void (*)(PP_Instance instance, const char* manifest_url, struct PP_CompletionCallback callback))&Pnacl_M25_PPB_NaCl_Private_RequestNaClManifest,
.RequestNaClManifest = (void (*)(PP_Instance instance, struct PP_CompletionCallback callback))&Pnacl_M25_PPB_NaCl_Private_RequestNaClManifest,
.GetManifestBaseURL = (struct PP_Var (*)(PP_Instance instance))&Pnacl_M25_PPB_NaCl_Private_GetManifestBaseURL,
.ProcessNaClManifest = (void (*)(PP_Instance instance, const char* program_url))&Pnacl_M25_PPB_NaCl_Private_ProcessNaClManifest,
.GetManifestURLArgument = (struct PP_Var (*)(PP_Instance instance))&Pnacl_M25_PPB_NaCl_Private_GetManifestURLArgument,
.DevInterfacesEnabled = (PP_Bool (*)(PP_Instance instance))&Pnacl_M25_PPB_NaCl_Private_DevInterfacesEnabled,
.GetManifestProgramURL = (PP_Bool (*)(PP_Instance instance, struct PP_Var* full_url, struct PP_PNaClOptions* pnacl_options, PP_Bool* uses_nonsfi_mode))&Pnacl_M25_PPB_NaCl_Private_GetManifestProgramURL,
.ManifestResolveKey = (PP_Bool (*)(PP_Instance instance, PP_Bool helper_process, const char* key, struct PP_Var* full_url, struct PP_PNaClOptions* pnacl_options))&Pnacl_M25_PPB_NaCl_Private_ManifestResolveKey,
......@@ -5183,7 +5176,8 @@ static const struct PPB_NaCl_Private_1_0 Pnacl_Wrappers_PPB_NaCl_Private_1_0 = {
.GetCpuFeatureAttrs = (struct PP_Var (*)(void))&Pnacl_M25_PPB_NaCl_Private_GetCpuFeatureAttrs,
.PostMessageToJavaScript = (void (*)(PP_Instance instance, const char* message))&Pnacl_M25_PPB_NaCl_Private_PostMessageToJavaScript,
.DownloadNexe = (void (*)(PP_Instance instance, const char* url, struct PP_NaClFileInfo* file_info, struct PP_CompletionCallback callback))&Pnacl_M25_PPB_NaCl_Private_DownloadNexe,
.DownloadFile = (void (*)(PP_Instance instance, const char* url, struct PP_NaClFileInfo* file_info, struct PP_CompletionCallback callback))&Pnacl_M25_PPB_NaCl_Private_DownloadFile
.DownloadFile = (void (*)(PP_Instance instance, const char* url, struct PP_NaClFileInfo* file_info, struct PP_CompletionCallback callback))&Pnacl_M25_PPB_NaCl_Private_DownloadFile,
.ReportSelLdrStatus = (void (*)(PP_Instance instance, int32_t load_status, int32_t max_status))&Pnacl_M25_PPB_NaCl_Private_ReportSelLdrStatus
};
static const struct PPB_NetAddress_Private_0_1 Pnacl_Wrappers_PPB_NetAddress_Private_0_1 = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment