summaryrefslogtreecommitdiffstats
path: root/ppapi
diff options
context:
space:
mode:
authorteravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-24 20:47:07 +0000
committerteravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-24 20:47:07 +0000
commit9565a418880f5149f721f5657c3f9b1a408e8dad (patch)
tree9b250c2de3a8d94e09b11b39daa777a340dc9dcc /ppapi
parentc74549b39d3d48c49f9a94a91001c3b5f41e344b (diff)
downloadchromium_src-9565a418880f5149f721f5657c3f9b1a408e8dad.zip
chromium_src-9565a418880f5149f721f5657c3f9b1a408e8dad.tar.gz
chromium_src-9565a418880f5149f721f5657c3f9b1a408e8dad.tar.bz2
Pepper: Remove callback for resource loading.
Using CompletionCallbacks for PNaClResources::StartLoad and PNaClResources::ReadResourceInfo doesn't accomplish much and makes the code more complicated. This is in preparation for a larger change to get rid of FileDownloader for streaming pexe downloads. BUG=239656 Review URL: https://codereview.chromium.org/358443002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@279485 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi')
-rw-r--r--ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc21
-rw-r--r--ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h5
-rw-r--r--ppapi/native_client/src/trusted/plugin/pnacl_resources.cc22
-rw-r--r--ppapi/native_client/src/trusted/plugin/pnacl_resources.h6
4 files changed, 11 insertions, 43 deletions
diff --git a/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc b/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc
index b85b446..0c453c8 100644
--- a/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc
+++ b/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.cc
@@ -312,29 +312,14 @@ void PnaclCoordinator::BitcodeStreamDidOpen(int32_t pp_error) {
CHECK(resources_ != NULL);
// The first step of loading resources: read the resource info file.
- pp::CompletionCallback resource_info_read_cb =
- callback_factory_.NewCallback(&PnaclCoordinator::ResourceInfoWasRead);
- resources_->ReadResourceInfo(resource_info_read_cb);
-}
-
-void PnaclCoordinator::ResourceInfoWasRead(int32_t pp_error) {
- PLUGIN_PRINTF(("PluginCoordinator::ResourceInfoWasRead (pp_error=%"
- NACL_PRId32 ")\n", pp_error));
- if (pp_error != PP_OK) {
+ if (!resources_->ReadResourceInfo()) {
ExitWithError();
return;
}
+
// Second step of loading resources: call StartLoad to load pnacl-llc
// and pnacl-ld, based on the filenames found in the resource info file.
- pp::CompletionCallback resources_cb =
- callback_factory_.NewCallback(&PnaclCoordinator::ResourcesDidLoad);
- resources_->StartLoad(resources_cb);
-}
-
-void PnaclCoordinator::ResourcesDidLoad(int32_t pp_error) {
- PLUGIN_PRINTF(("PnaclCoordinator::ResourcesDidLoad (pp_error=%"
- NACL_PRId32 ")\n", pp_error));
- if (pp_error != PP_OK) {
+ if (!resources_->StartLoad()) {
ReportNonPpapiError(
PP_NACL_ERROR_PNACL_RESOURCE_FETCH,
nacl::string("The Portable Native Client (pnacl) component is not "
diff --git a/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h b/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h
index d1ab90e..a135177 100644
--- a/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h
+++ b/ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h
@@ -108,11 +108,6 @@ class PnaclCoordinator: public CallbackSource<FileStreamData> {
// caching metadata.
void BitcodeStreamDidOpen(int32_t pp_error);
- // Callback for when the resource info JSON file has been read.
- void ResourceInfoWasRead(int32_t pp_error);
-
- // Callback for when llc and ld have been downloaded.
- void ResourcesDidLoad(int32_t pp_error);
// Invoked when we've gotten a temp FD for the nexe, either with the nexe
// data, or a writeable fd to save to.
void NexeFdDidOpen(int32_t pp_error);
diff --git a/ppapi/native_client/src/trusted/plugin/pnacl_resources.cc b/ppapi/native_client/src/trusted/plugin/pnacl_resources.cc
index 0e1a069..8b5f4cf 100644
--- a/ppapi/native_client/src/trusted/plugin/pnacl_resources.cc
+++ b/ppapi/native_client/src/trusted/plugin/pnacl_resources.cc
@@ -31,8 +31,7 @@ PnaclResources::~PnaclResources() {
CloseFileHandle(ld_file_handle_);
}
-void PnaclResources::ReadResourceInfo(
- const pp::CompletionCallback& resource_info_read_cb) {
+bool PnaclResources::ReadResourceInfo() {
PP_Var pp_llc_tool_name_var;
PP_Var pp_ld_tool_name_var;
if (!plugin_->nacl_interface()->GetPnaclResourceInfo(
@@ -40,16 +39,13 @@ void PnaclResources::ReadResourceInfo(
"chrome://pnacl-translator/pnacl.json",
&pp_llc_tool_name_var,
&pp_ld_tool_name_var)) {
- pp::Module::Get()->core()->CallOnMainThread(0,
- resource_info_read_cb,
- PP_ERROR_FAILED);
- return;
+ return false;
}
pp::Var llc_tool_name(pp::PASS_REF, pp_llc_tool_name_var);
pp::Var ld_tool_name(pp::PASS_REF, pp_ld_tool_name_var);
llc_tool_name_ = GetFullUrl(llc_tool_name.AsString());
ld_tool_name_ = GetFullUrl(ld_tool_name.AsString());
- pp::Module::Get()->core()->CallOnMainThread(0, resource_info_read_cb, PP_OK);
+ return true;
}
PP_FileHandle PnaclResources::TakeLlcFileHandle() {
@@ -64,8 +60,7 @@ PP_FileHandle PnaclResources::TakeLdFileHandle() {
return to_return;
}
-void PnaclResources::StartLoad(
- const pp::CompletionCallback& all_loaded_callback) {
+bool PnaclResources::StartLoad() {
PLUGIN_PRINTF(("PnaclResources::StartLoad\n"));
// Do a blocking load of each of the resources.
@@ -73,13 +68,8 @@ void PnaclResources::StartLoad(
plugin_->nacl_interface()->GetReadonlyPnaclFd(llc_tool_name_.c_str());
ld_file_handle_ =
plugin_->nacl_interface()->GetReadonlyPnaclFd(ld_tool_name_.c_str());
-
- int32_t result = PP_OK;
- if (llc_file_handle_ == PP_kInvalidFileHandle ||
- ld_file_handle_ == PP_kInvalidFileHandle) {
- result = PP_ERROR_FILENOTFOUND;
- }
- pp::Module::Get()->core()->CallOnMainThread(0, all_loaded_callback, result);
+ return (llc_file_handle_ != PP_kInvalidFileHandle &&
+ ld_file_handle_ != PP_kInvalidFileHandle);
}
} // namespace plugin
diff --git a/ppapi/native_client/src/trusted/plugin/pnacl_resources.h b/ppapi/native_client/src/trusted/plugin/pnacl_resources.h
index cca3b54..dcc521e 100644
--- a/ppapi/native_client/src/trusted/plugin/pnacl_resources.h
+++ b/ppapi/native_client/src/trusted/plugin/pnacl_resources.h
@@ -35,12 +35,10 @@ class PnaclResources {
// Read the resource info JSON file. This is the first step after
// construction; it has to be completed before StartLoad is called.
- virtual void ReadResourceInfo(
- const pp::CompletionCallback& resource_info_read_cb);
+ bool ReadResourceInfo();
// Start loading the resources.
- virtual void StartLoad(
- const pp::CompletionCallback& all_loaded_callback);
+ bool StartLoad();
const nacl::string& GetLlcUrl() { return llc_tool_name_; }
const nacl::string& GetLdUrl() { return ld_tool_name_; }