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

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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 } 68 }
69 69
70 // Launch NaCl's sel_ldr process. 70 // Launch NaCl's sel_ldr process.
71 PP_NaClResult LaunchSelLdr(PP_Instance instance, 71 PP_NaClResult LaunchSelLdr(PP_Instance instance,
72 const char* alleged_url, 72 const char* alleged_url,
73 PP_Bool uses_irt, 73 PP_Bool uses_irt,
74 PP_Bool uses_ppapi, 74 PP_Bool uses_ppapi,
75 PP_Bool enable_ppapi_dev, 75 PP_Bool enable_ppapi_dev,
76 PP_Bool enable_dyncode_syscalls, 76 PP_Bool enable_dyncode_syscalls,
77 PP_Bool enable_exception_handling, 77 PP_Bool enable_exception_handling,
78 void* imc_handle) { 78 void* imc_handle,
79 struct PP_Var* error_message) {
79 nacl::FileDescriptor result_socket; 80 nacl::FileDescriptor result_socket;
80 IPC::Sender* sender = content::RenderThread::Get(); 81 IPC::Sender* sender = content::RenderThread::Get();
81 if (sender == NULL) 82 if (sender == NULL)
82 sender = g_background_thread_sender.Pointer()->get(); 83 sender = g_background_thread_sender.Pointer()->get();
84 *error_message = ppapi::StringVar::StringToPPVar("");
dmichael (off chromium) 2013/07/10 17:07:20 The PP_Var you're getting has a ref-count of 1, so
halyavin 2013/07/11 09:03:36 Done.
83 85
84 int routing_id = 0; 86 int routing_id = 0;
85 // If the nexe uses ppapi APIs, we need a routing ID. 87 // If the nexe uses ppapi APIs, we need a routing ID.
86 // To get the routing ID, we must be on the main thread. 88 // To get the routing ID, we must be on the main thread.
87 // Some nexes do not use ppapi and launch from the background thread, 89 // Some nexes do not use ppapi and launch from the background thread,
88 // so those nexes can skip finding a routing_id. 90 // so those nexes can skip finding a routing_id.
89 if (uses_ppapi) { 91 if (uses_ppapi) {
90 routing_id = GetRoutingID(instance); 92 routing_id = GetRoutingID(instance);
91 if (!routing_id) 93 if (!routing_id)
92 return PP_NACL_FAILED; 94 return PP_NACL_FAILED;
93 } 95 }
94 96
95 InstanceInfo instance_info; 97 InstanceInfo instance_info;
96 instance_info.url = GURL(alleged_url); 98 instance_info.url = GURL(alleged_url);
97 99
98 uint32_t perm_bits = ppapi::PERMISSION_NONE; 100 uint32_t perm_bits = ppapi::PERMISSION_NONE;
99 // Conditionally block 'Dev' interfaces. We do this for the NaCl process, so 101 // Conditionally block 'Dev' interfaces. We do this for the NaCl process, so
100 // it's clearer to developers when they are using 'Dev' inappropriately. We 102 // it's clearer to developers when they are using 'Dev' inappropriately. We
101 // must also check on the trusted side of the proxy. 103 // must also check on the trusted side of the proxy.
102 if (enable_ppapi_dev) 104 if (enable_ppapi_dev)
103 perm_bits |= ppapi::PERMISSION_DEV; 105 perm_bits |= ppapi::PERMISSION_DEV;
104 instance_info.permissions = 106 instance_info.permissions =
105 ppapi::PpapiPermissions::GetForCommandLine(perm_bits); 107 ppapi::PpapiPermissions::GetForCommandLine(perm_bits);
108 std::string error_message_string;
109 nacl::NaClLaunchResult launch_result;
106 110
107 if (!sender->Send(new NaClHostMsg_LaunchNaCl( 111 if (!sender->Send(new NaClHostMsg_LaunchNaCl(
108 nacl::NaClLaunchParams(instance_info.url.spec(), 112 nacl::NaClLaunchParams(instance_info.url.spec(),
109 routing_id, 113 routing_id,
110 perm_bits, 114 perm_bits,
111 PP_ToBool(uses_irt), 115 PP_ToBool(uses_irt),
112 PP_ToBool(enable_dyncode_syscalls), 116 PP_ToBool(enable_dyncode_syscalls),
113 PP_ToBool(enable_exception_handling)), 117 PP_ToBool(enable_exception_handling)),
114 &result_socket, 118 &launch_result,
115 &instance_info.channel_handle, 119 &error_message_string))) {
116 &instance_info.plugin_pid,
117 &instance_info.plugin_child_id))) {
118 return PP_NACL_FAILED; 120 return PP_NACL_FAILED;
119 } 121 }
120 122 if (!error_message_string.empty()) {
123 *error_message = ppapi::StringVar::StringToPPVar(error_message_string);
124 return PP_NACL_FAILED;
125 }
126 result_socket = launch_result.imc_channel_handle;
127 instance_info.channel_handle = launch_result.ipc_channel_handle;
128 instance_info.plugin_pid = launch_result.plugin_pid;
129 instance_info.plugin_child_id = launch_result.plugin_child_id;
121 // Don't save instance_info if channel handle is invalid. 130 // Don't save instance_info if channel handle is invalid.
122 bool invalid_handle = instance_info.channel_handle.name.empty(); 131 bool invalid_handle = instance_info.channel_handle.name.empty();
123 #if defined(OS_POSIX) 132 #if defined(OS_POSIX)
124 if (!invalid_handle) 133 if (!invalid_handle)
125 invalid_handle = (instance_info.channel_handle.socket.fd == -1); 134 invalid_handle = (instance_info.channel_handle.socket.fd == -1);
126 #endif 135 #endif
127 if (!invalid_handle) 136 if (!invalid_handle)
128 g_instance_info.Get()[instance] = instance_info; 137 g_instance_info.Get()[instance] = instance_info;
129 138
130 *(static_cast<NaClHandle*>(imc_handle)) = 139 *(static_cast<NaClHandle*>(imc_handle)) =
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 &OpenNaClExecutable 353 &OpenNaClExecutable
345 }; 354 };
346 355
347 } // namespace 356 } // namespace
348 357
349 const PPB_NaCl_Private* PPB_NaCl_Private_Impl::GetInterface() { 358 const PPB_NaCl_Private* PPB_NaCl_Private_Impl::GetInterface() {
350 return &nacl_interface; 359 return &nacl_interface;
351 } 360 }
352 361
353 #endif // DISABLE_NACL 362 #endif // DISABLE_NACL
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698