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

Side by Side Diff: trunk/src/components/nacl/renderer/ppb_nacl_private_impl.cc

Issue 279323002: Revert 269791 "Pepper: Fix crash on allocation failure." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 7 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 | « no previous file | 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "components/nacl/renderer/ppb_nacl_private_impl.h" 5 #include "components/nacl/renderer/ppb_nacl_private_impl.h"
6 6
7 #include <numeric> 7 #include <numeric>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 1096 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 base::PlatformFile file = GetReadonlyPnaclFD(filename); 1107 base::PlatformFile file = GetReadonlyPnaclFD(filename);
1108 if (file == base::kInvalidPlatformFileValue) { 1108 if (file == base::kInvalidPlatformFileValue) {
1109 load_manager->ReportLoadError( 1109 load_manager->ReportLoadError(
1110 PP_NACL_ERROR_PNACL_RESOURCE_FETCH, 1110 PP_NACL_ERROR_PNACL_RESOURCE_FETCH,
1111 "The Portable Native Client (pnacl) component is not " 1111 "The Portable Native Client (pnacl) component is not "
1112 "installed. Please consult chrome://components for more " 1112 "installed. Please consult chrome://components for more "
1113 "information."); 1113 "information.");
1114 return PP_FALSE; 1114 return PP_FALSE;
1115 } 1115 }
1116 1116
1117 base::PlatformFileInfo file_info; 1117 const int kBufferSize = 1 << 20;
1118 if (!GetPlatformFileInfo(file, &file_info)) { 1118 scoped_ptr<char[]> buffer(new char[kBufferSize]);
1119 if (base::ReadPlatformFile(file, 0, buffer.get(), kBufferSize) < 0) {
1119 load_manager->ReportLoadError( 1120 load_manager->ReportLoadError(
1120 PP_NACL_ERROR_PNACL_RESOURCE_FETCH, 1121 PP_NACL_ERROR_PNACL_RESOURCE_FETCH,
1121 std::string("GetPNaClResourceInfo, GetFileInfo failed for: ") + 1122 std::string("PnaclResources::ReadResourceInfo reading failed for: ") +
1122 filename); 1123 filename);
1123 return PP_FALSE; 1124 return PP_FALSE;
1124 } 1125 }
1125 1126
1126 if (file_info.size > 1 << 20) {
1127 load_manager->ReportLoadError(
1128 PP_NACL_ERROR_PNACL_RESOURCE_FETCH,
1129 std::string("GetPNaClResourceInfo, file too large: ") + filename);
1130 return PP_FALSE;
1131 }
1132
1133 scoped_ptr<char[]> buffer(new char[file_info.size]);
1134 if (buffer.get() == NULL) {
1135 load_manager->ReportLoadError(
1136 PP_NACL_ERROR_PNACL_RESOURCE_FETCH,
1137 std::string("GetPNaClResourceInfo, couldn't allocate for: ") +
1138 filename);
1139 return PP_FALSE;
1140 }
1141
1142 if (base::ReadPlatformFile(file, 0, buffer.get(), file_info.size) < 0) {
1143 load_manager->ReportLoadError(
1144 PP_NACL_ERROR_PNACL_RESOURCE_FETCH,
1145 std::string("GetPNaClResourceInfo, reading failed for: ") + filename);
1146 return PP_FALSE;
1147 }
1148
1149 // Expect the JSON file to contain a top-level object (dictionary). 1127 // Expect the JSON file to contain a top-level object (dictionary).
1150 Json::Reader json_reader; 1128 Json::Reader json_reader;
1151 Json::Value json_data; 1129 Json::Value json_data;
1152 if (!json_reader.parse(buffer.get(), json_data)) { 1130 if (!json_reader.parse(buffer.get(), json_data)) {
1153 load_manager->ReportLoadError( 1131 load_manager->ReportLoadError(
1154 PP_NACL_ERROR_PNACL_RESOURCE_FETCH, 1132 PP_NACL_ERROR_PNACL_RESOURCE_FETCH,
1155 std::string("Parsing resource info failed: JSON parse error: ") + 1133 std::string("Parsing resource info failed: JSON parse error: ") +
1156 json_reader.getFormattedErrorMessages()); 1134 json_reader.getFormattedErrorMessages());
1157 return PP_FALSE; 1135 return PP_FALSE;
1158 } 1136 }
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 &PostMessageToJavaScript 1279 &PostMessageToJavaScript
1302 }; 1280 };
1303 1281
1304 } // namespace 1282 } // namespace
1305 1283
1306 const PPB_NaCl_Private* GetNaClPrivateInterface() { 1284 const PPB_NaCl_Private* GetNaClPrivateInterface() {
1307 return &nacl_interface; 1285 return &nacl_interface;
1308 } 1286 }
1309 1287
1310 } // namespace nacl 1288 } // namespace nacl
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698