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

Side by Side Diff: components/nacl/renderer/ppb_nacl_private_impl.cc

Issue 249183004: Implement open_resource in non-SFI mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 7 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/nacl/renderer/ppb_nacl_private_impl.h" 5 #include "components/nacl/renderer/ppb_nacl_private_impl.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/containers/scoped_ptr_hash_map.h" 10 #include "base/containers/scoped_ptr_hash_map.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 } 151 }
152 152
153 private: 153 private:
154 int num_remaining_calls_; 154 int num_remaining_calls_;
155 PP_CompletionCallback callback_; 155 PP_CompletionCallback callback_;
156 int32_t result_; 156 int32_t result_;
157 157
158 DISALLOW_COPY_AND_ASSIGN(ChannelConnectedCallback); 158 DISALLOW_COPY_AND_ASSIGN(ChannelConnectedCallback);
159 }; 159 };
160 160
161 // Thin adapter from PP_ManifestService to ManifestServiceChannel::Delegate. 161 // Thin adapter from PPP_ManifestService to ManifestServiceChannel::Delegate.
162 // Note that user_data is managed by the caller of LaunchSelLdr. Please see 162 // Note that user_data is managed by the caller of LaunchSelLdr. Please see
163 // also PP_ManifestService's comment for more details about resource 163 // also PP_ManifestService's comment for more details about resource
164 // management. 164 // management.
165 class ManifestServiceProxy : public ManifestServiceChannel::Delegate { 165 class ManifestServiceProxy : public ManifestServiceChannel::Delegate {
166 public: 166 public:
167 ManifestServiceProxy(const PP_ManifestService* manifest_service, 167 ManifestServiceProxy(const PPP_ManifestService* manifest_service,
168 void* user_data) 168 void* user_data)
169 : manifest_service_(*manifest_service), 169 : manifest_service_(*manifest_service),
170 user_data_(user_data) { 170 user_data_(user_data) {
171 } 171 }
172 172
173 virtual ~ManifestServiceProxy() { 173 virtual ~ManifestServiceProxy() {
174 Quit(); 174 Quit();
175 } 175 }
176 176
177 virtual void StartupInitializationComplete() OVERRIDE { 177 virtual void StartupInitializationComplete() OVERRIDE {
178 if (!user_data_) 178 if (!user_data_)
179 return; 179 return;
180 180
181 if (!PP_ToBool( 181 if (!PP_ToBool(
182 manifest_service_.StartupInitializationComplete(user_data_))) { 182 manifest_service_.StartupInitializationComplete(user_data_))) {
183 user_data_ = NULL; 183 user_data_ = NULL;
184 } 184 }
185 } 185 }
186 186
187 virtual void OpenResource(
188 const std::string& key,
189 const ManifestServiceChannel::OpenResourceCallback& callback) OVERRIDE {
190 if (!user_data_)
191 return;
192
193 // The allocated callback will be freed in DidOpenResource, which is always
194 // called regardless whether OpenResource() succeeds or fails.
195 if (!PP_ToBool(manifest_service_.OpenResource(
196 user_data_,
197 key.c_str(),
198 DidOpenResource,
199 new ManifestServiceChannel::OpenResourceCallback(callback)))) {
200 user_data_ = NULL;
201 }
202 }
203
187 private: 204 private:
205 static void DidOpenResource(void* user_data, PP_FileHandle file_handle) {
206 scoped_ptr<ManifestServiceChannel::OpenResourceCallback> callback(
207 static_cast<ManifestServiceChannel::OpenResourceCallback*>(user_data));
208 callback->Run(file_handle);
209 }
210
188 void Quit() { 211 void Quit() {
189 if (!user_data_) 212 if (!user_data_)
190 return; 213 return;
191 214
192 bool result = PP_ToBool(manifest_service_.Quit(user_data_)); 215 bool result = PP_ToBool(manifest_service_.Quit(user_data_));
193 DCHECK(!result); 216 DCHECK(!result);
194 user_data_ = NULL; 217 user_data_ = NULL;
195 } 218 }
196 219
197 PP_ManifestService manifest_service_; 220 PPP_ManifestService manifest_service_;
198 void* user_data_; 221 void* user_data_;
199 DISALLOW_COPY_AND_ASSIGN(ManifestServiceProxy); 222 DISALLOW_COPY_AND_ASSIGN(ManifestServiceProxy);
200 }; 223 };
201 224
202 // Launch NaCl's sel_ldr process. 225 // Launch NaCl's sel_ldr process.
203 void LaunchSelLdr(PP_Instance instance, 226 void LaunchSelLdr(PP_Instance instance,
204 const char* alleged_url, 227 const char* alleged_url,
205 PP_Bool uses_irt, 228 PP_Bool uses_irt,
206 PP_Bool uses_ppapi, 229 PP_Bool uses_ppapi,
207 PP_Bool uses_nonsfi_mode, 230 PP_Bool uses_nonsfi_mode,
208 PP_Bool enable_ppapi_dev, 231 PP_Bool enable_ppapi_dev,
209 PP_Bool enable_dyncode_syscalls, 232 PP_Bool enable_dyncode_syscalls,
210 PP_Bool enable_exception_handling, 233 PP_Bool enable_exception_handling,
211 PP_Bool enable_crash_throttling, 234 PP_Bool enable_crash_throttling,
212 const PP_ManifestService* manifest_service_interface, 235 const PPP_ManifestService* manifest_service_interface,
213 void* manifest_service_user_data, 236 void* manifest_service_user_data,
214 void* imc_handle, 237 void* imc_handle,
215 struct PP_Var* error_message, 238 struct PP_Var* error_message,
216 PP_CompletionCallback callback) { 239 PP_CompletionCallback callback) {
217 CHECK(ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()-> 240 CHECK(ppapi::PpapiGlobals::Get()->GetMainThreadMessageLoop()->
218 BelongsToCurrentThread()); 241 BelongsToCurrentThread());
219 242
220 // Create the manifest service proxy here, so on error case, it will be 243 // Create the manifest service proxy here, so on error case, it will be
221 // destructed (without passing it to ManifestServiceChannel), and QUIT 244 // destructed (without passing it to ManifestServiceChannel), and QUIT
222 // will be called in its destructor so that the caller of this function 245 // will be called in its destructor so that the caller of this function
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 connected_callback, 339 connected_callback,
317 content::RenderThread::Get()->GetShutdownEvent())); 340 content::RenderThread::Get()->GetShutdownEvent()));
318 load_manager->set_trusted_plugin_channel(trusted_plugin_channel.Pass()); 341 load_manager->set_trusted_plugin_channel(trusted_plugin_channel.Pass());
319 } else { 342 } else {
320 connected_callback.Run(PP_ERROR_FAILED); 343 connected_callback.Run(PP_ERROR_FAILED);
321 } 344 }
322 345
323 // Stash the manifest service handle as well. 346 // Stash the manifest service handle as well.
324 if (load_manager && 347 if (load_manager &&
325 IsValidChannelHandle( 348 IsValidChannelHandle(
326 launch_result.manifest_service_ipc_channel_handle)) { 349 launch_result.manifest_service_ipc_channel_handle)) {
Mark Seaborn 2014/05/01 23:28:33 Since you explained this in your previous reply...
hidehiko 2014/05/02 01:32:27 Done.
350 // For security hardening, disable the IPCs for open_resource() when they
351 // aren't needed. PNaCl doesn't expose open_resource(), and the new
352 // open_resource() IPCs are currently only used for Non-SFI NaCl so far,
353 // not SFI NaCl. Note that enable_dyncode_syscalls is true if and only if
354 // the plugin is a non-PNaCl plugin.
327 scoped_ptr<ManifestServiceChannel> manifest_service_channel( 355 scoped_ptr<ManifestServiceChannel> manifest_service_channel(
328 new ManifestServiceChannel( 356 new ManifestServiceChannel(
357 enable_dyncode_syscalls && uses_nonsfi_mode,
329 launch_result.manifest_service_ipc_channel_handle, 358 launch_result.manifest_service_ipc_channel_handle,
330 connected_callback, 359 connected_callback,
331 manifest_service_proxy.Pass(), 360 manifest_service_proxy.Pass(),
332 content::RenderThread::Get()->GetShutdownEvent())); 361 content::RenderThread::Get()->GetShutdownEvent()));
333 load_manager->set_manifest_service_channel( 362 load_manager->set_manifest_service_channel(
334 manifest_service_channel.Pass()); 363 manifest_service_channel.Pass());
335 } else { 364 } else {
336 // Currently, manifest service works only on linux/non-SFI mode. 365 // Currently, manifest service works only on linux/non-SFI mode.
337 // On other platforms, the socket will not be created, and thus this 366 // On other platforms, the socket will not be created, and thus this
338 // condition needs to be handled as success. 367 // condition needs to be handled as success.
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 &DevInterfacesEnabled 921 &DevInterfacesEnabled
893 }; 922 };
894 923
895 } // namespace 924 } // namespace
896 925
897 const PPB_NaCl_Private* GetNaClPrivateInterface() { 926 const PPB_NaCl_Private* GetNaClPrivateInterface() {
898 return &nacl_interface; 927 return &nacl_interface;
899 } 928 }
900 929
901 } // namespace nacl 930 } // namespace nacl
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698