diff options
author | teravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-25 22:19:54 +0000 |
---|---|---|
committer | teravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-03-25 22:19:54 +0000 |
commit | 4524fa338481939a676f1dece4b1095dd2310df2 (patch) | |
tree | ac21677bee4cf9ee5c0028e438eedd454adced56 /ppapi | |
parent | f496a4b8961dd855a4e27c48f5a56eabc22b296b (diff) | |
download | chromium_src-4524fa338481939a676f1dece4b1095dd2310df2.zip chromium_src-4524fa338481939a676f1dece4b1095dd2310df2.tar.gz chromium_src-4524fa338481939a676f1dece4b1095dd2310df2.tar.bz2 |
PPAPI/NaCl: Define NexeLoadManager class.
This adds an object that tracks the lifetime of the "Plugin" class in the
trusted plugin. State is kept in this class as long as the plugin is alive, to
make accounting much simpler for PPB_NaCl_Private.
This is derived from https://codereview.chromium.org/180213006/ but adds a
bugfix that initializes NexeLoadManager earlier.
BUG=239656
Review URL: https://codereview.chromium.org/208913002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@259362 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r-- | ppapi/api/private/ppb_nacl_private.idl | 3 | ||||
-rw-r--r-- | ppapi/c/private/ppb_nacl_private.h | 4 | ||||
-rw-r--r-- | ppapi/native_client/src/trusted/plugin/plugin.cc | 13 | ||||
-rw-r--r-- | ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c | 6 |
4 files changed, 21 insertions, 5 deletions
diff --git a/ppapi/api/private/ppb_nacl_private.idl b/ppapi/api/private/ppb_nacl_private.idl index c17ab8b..3249b99 100644 --- a/ppapi/api/private/ppb_nacl_private.idl +++ b/ppapi/api/private/ppb_nacl_private.idl @@ -278,6 +278,9 @@ interface PPB_NaCl_Private { [in] str_t console_message, [in] PP_Bool is_installed); + /* Performs internal setup when an instance is created. */ + void InstanceCreated([in] PP_Instance instance); + /* Performs internal cleanup when an instance is destroyed. */ void InstanceDestroyed([in] PP_Instance instance); diff --git a/ppapi/c/private/ppb_nacl_private.h b/ppapi/c/private/ppb_nacl_private.h index e5032fc..f730326 100644 --- a/ppapi/c/private/ppb_nacl_private.h +++ b/ppapi/c/private/ppb_nacl_private.h @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -/* From private/ppb_nacl_private.idl modified Thu Mar 20 14:02:02 2014. */ +/* From private/ppb_nacl_private.idl modified Fri Mar 21 13:55:07 2014. */ #ifndef PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_ #define PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_ @@ -284,6 +284,8 @@ struct PPB_NaCl_Private_1_0 { const char* error_message, const char* console_message, PP_Bool is_installed); + /* Performs internal setup when an instance is created. */ + void (*InstanceCreated)(PP_Instance instance); /* Performs internal cleanup when an instance is destroyed. */ void (*InstanceDestroyed)(PP_Instance instance); /* Return true if the NaCl debug stub is enabled and the loaded app diff --git a/ppapi/native_client/src/trusted/plugin/plugin.cc b/ppapi/native_client/src/trusted/plugin/plugin.cc index 931bfe2..0606934 100644 --- a/ppapi/native_client/src/trusted/plugin/plugin.cc +++ b/ppapi/native_client/src/trusted/plugin/plugin.cc @@ -606,6 +606,11 @@ Plugin::Plugin(PP_Instance pp_instance) nexe_downloader_.Initialize(this); nacl_interface_ = GetNaClInterface(); CHECK(nacl_interface_ != NULL); + + // Notify PPB_NaCl_Private that the instance is created before altering any + // state that it tracks. + nacl_interface_->InstanceCreated(pp_instance); + set_nacl_ready_state(UNSENT); set_last_error_string(""); // We call set_exit_status() here to ensure that the 'exitStatus' property is @@ -1260,15 +1265,15 @@ void Plugin::ReportLoadSuccess(LengthComputable length_computable, void Plugin::ReportLoadError(const ErrorInfo& error_info) { PLUGIN_PRINTF(("Plugin::ReportLoadError (error='%s')\n", error_info.message().c_str())); + // Set the readyState attribute to indicate we need to start over. + set_nacl_ready_state(DONE); + set_nexe_error_reported(true); + nacl_interface_->ReportLoadError(pp_instance(), error_info.error_code(), error_info.message().c_str(), error_info.console_message().c_str(), PP_FromBool(is_installed_)); - - // Set the readyState attribute to indicate we need to start over. - set_nacl_ready_state(DONE); - set_nexe_error_reported(true); } 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 cdf6126..c64f180 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 @@ -3168,6 +3168,11 @@ static void Pnacl_M25_PPB_NaCl_Private_ReportLoadError(PP_Instance instance, PP_ iface->ReportLoadError(instance, error, error_message, console_message, is_installed); } +static void Pnacl_M25_PPB_NaCl_Private_InstanceCreated(PP_Instance instance) { + const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; + iface->InstanceCreated(instance); +} + static void Pnacl_M25_PPB_NaCl_Private_InstanceDestroyed(PP_Instance instance) { const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; iface->InstanceDestroyed(instance); @@ -5086,6 +5091,7 @@ static const struct PPB_NaCl_Private_1_0 Pnacl_Wrappers_PPB_NaCl_Private_1_0 = { .DispatchEvent = (void (*)(PP_Instance instance, PP_NaClEventType event_type, const char* resource_url, PP_Bool length_is_computable, uint64_t loaded_bytes, uint64_t total_bytes))&Pnacl_M25_PPB_NaCl_Private_DispatchEvent, .SetReadOnlyProperty = (void (*)(PP_Instance instance, struct PP_Var key, struct PP_Var value))&Pnacl_M25_PPB_NaCl_Private_SetReadOnlyProperty, .ReportLoadError = (void (*)(PP_Instance instance, PP_NaClError error, const char* error_message, const char* console_message, PP_Bool is_installed))&Pnacl_M25_PPB_NaCl_Private_ReportLoadError, + .InstanceCreated = (void (*)(PP_Instance instance))&Pnacl_M25_PPB_NaCl_Private_InstanceCreated, .InstanceDestroyed = (void (*)(PP_Instance instance))&Pnacl_M25_PPB_NaCl_Private_InstanceDestroyed, .NaClDebugStubEnabled = (PP_Bool (*)(void))&Pnacl_M25_PPB_NaCl_Private_NaClDebugStubEnabled, .GetSandboxArch = (const char* (*)(void))&Pnacl_M25_PPB_NaCl_Private_GetSandboxArch, |