Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(219)

Side by Side Diff: chrome/renderer/pepper/ppb_nacl_private_impl.cc

Issue 18045007: Show more different NaCl loading errors. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/renderer/pepper/ppb_nacl_private_impl.h" 5 #include "chrome/renderer/pepper/ppb_nacl_private_impl.h"
6 6
7 #ifndef DISABLE_NACL 7 #ifndef DISABLE_NACL
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 } 87 }
88 88
89 // Launch NaCl's sel_ldr process. 89 // Launch NaCl's sel_ldr process.
90 PP_NaClResult LaunchSelLdr(PP_Instance instance, 90 PP_NaClResult LaunchSelLdr(PP_Instance instance,
91 const char* alleged_url, 91 const char* alleged_url,
92 PP_Bool uses_irt, 92 PP_Bool uses_irt,
93 PP_Bool uses_ppapi, 93 PP_Bool uses_ppapi,
94 PP_Bool enable_ppapi_dev, 94 PP_Bool enable_ppapi_dev,
95 PP_Bool enable_dyncode_syscalls, 95 PP_Bool enable_dyncode_syscalls,
96 PP_Bool enable_exception_handling, 96 PP_Bool enable_exception_handling,
97 void* imc_handle) { 97 void* imc_handle,
98 struct PP_Var* error_message) {
98 nacl::FileDescriptor result_socket; 99 nacl::FileDescriptor result_socket;
99 IPC::Sender* sender = content::RenderThread::Get(); 100 IPC::Sender* sender = content::RenderThread::Get();
100 DCHECK(sender); 101 DCHECK(sender);
102 *error_message = PP_MakeUndefined();
101 int routing_id = 0; 103 int routing_id = 0;
102 // If the nexe uses ppapi APIs, we need a routing ID. 104 // If the nexe uses ppapi APIs, we need a routing ID.
103 // To get the routing ID, we must be on the main thread. 105 // To get the routing ID, we must be on the main thread.
104 // Some nexes do not use ppapi and launch from the background thread, 106 // Some nexes do not use ppapi and launch from the background thread,
105 // so those nexes can skip finding a routing_id. 107 // so those nexes can skip finding a routing_id.
106 if (uses_ppapi) { 108 if (uses_ppapi) {
107 routing_id = GetRoutingID(instance); 109 routing_id = GetRoutingID(instance);
108 if (!routing_id) 110 if (!routing_id)
109 return PP_NACL_FAILED; 111 return PP_NACL_FAILED;
110 } 112 }
111 113
112 InstanceInfo instance_info; 114 InstanceInfo instance_info;
113 instance_info.url = GURL(alleged_url); 115 instance_info.url = GURL(alleged_url);
114 116
115 uint32_t perm_bits = ppapi::PERMISSION_NONE; 117 uint32_t perm_bits = ppapi::PERMISSION_NONE;
116 // Conditionally block 'Dev' interfaces. We do this for the NaCl process, so 118 // Conditionally block 'Dev' interfaces. We do this for the NaCl process, so
117 // it's clearer to developers when they are using 'Dev' inappropriately. We 119 // it's clearer to developers when they are using 'Dev' inappropriately. We
118 // must also check on the trusted side of the proxy. 120 // must also check on the trusted side of the proxy.
119 if (enable_ppapi_dev) 121 if (enable_ppapi_dev)
120 perm_bits |= ppapi::PERMISSION_DEV; 122 perm_bits |= ppapi::PERMISSION_DEV;
121 instance_info.permissions = 123 instance_info.permissions =
122 ppapi::PpapiPermissions::GetForCommandLine(perm_bits); 124 ppapi::PpapiPermissions::GetForCommandLine(perm_bits);
125 std::string error_message_string;
126 nacl::NaClLaunchResult launch_result;
123 127
124 if (!sender->Send(new NaClHostMsg_LaunchNaCl( 128 if (!sender->Send(new NaClHostMsg_LaunchNaCl(
125 nacl::NaClLaunchParams(instance_info.url.spec(), 129 nacl::NaClLaunchParams(instance_info.url.spec(),
126 routing_id, 130 routing_id,
127 perm_bits, 131 perm_bits,
128 PP_ToBool(uses_irt), 132 PP_ToBool(uses_irt),
129 PP_ToBool(enable_dyncode_syscalls), 133 PP_ToBool(enable_dyncode_syscalls),
130 PP_ToBool(enable_exception_handling)), 134 PP_ToBool(enable_exception_handling)),
131 &result_socket, 135 &launch_result,
132 &instance_info.channel_handle, 136 &error_message_string))) {
133 &instance_info.plugin_pid,
134 &instance_info.plugin_child_id))) {
135 return PP_NACL_FAILED; 137 return PP_NACL_FAILED;
136 } 138 }
137 139 if (!error_message_string.empty()) {
140 *error_message = ppapi::StringVar::StringToPPVar(error_message_string);
141 return PP_NACL_FAILED;
142 }
143 result_socket = launch_result.imc_channel_handle;
144 instance_info.channel_handle = launch_result.ipc_channel_handle;
145 instance_info.plugin_pid = launch_result.plugin_pid;
146 instance_info.plugin_child_id = launch_result.plugin_child_id;
138 // Don't save instance_info if channel handle is invalid. 147 // Don't save instance_info if channel handle is invalid.
139 bool invalid_handle = instance_info.channel_handle.name.empty(); 148 bool invalid_handle = instance_info.channel_handle.name.empty();
140 #if defined(OS_POSIX) 149 #if defined(OS_POSIX)
141 if (!invalid_handle) 150 if (!invalid_handle)
142 invalid_handle = (instance_info.channel_handle.socket.fd == -1); 151 invalid_handle = (instance_info.channel_handle.socket.fd == -1);
143 #endif 152 #endif
144 if (!invalid_handle) 153 if (!invalid_handle)
145 g_instance_info.Get()[instance] = instance_info; 154 g_instance_info.Get()[instance] = instance_info;
146 155
147 *(static_cast<NaClHandle*>(imc_handle)) = 156 *(static_cast<NaClHandle*>(imc_handle)) =
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 &OpenNaClExecutable 396 &OpenNaClExecutable
388 }; 397 };
389 398
390 } // namespace 399 } // namespace
391 400
392 const PPB_NaCl_Private* PPB_NaCl_Private_Impl::GetInterface() { 401 const PPB_NaCl_Private* PPB_NaCl_Private_Impl::GetInterface() {
393 return &nacl_interface; 402 return &nacl_interface;
394 } 403 }
395 404
396 #endif // DISABLE_NACL 405 #endif // DISABLE_NACL
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698