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

Side by Side Diff: ppapi/native_client/src/trusted/plugin/plugin.cc

Issue 263683002: Set file tokens for NaCl main nexe if available to enable validation caching. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: concat filepath literal 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
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 #ifdef _MSC_VER 5 #ifdef _MSC_VER
6 // Do not warn about use of std::copy with raw pointers. 6 // Do not warn about use of std::copy with raw pointers.
7 #pragma warning(disable : 4996) 7 #pragma warning(disable : 4996)
8 #endif 8 #endif
9 9
10 #include "ppapi/native_client/src/trusted/plugin/plugin.h" 10 #include "ppapi/native_client/src/trusted/plugin/plugin.h"
11 11
12 #include <sys/stat.h> 12 #include <sys/stat.h>
13 #include <sys/types.h> 13 #include <sys/types.h>
14 14
15 #include <algorithm> 15 #include <algorithm>
16 #include <string> 16 #include <string>
17 #include <vector> 17 #include <vector>
18 18
19 #include "native_client/src/include/nacl_base.h" 19 #include "native_client/src/include/nacl_base.h"
20 #include "native_client/src/include/nacl_macros.h" 20 #include "native_client/src/include/nacl_macros.h"
21 #include "native_client/src/include/nacl_scoped_ptr.h" 21 #include "native_client/src/include/nacl_scoped_ptr.h"
22 #include "native_client/src/include/nacl_string.h" 22 #include "native_client/src/include/nacl_string.h"
23 #include "native_client/src/include/portability.h" 23 #include "native_client/src/include/portability.h"
24 #include "native_client/src/include/portability_io.h" 24 #include "native_client/src/include/portability_io.h"
25 #include "native_client/src/include/portability_string.h" 25 #include "native_client/src/include/portability_string.h"
26 #include "native_client/src/public/nacl_file_info.h"
26 #include "native_client/src/shared/platform/nacl_check.h" 27 #include "native_client/src/shared/platform/nacl_check.h"
27 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" 28 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h"
28 #include "native_client/src/trusted/nonnacl_util/sel_ldr_launcher.h" 29 #include "native_client/src/trusted/nonnacl_util/sel_ldr_launcher.h"
29 #include "native_client/src/trusted/service_runtime/nacl_error_code.h" 30 #include "native_client/src/trusted/service_runtime/nacl_error_code.h"
30 31
31 #include "ppapi/c/pp_errors.h" 32 #include "ppapi/c/pp_errors.h"
32 #include "ppapi/c/ppb_var.h" 33 #include "ppapi/c/ppb_var.h"
33 #include "ppapi/c/private/ppb_nacl_private.h" 34 #include "ppapi/c/private/ppb_nacl_private.h"
34 #include "ppapi/cpp/dev/url_util_dev.h" 35 #include "ppapi/cpp/dev/url_util_dev.h"
35 #include "ppapi/cpp/module.h" 36 #include "ppapi/cpp/module.h"
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 } 324 }
324 325
325 Plugin::Plugin(PP_Instance pp_instance) 326 Plugin::Plugin(PP_Instance pp_instance)
326 : pp::Instance(pp_instance), 327 : pp::Instance(pp_instance),
327 main_subprocess_("main subprocess", NULL, NULL), 328 main_subprocess_("main subprocess", NULL, NULL),
328 uses_nonsfi_mode_(false), 329 uses_nonsfi_mode_(false),
329 wrapper_factory_(NULL), 330 wrapper_factory_(NULL),
330 time_of_last_progress_event_(0), 331 time_of_last_progress_event_(0),
331 manifest_id_(-1), 332 manifest_id_(-1),
332 nexe_handle_(PP_kInvalidFileHandle), 333 nexe_handle_(PP_kInvalidFileHandle),
334 nexe_token_lo_(0),
335 nexe_token_hi_(0),
333 nacl_interface_(NULL), 336 nacl_interface_(NULL),
334 uma_interface_(this) { 337 uma_interface_(this) {
335 PLUGIN_PRINTF(("Plugin::Plugin (this=%p, pp_instance=%" 338 PLUGIN_PRINTF(("Plugin::Plugin (this=%p, pp_instance=%"
336 NACL_PRId32 ")\n", static_cast<void*>(this), pp_instance)); 339 NACL_PRId32 ")\n", static_cast<void*>(this), pp_instance));
337 callback_factory_.Initialize(this); 340 callback_factory_.Initialize(this);
338 nacl_interface_ = GetNaClInterface(); 341 nacl_interface_ = GetNaClInterface();
339 CHECK(nacl_interface_ != NULL); 342 CHECK(nacl_interface_ != NULL);
340 343
341 // Notify PPB_NaCl_Private that the instance is created before altering any 344 // Notify PPB_NaCl_Private that the instance is created before altering any
342 // state that it tracks. 345 // state that it tracks.
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 static_cast<void*>(this))); 407 static_cast<void*>(this)));
405 // We don't know if the plugin will handle the document load, but return 408 // We don't know if the plugin will handle the document load, but return
406 // true in order to give it a chance to respond once the proxy is started. 409 // true in order to give it a chance to respond once the proxy is started.
407 return true; 410 return true;
408 } 411 }
409 412
410 void Plugin::NexeFileDidOpen(int32_t pp_error) { 413 void Plugin::NexeFileDidOpen(int32_t pp_error) {
411 if (pp_error != PP_OK) 414 if (pp_error != PP_OK)
412 return; 415 return;
413 416
414 int32_t desc = ConvertFileDescriptor(nexe_handle_, true); 417 NaClFileInfo nexe_file_info;
418 nexe_file_info.desc = ConvertFileDescriptor(nexe_handle_, true);
419 nexe_file_info.file_token.lo = nexe_token_lo_;
420 nexe_file_info.file_token.hi = nexe_token_hi_;
415 nexe_handle_ = PP_kInvalidFileHandle; // Clear out nexe handle. 421 nexe_handle_ = PP_kInvalidFileHandle; // Clear out nexe handle.
422 nexe_token_lo_ = 0;
423 nexe_token_hi_ = 0;
424
425 NaClDesc *desc = NaClDescIoFromFileInfo(nexe_file_info, O_RDONLY);
426 if (desc == NULL)
427 return;
428 // nexe_file_info_ is handed to desc, clear out old copy.
429 memset(&nexe_file_info, 0, sizeof nexe_file_info);
430 nexe_file_info.desc = -1;
416 431
417 nacl::scoped_ptr<nacl::DescWrapper> 432 nacl::scoped_ptr<nacl::DescWrapper>
418 wrapper(wrapper_factory()->MakeFileDesc(desc, O_RDONLY)); 433 wrapper(wrapper_factory()->MakeGenericCleanup(desc));
419 NaClLog(4, "NexeFileDidOpen: invoking LoadNaClModule\n"); 434 NaClLog(4, "NexeFileDidOpen: invoking LoadNaClModule\n");
420 LoadNaClModule( 435 LoadNaClModule(
421 wrapper.release(), 436 wrapper.release(),
422 uses_nonsfi_mode_, 437 uses_nonsfi_mode_,
423 true, /* enable_dyncode_syscalls */ 438 true, /* enable_dyncode_syscalls */
424 true, /* enable_exception_handling */ 439 true, /* enable_exception_handling */
425 false, /* enable_crash_throttling */ 440 false, /* enable_crash_throttling */
426 callback_factory_.NewCallback(&Plugin::NexeFileDidOpenContinuation), 441 callback_factory_.NewCallback(&Plugin::NexeFileDidOpenContinuation),
427 callback_factory_.NewCallback(&Plugin::NexeDidCrash)); 442 callback_factory_.NewCallback(&Plugin::NexeDidCrash));
428 } 443 }
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 pnacl_options, 534 pnacl_options,
520 translate_callback)); 535 translate_callback));
521 return; 536 return;
522 } else { 537 } else {
523 pp::CompletionCallback open_callback = 538 pp::CompletionCallback open_callback =
524 callback_factory_.NewCallback(&Plugin::NexeFileDidOpen); 539 callback_factory_.NewCallback(&Plugin::NexeFileDidOpen);
525 // Will always call the callback on success or failure. 540 // Will always call the callback on success or failure.
526 nacl_interface_->DownloadNexe(pp_instance(), 541 nacl_interface_->DownloadNexe(pp_instance(),
527 program_url_.c_str(), 542 program_url_.c_str(),
528 &nexe_handle_, 543 &nexe_handle_,
544 &nexe_token_lo_,
545 &nexe_token_hi_,
529 open_callback.pp_completion_callback()); 546 open_callback.pp_completion_callback());
530 return; 547 return;
531 } 548 }
532 } 549 }
533 } 550 }
534 551
535 void Plugin::RequestNaClManifest(const nacl::string& url) { 552 void Plugin::RequestNaClManifest(const nacl::string& url) {
536 PLUGIN_PRINTF(("Plugin::RequestNaClManifest (url='%s')\n", url.c_str())); 553 PLUGIN_PRINTF(("Plugin::RequestNaClManifest (url='%s')\n", url.c_str()));
537 pp::CompletionCallback open_callback = 554 pp::CompletionCallback open_callback =
538 callback_factory_.NewCallback(&Plugin::NaClManifestFileDidOpen); 555 callback_factory_.NewCallback(&Plugin::NaClManifestFileDidOpen);
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 745
729 void Plugin::SetExitStatusOnMainThread(int32_t pp_error, 746 void Plugin::SetExitStatusOnMainThread(int32_t pp_error,
730 int exit_status) { 747 int exit_status) {
731 DCHECK(pp::Module::Get()->core()->IsMainThread()); 748 DCHECK(pp::Module::Get()->core()->IsMainThread());
732 DCHECK(nacl_interface_); 749 DCHECK(nacl_interface_);
733 nacl_interface_->SetExitStatus(pp_instance(), exit_status); 750 nacl_interface_->SetExitStatus(pp_instance(), exit_status);
734 } 751 }
735 752
736 753
737 } // namespace plugin 754 } // namespace plugin
OLDNEW
« no previous file with comments | « ppapi/native_client/src/trusted/plugin/plugin.h ('k') | ppapi/native_client/src/untrusted/pnacl_irt_shim/pnacl_shim.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698