diff options
author | teravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-22 22:42:08 +0000 |
---|---|---|
committer | teravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-22 22:42:08 +0000 |
commit | 16499d49e7906aece538a9ac027a7805073f65e9 (patch) | |
tree | 9b095de4b33f1ab04be95bf9af7e76cc3afd749e | |
parent | e89f1bf59f0c768f2b02001a88e2a391f15bbd80 (diff) | |
download | chromium_src-16499d49e7906aece538a9ac027a7805073f65e9.zip chromium_src-16499d49e7906aece538a9ac027a7805073f65e9.tar.gz chromium_src-16499d49e7906aece538a9ac027a7805073f65e9.tar.bz2 |
Pepper: Move some manifest processing for refactor.
This moves some of the manifest processing logic outside the trusted plugin.
This reduces the number of things we need to expose in PPB_NaCl_Private.
BUG=239656
Review URL: https://codereview.chromium.org/243353002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@265394 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | components/nacl/renderer/nexe_load_manager.cc | 13 | ||||
-rw-r--r-- | components/nacl/renderer/nexe_load_manager.h | 2 | ||||
-rw-r--r-- | components/nacl/renderer/ppb_nacl_private_impl.cc | 25 | ||||
-rw-r--r-- | ppapi/api/private/ppb_nacl_private.idl | 15 | ||||
-rw-r--r-- | ppapi/c/private/ppb_nacl_private.h | 12 | ||||
-rw-r--r-- | ppapi/native_client/src/trusted/plugin/plugin.cc | 21 | ||||
-rw-r--r-- | ppapi/native_client/src/trusted/plugin/plugin.h | 1 | ||||
-rw-r--r-- | ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c | 20 |
8 files changed, 45 insertions, 64 deletions
diff --git a/components/nacl/renderer/nexe_load_manager.cc b/components/nacl/renderer/nexe_load_manager.cc index 8cbd1b3..942aea0 100644 --- a/components/nacl/renderer/nexe_load_manager.cc +++ b/components/nacl/renderer/nexe_load_manager.cc @@ -582,6 +582,19 @@ bool NexeLoadManager::RequestNaClManifest(const std::string& url, return false; } +void NexeLoadManager::ProcessNaClManifest(const std::string& program_url) { + GURL gurl(program_url); + DCHECK(gurl.is_valid()); + if (gurl.is_valid()) + is_installed_ = gurl.SchemeIs("chrome-extension"); + set_nacl_ready_state(PP_NACL_READY_STATE_LOADING); + ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->PostTask( + FROM_HERE, + base::Bind(&NexeLoadManager::DispatchEvent, + weak_factory_.GetWeakPtr(), + ProgressEvent(PP_NACL_EVENT_PROGRESS))); +} + 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 4b0f3a1..a094f07 100644 --- a/components/nacl/renderer/nexe_load_manager.h +++ b/components/nacl/renderer/nexe_load_manager.h @@ -89,7 +89,6 @@ class NexeLoadManager { void LogToConsole(const std::string& message); bool is_installed() const { return is_installed_; } - void set_is_installed(bool installed) { is_installed_ = installed; } int32_t exit_status() const { return exit_status_; } void set_exit_status(int32_t exit_status); @@ -101,6 +100,7 @@ class NexeLoadManager { int64_t nexe_size() const { return nexe_size_; } bool RequestNaClManifest(const std::string& url, bool* is_data_uri); + void ProcessNaClManifest(const std::string& program_url); // URL resolution support. // plugin_base_url is the URL used for resolving relative URLs used in diff --git a/components/nacl/renderer/ppb_nacl_private_impl.cc b/components/nacl/renderer/ppb_nacl_private_impl.cc index 70d9bac..46ff30d 100644 --- a/components/nacl/renderer/ppb_nacl_private_impl.cc +++ b/components/nacl/renderer/ppb_nacl_private_impl.cc @@ -670,13 +670,6 @@ PP_NaClReadyState GetNaClReadyState(PP_Instance instance) { return PP_NACL_READY_STATE_UNSENT; } -void SetNaClReadyState(PP_Instance instance, PP_NaClReadyState ready_state) { - nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); - DCHECK(load_manager); - if (load_manager) - load_manager->set_nacl_ready_state(ready_state); -} - PP_Bool GetIsInstalled(PP_Instance instance) { nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); DCHECK(load_manager); @@ -685,13 +678,6 @@ PP_Bool GetIsInstalled(PP_Instance instance) { return PP_FALSE; } -void SetIsInstalled(PP_Instance instance, PP_Bool installed) { - nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); - DCHECK(load_manager); - if (load_manager) - load_manager->set_is_installed(PP_ToBool(installed)); -} - int32_t GetExitStatus(PP_Instance instance) { nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); DCHECK(load_manager); @@ -773,6 +759,12 @@ PP_Var ParseDataURL(const char* data_url) { return ppapi::StringVar::StringToPPVar(data); } +void ProcessNaClManifest(PP_Instance instance, const char* program_url) { + nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); + if (load_manager) + load_manager->ProcessNaClManifest(program_url); +} + const PPB_NaCl_Private nacl_interface = { &LaunchSelLdr, &StartPpapiProxy, @@ -799,9 +791,7 @@ const PPB_NaCl_Private nacl_interface = { &GetUrlScheme, &LogToConsole, &GetNaClReadyState, - &SetNaClReadyState, &GetIsInstalled, - &SetIsInstalled, &GetExitStatus, &SetExitStatus, &Vlog, @@ -810,7 +800,8 @@ const PPB_NaCl_Private nacl_interface = { &RequestNaClManifest, &GetManifestBaseURL, &ResolvesRelativeToPluginBaseURL, - &ParseDataURL + &ParseDataURL, + &ProcessNaClManifest }; } // namespace diff --git a/ppapi/api/private/ppb_nacl_private.idl b/ppapi/api/private/ppb_nacl_private.idl index 4c783d0..2042423 100644 --- a/ppapi/api/private/ppb_nacl_private.idl +++ b/ppapi/api/private/ppb_nacl_private.idl @@ -331,17 +331,9 @@ interface PPB_NaCl_Private { /* Returns the NaCl readiness status for this instance. */ PP_NaClReadyState GetNaClReadyState([in] PP_Instance instance); - /* Sets the NaCl readiness status for this instance. */ - void SetNaClReadyState([in] PP_Instance instance, - [in] PP_NaClReadyState ready_state); - /* Returns true if the plugin is an installed app. */ PP_Bool GetIsInstalled([in] PP_Instance instance); - /* Sets whether the plugin is an installed app. */ - void SetIsInstalled([in] PP_Instance instance, - [in] PP_Bool is_installed); - /* Returns the exit status of the plugin process. */ int32_t GetExitStatus([in] PP_Instance instance); @@ -369,4 +361,11 @@ interface PPB_NaCl_Private { [in] str_t url); PP_Var ParseDataURL([in] str_t data_url); + + /* Processes the NaCl manifest once it's been retrieved. + * TODO(teravest): Move the rest of the supporting logic out of the trusted + * plugin. + */ + void ProcessNaClManifest([in] PP_Instance instance, + [in] str_t program_url); }; diff --git a/ppapi/c/private/ppb_nacl_private.h b/ppapi/c/private/ppb_nacl_private.h index 340ca44..d782b40 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 Fri Apr 18 11:23:31 2014. */ +/* From private/ppb_nacl_private.idl modified Tue Apr 22 13:59:14 2014. */ #ifndef PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_ #define PPAPI_C_PRIVATE_PPB_NACL_PRIVATE_H_ @@ -331,13 +331,8 @@ 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); - /* Sets the NaCl readiness status for this instance. */ - void (*SetNaClReadyState)(PP_Instance instance, - PP_NaClReadyState ready_state); /* Returns true if the plugin is an installed app. */ PP_Bool (*GetIsInstalled)(PP_Instance instance); - /* Sets whether the plugin is an installed app. */ - void (*SetIsInstalled)(PP_Instance instance, PP_Bool is_installed); /* Returns the exit status of the plugin process. */ int32_t (*GetExitStatus)(PP_Instance instance); /* Sets the exit status of the plugin process. */ @@ -356,6 +351,11 @@ struct PPB_NaCl_Private_1_0 { PP_Bool (*ResolvesRelativeToPluginBaseUrl)(PP_Instance instance, const char* url); struct PP_Var (*ParseDataURL)(const char* data_url); + /* Processes the NaCl manifest once it's been retrieved. + * TODO(teravest): Move the rest of the supporting logic out of the trusted + * plugin. + */ + void (*ProcessNaClManifest)(PP_Instance instance, const char* program_url); }; typedef struct PPB_NaCl_Private_1_0 PPB_NaCl_Private; diff --git a/ppapi/native_client/src/trusted/plugin/plugin.cc b/ppapi/native_client/src/trusted/plugin/plugin.cc index 47640a2..c4b1aaf 100644 --- a/ppapi/native_client/src/trusted/plugin/plugin.cc +++ b/ppapi/native_client/src/trusted/plugin/plugin.cc @@ -772,17 +772,10 @@ void Plugin::ProcessNaClManifest(const nacl::string& manifest_json) { bool uses_nonsfi_mode; if (manifest_->GetProgramURL( &program_url, &pnacl_options, &uses_nonsfi_mode, &error_info)) { - pp::Var program_url_var(program_url); - nacl_interface_->SetIsInstalled( - pp_instance(), - PP_FromBool( - nacl_interface_->GetUrlScheme(program_url_var.pp_var()) == - PP_SCHEME_CHROME_EXTENSION)); + // TODO(teravest): Make ProcessNaClManifest take responsibility for more of + // this function. + nacl_interface_->ProcessNaClManifest(pp_instance(), program_url.c_str()); uses_nonsfi_mode_ = uses_nonsfi_mode; - nacl_interface_->SetNaClReadyState(pp_instance(), - PP_NACL_READY_STATE_LOADING); - // Inform JavaScript that we found a nexe URL to load. - EnqueueProgressEvent(PP_NACL_EVENT_PROGRESS); if (pnacl_options.translate) { pp::CompletionCallback translate_callback = callback_factory_.NewCallback(&Plugin::BitcodeDidTranslate); @@ -1037,14 +1030,6 @@ void Plugin::ReportSelLdrLoadStatus(int status) { HistogramEnumerateSelLdrLoadStatus(static_cast<NaClErrorCode>(status)); } -void Plugin::EnqueueProgressEvent(PP_NaClEventType event_type) { - EnqueueProgressEvent(event_type, - NACL_NO_URL, - Plugin::LENGTH_IS_NOT_COMPUTABLE, - Plugin::kUnknownBytes, - Plugin::kUnknownBytes); -} - void Plugin::EnqueueProgressEvent(PP_NaClEventType event_type, const nacl::string& url, LengthComputable length_computable, diff --git a/ppapi/native_client/src/trusted/plugin/plugin.h b/ppapi/native_client/src/trusted/plugin/plugin.h index 59e7ca8..a1e12c3 100644 --- a/ppapi/native_client/src/trusted/plugin/plugin.h +++ b/ppapi/native_client/src/trusted/plugin/plugin.h @@ -134,7 +134,6 @@ class Plugin : public pp::Instance { // event (loadstart, progress, error, abort, load, loadend). Events are // enqueued on the JavaScript event loop, which then calls back through // DispatchProgressEvent. - void EnqueueProgressEvent(PP_NaClEventType event_type); void EnqueueProgressEvent(PP_NaClEventType event_type, const nacl::string& url, LengthComputable length_computable, 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 57dab9e..2d51251 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 @@ -3212,21 +3212,11 @@ static PP_NaClReadyState Pnacl_M25_PPB_NaCl_Private_GetNaClReadyState(PP_Instanc return iface->GetNaClReadyState(instance); } -static void Pnacl_M25_PPB_NaCl_Private_SetNaClReadyState(PP_Instance instance, PP_NaClReadyState ready_state) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - iface->SetNaClReadyState(instance, ready_state); -} - 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 void Pnacl_M25_PPB_NaCl_Private_SetIsInstalled(PP_Instance instance, PP_Bool is_installed) { - const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; - iface->SetIsInstalled(instance, is_installed); -} - 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); @@ -3272,6 +3262,11 @@ static void Pnacl_M25_PPB_NaCl_Private_ParseDataURL(struct PP_Var* _struct_resul *_struct_result = iface->ParseDataURL(data_url); } +static void Pnacl_M25_PPB_NaCl_Private_ProcessNaClManifest(PP_Instance instance, const char* program_url) { + const struct PPB_NaCl_Private_1_0 *iface = Pnacl_WrapperInfo_PPB_NaCl_Private_1_0.real_iface; + iface->ProcessNaClManifest(instance, program_url); +} + /* End wrapper methods for PPB_NaCl_Private_1_0 */ /* Begin wrapper methods for PPB_NetAddress_Private_0_1 */ @@ -5171,9 +5166,7 @@ static const struct PPB_NaCl_Private_1_0 Pnacl_Wrappers_PPB_NaCl_Private_1_0 = { .GetUrlScheme = (PP_UrlSchemeType (*)(struct PP_Var url))&Pnacl_M25_PPB_NaCl_Private_GetUrlScheme, .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, - .SetNaClReadyState = (void (*)(PP_Instance instance, PP_NaClReadyState ready_state))&Pnacl_M25_PPB_NaCl_Private_SetNaClReadyState, .GetIsInstalled = (PP_Bool (*)(PP_Instance instance))&Pnacl_M25_PPB_NaCl_Private_GetIsInstalled, - .SetIsInstalled = (void (*)(PP_Instance instance, PP_Bool is_installed))&Pnacl_M25_PPB_NaCl_Private_SetIsInstalled, .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, @@ -5182,7 +5175,8 @@ static const struct PPB_NaCl_Private_1_0 Pnacl_Wrappers_PPB_NaCl_Private_1_0 = { .RequestNaClManifest = (PP_Bool (*)(PP_Instance instance, const char* manifest_url, PP_Bool* is_data_uri))&Pnacl_M25_PPB_NaCl_Private_RequestNaClManifest, .GetManifestBaseURL = (struct PP_Var (*)(PP_Instance instance))&Pnacl_M25_PPB_NaCl_Private_GetManifestBaseURL, .ResolvesRelativeToPluginBaseUrl = (PP_Bool (*)(PP_Instance instance, const char* url))&Pnacl_M25_PPB_NaCl_Private_ResolvesRelativeToPluginBaseUrl, - .ParseDataURL = (struct PP_Var (*)(const char* data_url))&Pnacl_M25_PPB_NaCl_Private_ParseDataURL + .ParseDataURL = (struct PP_Var (*)(const char* data_url))&Pnacl_M25_PPB_NaCl_Private_ParseDataURL, + .ProcessNaClManifest = (void (*)(PP_Instance instance, const char* program_url))&Pnacl_M25_PPB_NaCl_Private_ProcessNaClManifest }; static const struct PPB_NetAddress_Private_0_1 Pnacl_Wrappers_PPB_NetAddress_Private_0_1 = { |