Chromium Code Reviews| Index: chrome/browser/nacl_host/nacl_process_host.cc |
| =================================================================== |
| --- chrome/browser/nacl_host/nacl_process_host.cc (revision 211556) |
| +++ chrome/browser/nacl_host/nacl_process_host.cc (working copy) |
| @@ -289,8 +289,8 @@ |
| NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); |
| nacl_browser->EnsureAllResourcesAvailable(); |
| if (!nacl_browser->IsOk()) { |
| - LOG(ERROR) << "NaCl process launch failed: could not find all the " |
| - "resources needed to launch the process"; |
| + SendErrorToRenderer("could not find all the resources needed" |
|
Mark Seaborn
2013/07/16 02:02:53
Are these error messages displayed in the console
halyavin
2013/07/16 08:04:35
Yes, they are prefixed with "NaCl process launch f
|
| + " to launch the process"); |
| delete this; |
| return; |
| } |
| @@ -307,7 +307,7 @@ |
| NaClHandle pair[2]; |
| // Create a connected socket |
| if (NaClSocketPair(pair) == -1) { |
| - LOG(ERROR) << "NaCl process launch failed: could not create a socket pair"; |
| + SendErrorToRenderer("could not create a socket pair"); |
| delete this; |
| return; |
| } |
| @@ -393,7 +393,7 @@ |
| bool NaClProcessHost::LaunchSelLdr() { |
| std::string channel_id = process_->GetHost()->CreateChannel(); |
| if (channel_id.empty()) { |
| - LOG(ERROR) << "NaCl process launch failed: could not create channel"; |
| + SendErrorToRenderer("could not create channel"); |
| return false; |
| } |
| @@ -428,6 +428,7 @@ |
| // On Windows 64-bit NaCl loader is called nacl64.exe instead of chrome.exe |
| if (RunningOnWOW64()) { |
| if (!NaClBrowser::GetInstance()->GetNaCl64ExePath(&exe_path)) { |
| + SendErrorToRenderer("could not resolve module"); |
|
Mark Seaborn
2013/07/16 02:02:53
How about: "Could not get nacl64.exe path"?
halyavin
2013/07/16 08:04:35
Done.
|
| return false; |
| } |
| } |
| @@ -450,8 +451,7 @@ |
| if (RunningOnWOW64()) { |
| if (!NaClBrokerService::GetInstance()->LaunchLoader( |
| weak_factory_.GetWeakPtr(), channel_id)) { |
| - LOG(ERROR) << "NaCl process launch failed: broker service did not launch " |
| - "process"; |
| + SendErrorToRenderer("broker service did not launch process"); |
| return false; |
| } |
| } else { |
| @@ -496,8 +496,7 @@ |
| void NaClProcessHost::OnResourcesReady() { |
| NaClBrowser* nacl_browser = NaClBrowser::GetInstance(); |
| if (!nacl_browser->IsReady()) { |
| - LOG(ERROR) << "NaCl process launch failed: could not acquire shared " |
| - "resources needed by NaCl"; |
| + SendErrorToRenderer("could not acquire shared resources needed by NaCl"); |
| delete this; |
| } else if (!SendStart()) { |
| delete this; |
| @@ -514,7 +513,7 @@ |
| // BrokerDuplicateHandle(). |
| if (RunningOnWOW64()) { |
| if (!content::BrokerAddTargetPeer(process_->GetData().handle)) { |
| - LOG(ERROR) << "Failed to add NaCl process PID"; |
| + SendErrorToRenderer("failed to add NaCl process PID"); |
| return false; |
| } |
| } |
| @@ -532,7 +531,7 @@ |
| 0, // Unused given DUPLICATE_SAME_ACCESS. |
| FALSE, |
| DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS)) { |
| - LOG(ERROR) << "DuplicateHandle() failed"; |
| + SendErrorToRenderer("DuplicateHandle() failed"); |
| return false; |
| } |
| handle_for_renderer = reinterpret_cast<nacl::FileDescriptor>( |
| @@ -547,16 +546,35 @@ |
| #endif |
| const ChildProcessData& data = process_->GetData(); |
| - NaClHostMsg_LaunchNaCl::WriteReplyParams( |
| - reply_msg_, handle_for_renderer, |
| - channel_handle, base::GetProcId(data.handle), data.id); |
| - nacl_host_message_filter_->Send(reply_msg_); |
| - nacl_host_message_filter_ = NULL; |
| - reply_msg_ = NULL; |
| + SendMessageToRenderer( |
| + nacl::NaClLaunchResult(handle_for_renderer, |
| + channel_handle, |
| + base::GetProcId(data.handle), |
| + data.id), |
| + std::string() /* error_message */); |
| internal_->socket_for_renderer = NACL_INVALID_HANDLE; |
| return true; |
| } |
| +void NaClProcessHost::SendErrorToRenderer(const std::string& error_message) { |
| + LOG(ERROR) << "NaCl process launch failed: " << error_message; |
| + SendMessageToRenderer(nacl::NaClLaunchResult(), error_message); |
| +} |
| + |
| +void NaClProcessHost::SendMessageToRenderer( |
| + const nacl::NaClLaunchResult& result, |
| + const std::string& error_message) { |
| + DCHECK(nacl_host_message_filter_); |
| + DCHECK(reply_msg_); |
| + if (nacl_host_message_filter_ != NULL && reply_msg_ != NULL) { |
| + NaClHostMsg_LaunchNaCl::WriteReplyParams( |
| + reply_msg_, result, error_message); |
| + nacl_host_message_filter_->Send(reply_msg_); |
| + nacl_host_message_filter_ = NULL; |
| + reply_msg_ = NULL; |
| + } |
| +} |
| + |
| // TCP port we chose for NaCl debug stub. It can be any other number. |
| static const int kDebugStubPort = 4014; |
| @@ -755,8 +773,7 @@ |
| weak_factory_.GetWeakPtr())); |
| return true; |
| } else { |
| - LOG(ERROR) << "NaCl process failed to launch: previously failed to acquire " |
| - "shared resources"; |
| + SendErrorToRenderer("previously failed to acquire shared resources"); |
| return false; |
| } |
| } |