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

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: 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
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" 12 #include "ppapi/native_client/src/trusted/plugin/pnacl_coordinator.h"
dmichael (off chromium) 2014/06/03 19:52:51 nit: don't need this anymore
13 #include "ppapi/native_client/src/trusted/plugin/utility.h" 13 #include "ppapi/native_client/src/trusted/plugin/utility.h"
14 14
15 namespace plugin { 15 namespace plugin {
16 16
17 namespace { 17 namespace {
18 18
19 static const char kPnaclBaseUrl[] = "chrome://pnacl-translator/"; 19 static const char kPnaclBaseUrl[] = "chrome://pnacl-translator/";
20 20
21 nacl::string GetFullUrl(const nacl::string& partial_url) { 21 nacl::string GetFullUrl(const nacl::string& partial_url) {
22 return nacl::string(kPnaclBaseUrl) + GetNaClInterface()->GetSandboxArch() + 22 return nacl::string(kPnaclBaseUrl) + GetNaClInterface()->GetSandboxArch() +
(...skipping 11 matching lines...) Expand all
34 34
35 void PnaclResources::ReadResourceInfo( 35 void PnaclResources::ReadResourceInfo(
36 const pp::CompletionCallback& resource_info_read_cb) { 36 const pp::CompletionCallback& resource_info_read_cb) {
37 PP_Var pp_llc_tool_name_var; 37 PP_Var pp_llc_tool_name_var;
38 PP_Var pp_ld_tool_name_var; 38 PP_Var pp_ld_tool_name_var;
39 if (!plugin_->nacl_interface()->GetPnaclResourceInfo( 39 if (!plugin_->nacl_interface()->GetPnaclResourceInfo(
40 plugin_->pp_instance(), 40 plugin_->pp_instance(),
41 "chrome://pnacl-translator/pnacl.json", 41 "chrome://pnacl-translator/pnacl.json",
42 &pp_llc_tool_name_var, 42 &pp_llc_tool_name_var,
43 &pp_ld_tool_name_var)) { 43 &pp_ld_tool_name_var)) {
44 coordinator_->ExitWithError(); 44 pp::Module::Get()->core()->CallOnMainThread(0,
45 resource_info_read_cb,
46 PP_ERROR_FAILED);
47 return;
45 } 48 }
46
47 pp::Var llc_tool_name(pp::PASS_REF, pp_llc_tool_name_var); 49 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); 50 pp::Var ld_tool_name(pp::PASS_REF, pp_ld_tool_name_var);
49 llc_tool_name_ = GetFullUrl(llc_tool_name.AsString()); 51 llc_tool_name_ = GetFullUrl(llc_tool_name.AsString());
50 ld_tool_name_ = GetFullUrl(ld_tool_name.AsString()); 52 ld_tool_name_ = GetFullUrl(ld_tool_name.AsString());
51 pp::Module::Get()->core()->CallOnMainThread(0, resource_info_read_cb, PP_OK); 53 pp::Module::Get()->core()->CallOnMainThread(0, resource_info_read_cb, PP_OK);
52 } 54 }
53 55
54 PP_FileHandle PnaclResources::TakeLlcFileHandle() { 56 PP_FileHandle PnaclResources::TakeLlcFileHandle() {
55 PP_FileHandle to_return = llc_file_handle_; 57 PP_FileHandle to_return = llc_file_handle_;
56 llc_file_handle_ = PP_kInvalidFileHandle; 58 llc_file_handle_ = PP_kInvalidFileHandle;
(...skipping 12 matching lines...) Expand all
69 71
70 // Do a blocking load of each of the resources. 72 // Do a blocking load of each of the resources.
71 llc_file_handle_ = 73 llc_file_handle_ =
72 plugin_->nacl_interface()->GetReadonlyPnaclFd(llc_tool_name_.c_str()); 74 plugin_->nacl_interface()->GetReadonlyPnaclFd(llc_tool_name_.c_str());
73 ld_file_handle_ = 75 ld_file_handle_ =
74 plugin_->nacl_interface()->GetReadonlyPnaclFd(ld_tool_name_.c_str()); 76 plugin_->nacl_interface()->GetReadonlyPnaclFd(ld_tool_name_.c_str());
75 77
76 int32_t result = PP_OK; 78 int32_t result = PP_OK;
77 if (llc_file_handle_ == PP_kInvalidFileHandle || 79 if (llc_file_handle_ == PP_kInvalidFileHandle ||
78 ld_file_handle_ == PP_kInvalidFileHandle) { 80 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; 81 result = PP_ERROR_FILENOTFOUND;
88 } 82 }
89 pp::Module::Get()->core()->CallOnMainThread(0, all_loaded_callback, result); 83 pp::Module::Get()->core()->CallOnMainThread(0, all_loaded_callback, result);
90 } 84 }
91 85
92 } // namespace plugin 86 } // namespace plugin
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698