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

Pepper: Move LogToConsole to NexeLoadManager.

BUG=239656

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@260259 0039d316-1c4b-4281-b951-d872f2087c98
parent bd8fab33
...@@ -97,7 +97,8 @@ NexeLoadManager::~NexeLoadManager() { ...@@ -97,7 +97,8 @@ NexeLoadManager::~NexeLoadManager() {
} }
void NexeLoadManager::ReportLoadError(PP_NaClError error, void NexeLoadManager::ReportLoadError(PP_NaClError error,
const std::string& error_message) { const std::string& error_message,
const std::string& console_message) {
// Check that we are on the main renderer thread. // Check that we are on the main renderer thread.
DCHECK(content::RenderThread::Get()); DCHECK(content::RenderThread::Get());
...@@ -108,9 +109,6 @@ void NexeLoadManager::ReportLoadError(PP_NaClError error, ...@@ -108,9 +109,6 @@ void NexeLoadManager::ReportLoadError(PP_NaClError error,
sender->Send( sender->Send(
new NaClHostMsg_MissingArchError(GetRoutingID(pp_instance_))); new NaClHostMsg_MissingArchError(GetRoutingID(pp_instance_)));
} }
// TODO(dmichael): Move the following actions here:
// - Print error message to JavaScript console.
set_nacl_ready_state(PP_NACL_READY_STATE_DONE); set_nacl_ready_state(PP_NACL_READY_STATE_DONE);
nexe_error_reported_ = true; nexe_error_reported_ = true;
...@@ -141,6 +139,8 @@ void NexeLoadManager::ReportLoadError(PP_NaClError error, ...@@ -141,6 +139,8 @@ void NexeLoadManager::ReportLoadError(PP_NaClError error,
"NaCl.LoadStatus.Plugin.InstalledApp" : "NaCl.LoadStatus.Plugin.InstalledApp" :
"NaCl.LoadStatus.Plugin.NotInstalledApp"; "NaCl.LoadStatus.Plugin.NotInstalledApp";
HistogramEnumerate(uma_name, error, PP_NACL_ERROR_MAX); HistogramEnumerate(uma_name, error, PP_NACL_ERROR_MAX);
LogToConsole(console_message);
} }
void NexeLoadManager::DispatchEvent(const ProgressEvent &event) { void NexeLoadManager::DispatchEvent(const ProgressEvent &event) {
...@@ -207,4 +207,9 @@ void NexeLoadManager::SetReadOnlyProperty(PP_Var key, PP_Var value) { ...@@ -207,4 +207,9 @@ void NexeLoadManager::SetReadOnlyProperty(PP_Var key, PP_Var value) {
plugin_instance_->SetEmbedProperty(key, value); plugin_instance_->SetEmbedProperty(key, value);
} }
void NexeLoadManager::LogToConsole(const std::string& message) {
ppapi::PpapiGlobals::Get()->LogWithSource(
pp_instance_, PP_LOGLEVEL_LOG, std::string("NativeClient"), message);
}
} // namespace nacl } // namespace nacl
...@@ -28,7 +28,9 @@ class NexeLoadManager { ...@@ -28,7 +28,9 @@ class NexeLoadManager {
explicit NexeLoadManager(PP_Instance instance); explicit NexeLoadManager(PP_Instance instance);
~NexeLoadManager(); ~NexeLoadManager();
void ReportLoadError(PP_NaClError error, const std::string& error_message); void ReportLoadError(PP_NaClError error,
const std::string& error_message,
const std::string& console_message);
// TODO(dmichael): Everything below this comment should eventually be made // TODO(dmichael): Everything below this comment should eventually be made
// private, when ppb_nacl_private_impl.cc is no longer using them directly. // private, when ppb_nacl_private_impl.cc is no longer using them directly.
...@@ -59,6 +61,7 @@ class NexeLoadManager { ...@@ -59,6 +61,7 @@ class NexeLoadManager {
void set_nacl_ready_state(PP_NaClReadyState ready_state); void set_nacl_ready_state(PP_NaClReadyState ready_state);
void SetReadOnlyProperty(PP_Var key, PP_Var value); void SetReadOnlyProperty(PP_Var key, PP_Var value);
void LogToConsole(const std::string& message);
bool is_installed() { return is_installed_; } bool is_installed() { return is_installed_; }
void set_is_installed(bool installed) { is_installed_ = installed; } void set_is_installed(bool installed) { is_installed_ = installed; }
......
...@@ -35,9 +35,6 @@ ...@@ -35,9 +35,6 @@
namespace { namespace {
// Forward declare LogToConsole() we can use it in other functions here.
void LogToConsole(PP_Instance instance, const char* message);
base::LazyInstance<scoped_refptr<PnaclTranslationResourceHost> > base::LazyInstance<scoped_refptr<PnaclTranslationResourceHost> >
g_pnacl_resource_host = LAZY_INSTANCE_INITIALIZER; g_pnacl_resource_host = LAZY_INSTANCE_INITIALIZER;
...@@ -449,8 +446,7 @@ void ReportLoadError(PP_Instance instance, ...@@ -449,8 +446,7 @@ void ReportLoadError(PP_Instance instance,
const char* console_message) { const char* console_message) {
nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance); nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance);
if (load_manager) if (load_manager)
load_manager->ReportLoadError(error, error_message); load_manager->ReportLoadError(error, error_message, console_message);
LogToConsole(instance, console_message);
} }
void InstanceCreated(PP_Instance instance) { void InstanceCreated(PP_Instance instance) {
...@@ -499,11 +495,10 @@ PP_UrlSchemeType GetUrlScheme(PP_Var url) { ...@@ -499,11 +495,10 @@ PP_UrlSchemeType GetUrlScheme(PP_Var url) {
} }
void LogToConsole(PP_Instance instance, const char* message) { void LogToConsole(PP_Instance instance, const char* message) {
std::string source("NativeClient"); nacl::NexeLoadManager* load_manager = GetNexeLoadManager(instance);
ppapi::PpapiGlobals::Get()->LogWithSource(instance, DCHECK(load_manager);
PP_LOGLEVEL_LOG, if (load_manager)
source, load_manager->LogToConsole(std::string(message));
std::string(message));
} }
PP_Bool GetNexeErrorReported(PP_Instance instance) { PP_Bool GetNexeErrorReported(PP_Instance instance) {
......
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