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

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

Issue 235983020: Pepper: Move PnaclOptions outside trusted plugin. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: another build fix Created 6 years, 8 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 "ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h" 5 #include "ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "native_client/src/include/checked_cast.h" 10 #include "native_client/src/include/checked_cast.h"
(...skipping 24 matching lines...) Expand all
35 // Here, we provide a manifest that redirects to PNaCl component files 35 // Here, we provide a manifest that redirects to PNaCl component files
36 // that are part of Chrome. 36 // that are part of Chrome.
37 class PnaclManifest : public Manifest { 37 class PnaclManifest : public Manifest {
38 public: 38 public:
39 PnaclManifest(const nacl::string& sandbox_arch) 39 PnaclManifest(const nacl::string& sandbox_arch)
40 : sandbox_arch_(sandbox_arch) { } 40 : sandbox_arch_(sandbox_arch) { }
41 41
42 virtual ~PnaclManifest() { } 42 virtual ~PnaclManifest() { }
43 43
44 virtual bool GetProgramURL(nacl::string* full_url, 44 virtual bool GetProgramURL(nacl::string* full_url,
45 PnaclOptions* pnacl_options, 45 PP_PNaClOptions* pnacl_options,
46 bool* uses_nonsfi_mode, 46 bool* uses_nonsfi_mode,
47 ErrorInfo* error_info) const { 47 ErrorInfo* error_info) const {
48 // Does not contain program urls. 48 // Does not contain program urls.
49 UNREFERENCED_PARAMETER(full_url); 49 UNREFERENCED_PARAMETER(full_url);
50 UNREFERENCED_PARAMETER(pnacl_options); 50 UNREFERENCED_PARAMETER(pnacl_options);
51 UNREFERENCED_PARAMETER(uses_nonsfi_mode); 51 UNREFERENCED_PARAMETER(uses_nonsfi_mode);
52 UNREFERENCED_PARAMETER(error_info); 52 UNREFERENCED_PARAMETER(error_info);
53 PLUGIN_PRINTF(("PnaclManifest does not contain a program\n")); 53 PLUGIN_PRINTF(("PnaclManifest does not contain a program\n"));
54 error_info->SetReport(PP_NACL_ERROR_MANIFEST_GET_NEXE_URL, 54 error_info->SetReport(PP_NACL_ERROR_MANIFEST_GET_NEXE_URL,
55 "pnacl manifest does not contain a program."); 55 "pnacl manifest does not contain a program.");
56 return false; 56 return false;
57 } 57 }
58 58
59 virtual bool GetFileKeys(std::set<nacl::string>* keys) const { 59 virtual bool GetFileKeys(std::set<nacl::string>* keys) const {
60 // Does not support enumeration. 60 // Does not support enumeration.
61 PLUGIN_PRINTF(("PnaclManifest does not support key enumeration\n")); 61 PLUGIN_PRINTF(("PnaclManifest does not support key enumeration\n"));
62 UNREFERENCED_PARAMETER(keys); 62 UNREFERENCED_PARAMETER(keys);
63 return false; 63 return false;
64 } 64 }
65 65
66 virtual bool ResolveKey(const nacl::string& key, 66 virtual bool ResolveKey(const nacl::string& key,
67 nacl::string* full_url, 67 nacl::string* full_url,
68 PnaclOptions* pnacl_options, 68 PP_PNaClOptions* pnacl_options,
69 ErrorInfo* error_info) const { 69 ErrorInfo* error_info) const {
70 // All of the component files are native (do not require pnacl translate). 70 // All of the component files are native (do not require pnacl translate).
71 pnacl_options->set_translate(false); 71 pnacl_options->translate = PP_FALSE;
72 // We can only resolve keys in the files/ namespace. 72 // We can only resolve keys in the files/ namespace.
73 const nacl::string kFilesPrefix = "files/"; 73 const nacl::string kFilesPrefix = "files/";
74 size_t files_prefix_pos = key.find(kFilesPrefix); 74 size_t files_prefix_pos = key.find(kFilesPrefix);
75 if (files_prefix_pos == nacl::string::npos) { 75 if (files_prefix_pos == nacl::string::npos) {
76 error_info->SetReport(PP_NACL_ERROR_MANIFEST_RESOLVE_URL, 76 error_info->SetReport(PP_NACL_ERROR_MANIFEST_RESOLVE_URL,
77 "key did not start with files/"); 77 "key did not start with files/");
78 return false; 78 return false;
79 } 79 }
80 // Resolve the full URL to the file. Provide it with a platform-specific 80 // Resolve the full URL to the file. Provide it with a platform-specific
81 // prefix. 81 // prefix.
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 ////////////////////////////////////////////////////////////////////// 174 //////////////////////////////////////////////////////////////////////
175 175
176 // Out-of-line destructor to keep it from getting put in every .o where 176 // Out-of-line destructor to keep it from getting put in every .o where
177 // callback_source.h is included 177 // callback_source.h is included
178 template<> 178 template<>
179 CallbackSource<FileStreamData>::~CallbackSource() {} 179 CallbackSource<FileStreamData>::~CallbackSource() {}
180 180
181 PnaclCoordinator* PnaclCoordinator::BitcodeToNative( 181 PnaclCoordinator* PnaclCoordinator::BitcodeToNative(
182 Plugin* plugin, 182 Plugin* plugin,
183 const nacl::string& pexe_url, 183 const nacl::string& pexe_url,
184 const PnaclOptions& pnacl_options, 184 const PP_PNaClOptions& pnacl_options,
185 const pp::CompletionCallback& translate_notify_callback) { 185 const pp::CompletionCallback& translate_notify_callback) {
186 PLUGIN_PRINTF(("PnaclCoordinator::BitcodeToNative (plugin=%p, pexe=%s)\n", 186 PLUGIN_PRINTF(("PnaclCoordinator::BitcodeToNative (plugin=%p, pexe=%s)\n",
187 static_cast<void*>(plugin), pexe_url.c_str())); 187 static_cast<void*>(plugin), pexe_url.c_str()));
188 PnaclCoordinator* coordinator = 188 PnaclCoordinator* coordinator =
189 new PnaclCoordinator(plugin, pexe_url, 189 new PnaclCoordinator(plugin, pexe_url,
190 pnacl_options, 190 pnacl_options,
191 translate_notify_callback); 191 translate_notify_callback);
192 coordinator->pnacl_init_time_ = NaClGetTimeOfDayMicroseconds(); 192 coordinator->pnacl_init_time_ = NaClGetTimeOfDayMicroseconds();
193 PLUGIN_PRINTF(("PnaclCoordinator::BitcodeToNative (manifest=%p, ", 193 PLUGIN_PRINTF(("PnaclCoordinator::BitcodeToNative (manifest=%p, ",
194 reinterpret_cast<const void*>(coordinator->manifest_.get()))); 194 reinterpret_cast<const void*>(coordinator->manifest_.get())));
195 195
196 int cpus = plugin->nacl_interface()->GetNumberOfProcessors(); 196 int cpus = plugin->nacl_interface()->GetNumberOfProcessors();
197 coordinator->split_module_count_ = std::min(4, std::max(1, cpus)); 197 coordinator->split_module_count_ = std::min(4, std::max(1, cpus));
198 198
199 // First start a network request for the pexe, to tickle the component 199 // First start a network request for the pexe, to tickle the component
200 // updater's On-Demand resource throttler, and to get Last-Modified/ETag 200 // updater's On-Demand resource throttler, and to get Last-Modified/ETag
201 // cache information. We can cancel the request later if there's 201 // cache information. We can cancel the request later if there's
202 // a bitcode->nexe cache hit. 202 // a bitcode->nexe cache hit.
203 coordinator->OpenBitcodeStream(); 203 coordinator->OpenBitcodeStream();
204 return coordinator; 204 return coordinator;
205 } 205 }
206 206
207 PnaclCoordinator::PnaclCoordinator( 207 PnaclCoordinator::PnaclCoordinator(
208 Plugin* plugin, 208 Plugin* plugin,
209 const nacl::string& pexe_url, 209 const nacl::string& pexe_url,
210 const PnaclOptions& pnacl_options, 210 const PP_PNaClOptions& pnacl_options,
211 const pp::CompletionCallback& translate_notify_callback) 211 const pp::CompletionCallback& translate_notify_callback)
212 : translate_finish_error_(PP_OK), 212 : translate_finish_error_(PP_OK),
213 plugin_(plugin), 213 plugin_(plugin),
214 translate_notify_callback_(translate_notify_callback), 214 translate_notify_callback_(translate_notify_callback),
215 translation_finished_reported_(false), 215 translation_finished_reported_(false),
216 manifest_(new PnaclManifest(plugin->nacl_interface()->GetSandboxArch())), 216 manifest_(new PnaclManifest(plugin->nacl_interface()->GetSandboxArch())),
217 pexe_url_(pexe_url), 217 pexe_url_(pexe_url),
218 pnacl_options_(pnacl_options), 218 pnacl_options_(pnacl_options),
219 split_module_count_(1), 219 split_module_count_(1),
220 num_object_files_opened_(0), 220 num_object_files_opened_(0),
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 if (ExpectedProgressKnown()) { 318 if (ExpectedProgressKnown()) {
319 pexe_bytes_compiled_ = expected_pexe_size_; 319 pexe_bytes_compiled_ = expected_pexe_size_;
320 plugin_->EnqueueProgressEvent(PP_NACL_EVENT_PROGRESS, 320 plugin_->EnqueueProgressEvent(PP_NACL_EVENT_PROGRESS,
321 pexe_url_, 321 pexe_url_,
322 plugin::Plugin::LENGTH_IS_COMPUTABLE, 322 plugin::Plugin::LENGTH_IS_COMPUTABLE,
323 pexe_bytes_compiled_, 323 pexe_bytes_compiled_,
324 expected_pexe_size_); 324 expected_pexe_size_);
325 } 325 }
326 326
327 // If there are no errors, report stats from this thread (the main thread). 327 // If there are no errors, report stats from this thread (the main thread).
328 HistogramOptLevel(plugin_->uma_interface(), pnacl_options_.opt_level()); 328 HistogramOptLevel(plugin_->uma_interface(), pnacl_options_.opt_level);
329 HistogramKBPerSec(plugin_->uma_interface(), 329 HistogramKBPerSec(plugin_->uma_interface(),
330 "NaCl.Perf.PNaClLoadTime.CompileKBPerSec", 330 "NaCl.Perf.PNaClLoadTime.CompileKBPerSec",
331 pexe_size_ / 1024.0, 331 pexe_size_ / 1024.0,
332 translate_thread_->GetCompileTime() / 1000000.0); 332 translate_thread_->GetCompileTime() / 1000000.0);
333 HistogramSizeKB(plugin_->uma_interface(), "NaCl.Perf.Size.Pexe", 333 HistogramSizeKB(plugin_->uma_interface(), "NaCl.Perf.Size.Pexe",
334 static_cast<int64_t>(pexe_size_ / 1024)); 334 static_cast<int64_t>(pexe_size_ / 1024));
335 335
336 struct nacl_abi_stat stbuf; 336 struct nacl_abi_stat stbuf;
337 struct NaClDesc* desc = temp_nexe_file_->read_wrapper()->desc(); 337 struct NaClDesc* desc = temp_nexe_file_->read_wrapper()->desc();
338 int stat_ret; 338 int stat_ret;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 temp_nexe_file_.reset(new TempFile(plugin_)); 476 temp_nexe_file_.reset(new TempFile(plugin_));
477 pp::CompletionCallback cb = 477 pp::CompletionCallback cb =
478 callback_factory_.NewCallback(&PnaclCoordinator::NexeFdDidOpen); 478 callback_factory_.NewCallback(&PnaclCoordinator::NexeFdDidOpen);
479 int32_t nexe_fd_err = 479 int32_t nexe_fd_err =
480 plugin_->nacl_interface()->GetNexeFd( 480 plugin_->nacl_interface()->GetNexeFd(
481 plugin_->pp_instance(), 481 plugin_->pp_instance(),
482 streaming_downloader_->full_url().c_str(), 482 streaming_downloader_->full_url().c_str(),
483 // TODO(dschuff): Get this value from the pnacl json file after it 483 // TODO(dschuff): Get this value from the pnacl json file after it
484 // rolls in from NaCl. 484 // rolls in from NaCl.
485 1, 485 1,
486 pnacl_options_.opt_level(), 486 pnacl_options_.opt_level,
487 headers.c_str(), 487 headers.c_str(),
488 "", // No extra compile flags yet. 488 "", // No extra compile flags yet.
489 &is_cache_hit_, 489 &is_cache_hit_,
490 temp_nexe_file_->existing_handle(), 490 temp_nexe_file_->existing_handle(),
491 cb.pp_completion_callback()); 491 cb.pp_completion_callback());
492 if (nexe_fd_err < PP_OK_COMPLETIONPENDING) { 492 if (nexe_fd_err < PP_OK_COMPLETIONPENDING) {
493 ReportPpapiError(PP_NACL_ERROR_PNACL_CREATE_TEMP, nexe_fd_err, 493 ReportPpapiError(PP_NACL_ERROR_PNACL_CREATE_TEMP, nexe_fd_err,
494 nacl::string("Call to GetNexeFd failed")); 494 nacl::string("Call to GetNexeFd failed"));
495 } 495 }
496 } 496 }
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 temp_nexe_file_.get(), 682 temp_nexe_file_.get(),
683 invalid_desc_wrapper_.get(), 683 invalid_desc_wrapper_.get(),
684 &error_info_, 684 &error_info_,
685 resources_.get(), 685 resources_.get(),
686 &pnacl_options_, 686 &pnacl_options_,
687 this, 687 this,
688 plugin_); 688 plugin_);
689 } 689 }
690 690
691 } // namespace plugin 691 } // namespace plugin
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698