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

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

Issue 19863003: PNaCl on-demand installs: Make a separate async IPC to check if PNaCl is installed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: take out progress IPC for now Created 7 years, 4 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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 pnacl_options, 234 pnacl_options,
235 translate_notify_callback); 235 translate_notify_callback);
236 coordinator->pnacl_init_time_ = NaClGetTimeOfDayMicroseconds(); 236 coordinator->pnacl_init_time_ = NaClGetTimeOfDayMicroseconds();
237 coordinator->off_the_record_ = 237 coordinator->off_the_record_ =
238 plugin->nacl_interface()->IsOffTheRecord(); 238 plugin->nacl_interface()->IsOffTheRecord();
239 PLUGIN_PRINTF(("PnaclCoordinator::BitcodeToNative (manifest=%p, " 239 PLUGIN_PRINTF(("PnaclCoordinator::BitcodeToNative (manifest=%p, "
240 "off_the_record=%d)\n", 240 "off_the_record=%d)\n",
241 reinterpret_cast<const void*>(coordinator->manifest_.get()), 241 reinterpret_cast<const void*>(coordinator->manifest_.get()),
242 coordinator->off_the_record_)); 242 coordinator->off_the_record_));
243 243
244 // Loading resources (e.g. llc and ld nexes) is done with PnaclResources. 244 // First check that PNaCl is installed.
245 coordinator->resources_.reset( 245 pp::CompletionCallback pnacl_installed_cb =
246 new PnaclResources(plugin,
247 coordinator,
248 coordinator->manifest_.get()));
249 CHECK(coordinator->resources_ != NULL);
250
251 // The first step of loading resources: read the resource info file.
252 pp::CompletionCallback resource_info_read_cb =
253 coordinator->callback_factory_.NewCallback( 246 coordinator->callback_factory_.NewCallback(
254 &PnaclCoordinator::ResourceInfoWasRead); 247 &PnaclCoordinator::DidCheckPnaclInstalled);
255 coordinator->resources_->ReadResourceInfo(PnaclUrls::GetResourceInfoUrl(), 248 plugin->nacl_interface()->EnsurePnaclInstalled(
256 resource_info_read_cb); 249 plugin->pp_instance(),
250 pnacl_installed_cb.pp_completion_callback());
257 return coordinator; 251 return coordinator;
258 } 252 }
259 253
260 PnaclCoordinator::PnaclCoordinator( 254 PnaclCoordinator::PnaclCoordinator(
261 Plugin* plugin, 255 Plugin* plugin,
262 const nacl::string& pexe_url, 256 const nacl::string& pexe_url,
263 const PnaclOptions& pnacl_options, 257 const PnaclOptions& pnacl_options,
264 const pp::CompletionCallback& translate_notify_callback) 258 const pp::CompletionCallback& translate_notify_callback)
265 : translate_finish_error_(PP_OK), 259 : translate_finish_error_(PP_OK),
266 plugin_(plugin), 260 plugin_(plugin),
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 651
658 // Transfer ownership of cache/temp file's wrapper to the coordinator. 652 // Transfer ownership of cache/temp file's wrapper to the coordinator.
659 if (cached_nexe_file_ != NULL) { 653 if (cached_nexe_file_ != NULL) {
660 translated_fd_.reset(cached_nexe_file_->release_read_wrapper()); 654 translated_fd_.reset(cached_nexe_file_->release_read_wrapper());
661 } else { 655 } else {
662 translated_fd_.reset(temp_nexe_file_->release_read_wrapper()); 656 translated_fd_.reset(temp_nexe_file_->release_read_wrapper());
663 } 657 }
664 translate_notify_callback_.Run(pp_error); 658 translate_notify_callback_.Run(pp_error);
665 } 659 }
666 660
661 void PnaclCoordinator::DidCheckPnaclInstalled(int32_t pp_error) {
662 if (pp_error != PP_OK) {
663 ReportNonPpapiError(
664 ERROR_PNACL_RESOURCE_FETCH,
665 nacl::string("The Portable Native Client component is not installed"
666 " or has been disabled."));
667 return;
668 }
669
670 // Loading resources (e.g. llc and ld nexes) is done with PnaclResources.
671 resources_.reset(new PnaclResources(plugin_,
672 this,
673 this->manifest_.get()));
674 CHECK(resources_ != NULL);
675
676 // The first step of loading resources: read the resource info file.
677 pp::CompletionCallback resource_info_read_cb =
678 callback_factory_.NewCallback(
679 &PnaclCoordinator::ResourceInfoWasRead);
680 resources_->ReadResourceInfo(PnaclUrls::GetResourceInfoUrl(),
681 resource_info_read_cb);
682 }
683
667 void PnaclCoordinator::ResourceInfoWasRead(int32_t pp_error) { 684 void PnaclCoordinator::ResourceInfoWasRead(int32_t pp_error) {
668 PLUGIN_PRINTF(("PluginCoordinator::ResourceInfoWasRead (pp_error=%" 685 PLUGIN_PRINTF(("PluginCoordinator::ResourceInfoWasRead (pp_error=%"
669 NACL_PRId32 ")\n", pp_error)); 686 NACL_PRId32 ")\n", pp_error));
670 // Second step of loading resources: call StartLoad. 687 // Second step of loading resources: call StartLoad.
671 pp::CompletionCallback resources_cb = 688 pp::CompletionCallback resources_cb =
672 callback_factory_.NewCallback(&PnaclCoordinator::ResourcesDidLoad); 689 callback_factory_.NewCallback(&PnaclCoordinator::ResourcesDidLoad);
673 resources_->StartLoad(resources_cb); 690 resources_->StartLoad(resources_cb);
674 } 691 }
675 692
676 void PnaclCoordinator::ResourcesDidLoad(int32_t pp_error) { 693 void PnaclCoordinator::ResourcesDidLoad(int32_t pp_error) {
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 obj_file_.get(), 1078 obj_file_.get(),
1062 temp_nexe_file_.get(), 1079 temp_nexe_file_.get(),
1063 &error_info_, 1080 &error_info_,
1064 resources_.get(), 1081 resources_.get(),
1065 &pnacl_options_, 1082 &pnacl_options_,
1066 this, 1083 this,
1067 plugin_); 1084 plugin_);
1068 } 1085 }
1069 1086
1070 } // namespace plugin 1087 } // namespace plugin
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698