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

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

Issue 315583005: Pepper: Simplify error reporting in PnaclResources. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 6 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
« no previous file with comments | « ppapi/native_client/src/trusted/plugin/pnacl_resources.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_resources.h" 5 #include "ppapi/native_client/src/trusted/plugin/pnacl_resources.h"
6 6
7 #include "native_client/src/include/portability_io.h" 7 #include "native_client/src/include/portability_io.h"
8 #include "native_client/src/shared/platform/nacl_check.h" 8 #include "native_client/src/shared/platform/nacl_check.h"
9 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h" 9 #include "native_client/src/trusted/desc/nacl_desc_wrapper.h"
10 #include "ppapi/c/pp_errors.h" 10 #include "ppapi/c/pp_errors.h"
11 #include "ppapi/native_client/src/trusted/plugin/plugin.h" 11 #include "ppapi/native_client/src/trusted/plugin/plugin.h"
12 #include "ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h"
13 #include "ppapi/native_client/src/trusted/plugin/utility.h" 12 #include "ppapi/native_client/src/trusted/plugin/utility.h"
14 13
15 namespace plugin { 14 namespace plugin {
16 15
17 namespace { 16 namespace {
18 17
19 static const char kPnaclBaseUrl[] = "chrome://pnacl-translator/"; 18 static const char kPnaclBaseUrl[] = "chrome://pnacl-translator/";
20 19
21 nacl::string GetFullUrl(const nacl::string& partial_url) { 20 nacl::string GetFullUrl(const nacl::string& partial_url) {
22 return nacl::string(kPnaclBaseUrl) + GetNaClInterface()->GetSandboxArch() + 21 return nacl::string(kPnaclBaseUrl) + GetNaClInterface()->GetSandboxArch() +
(...skipping 11 matching lines...) Expand all
34 33
35 void PnaclResources::ReadResourceInfo( 34 void PnaclResources::ReadResourceInfo(
36 const pp::CompletionCallback& resource_info_read_cb) { 35 const pp::CompletionCallback& resource_info_read_cb) {
37 PP_Var pp_llc_tool_name_var; 36 PP_Var pp_llc_tool_name_var;
38 PP_Var pp_ld_tool_name_var; 37 PP_Var pp_ld_tool_name_var;
39 if (!plugin_->nacl_interface()->GetPnaclResourceInfo( 38 if (!plugin_->nacl_interface()->GetPnaclResourceInfo(
40 plugin_->pp_instance(), 39 plugin_->pp_instance(),
41 "chrome://pnacl-translator/pnacl.json", 40 "chrome://pnacl-translator/pnacl.json",
42 &pp_llc_tool_name_var, 41 &pp_llc_tool_name_var,
43 &pp_ld_tool_name_var)) { 42 &pp_ld_tool_name_var)) {
44 coordinator_->ExitWithError(); 43 pp::Module::Get()->core()->CallOnMainThread(0,
44 resource_info_read_cb,
45 PP_ERROR_FAILED);
46 return;
45 } 47 }
46
47 pp::Var llc_tool_name(pp::PASS_REF, pp_llc_tool_name_var); 48 pp::Var llc_tool_name(pp::PASS_REF, pp_llc_tool_name_var);
48 pp::Var ld_tool_name(pp::PASS_REF, pp_ld_tool_name_var); 49 pp::Var ld_tool_name(pp::PASS_REF, pp_ld_tool_name_var);
49 llc_tool_name_ = GetFullUrl(llc_tool_name.AsString()); 50 llc_tool_name_ = GetFullUrl(llc_tool_name.AsString());
50 ld_tool_name_ = GetFullUrl(ld_tool_name.AsString()); 51 ld_tool_name_ = GetFullUrl(ld_tool_name.AsString());
51 pp::Module::Get()->core()->CallOnMainThread(0, resource_info_read_cb, PP_OK); 52 pp::Module::Get()->core()->CallOnMainThread(0, resource_info_read_cb, PP_OK);
52 } 53 }
53 54
54 PP_FileHandle PnaclResources::TakeLlcFileHandle() { 55 PP_FileHandle PnaclResources::TakeLlcFileHandle() {
55 PP_FileHandle to_return = llc_file_handle_; 56 PP_FileHandle to_return = llc_file_handle_;
56 llc_file_handle_ = PP_kInvalidFileHandle; 57 llc_file_handle_ = PP_kInvalidFileHandle;
(...skipping 12 matching lines...) Expand all
69 70
70 // Do a blocking load of each of the resources. 71 // Do a blocking load of each of the resources.
71 llc_file_handle_ = 72 llc_file_handle_ =
72 plugin_->nacl_interface()->GetReadonlyPnaclFd(llc_tool_name_.c_str()); 73 plugin_->nacl_interface()->GetReadonlyPnaclFd(llc_tool_name_.c_str());
73 ld_file_handle_ = 74 ld_file_handle_ =
74 plugin_->nacl_interface()->GetReadonlyPnaclFd(ld_tool_name_.c_str()); 75 plugin_->nacl_interface()->GetReadonlyPnaclFd(ld_tool_name_.c_str());
75 76
76 int32_t result = PP_OK; 77 int32_t result = PP_OK;
77 if (llc_file_handle_ == PP_kInvalidFileHandle || 78 if (llc_file_handle_ == PP_kInvalidFileHandle ||
78 ld_file_handle_ == PP_kInvalidFileHandle) { 79 ld_file_handle_ == PP_kInvalidFileHandle) {
79 // File-open failed. Assume this means that the file is
80 // not actually installed. This shouldn't actually occur since
81 // ReadResourceInfo() fail first.
82 coordinator_->ReportNonPpapiError(
83 PP_NACL_ERROR_PNACL_RESOURCE_FETCH,
84 nacl::string("The Portable Native Client (pnacl) component is not "
85 "installed. Please consult chrome://components for more "
86 "information."));
87 result = PP_ERROR_FILENOTFOUND; 80 result = PP_ERROR_FILENOTFOUND;
88 } 81 }
89 pp::Module::Get()->core()->CallOnMainThread(0, all_loaded_callback, result); 82 pp::Module::Get()->core()->CallOnMainThread(0, all_loaded_callback, result);
90 } 83 }
91 84
92 } // namespace plugin 85 } // namespace plugin
OLDNEW
« no previous file with comments | « ppapi/native_client/src/trusted/plugin/pnacl_resources.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698