OLD | NEW |
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/tests/test_file_io.h" | 5 #include "ppapi/tests/test_file_io.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1134 if (rv == PP_OK_COMPLETIONPENDING) | 1134 if (rv == PP_OK_COMPLETIONPENDING) |
1135 rv = callback.WaitForResult(); | 1135 rv = callback.WaitForResult(); |
1136 if (rv != PP_OK) | 1136 if (rv != PP_OK) |
1137 return ReportError("FileIO::Open", rv); | 1137 return ReportError("FileIO::Open", rv); |
1138 | 1138 |
1139 const PPB_FileIOTrusted* trusted = static_cast<const PPB_FileIOTrusted*>( | 1139 const PPB_FileIOTrusted* trusted = static_cast<const PPB_FileIOTrusted*>( |
1140 pp::Module::Get()->GetBrowserInterface(PPB_FILEIOTRUSTED_INTERFACE)); | 1140 pp::Module::Get()->GetBrowserInterface(PPB_FILEIOTRUSTED_INTERFACE)); |
1141 if (!trusted) | 1141 if (!trusted) |
1142 return ReportError("FileIOTrusted", PP_ERROR_FAILED); | 1142 return ReportError("FileIOTrusted", PP_ERROR_FAILED); |
1143 | 1143 |
1144 // Get file descriptor. This is only supported in-process for now, so don't | |
1145 // test out of process. | |
1146 const PPB_Testing_Dev* testing_interface = GetTestingInterface(); | |
1147 if (testing_interface && !testing_interface->IsOutOfProcess()) { | |
1148 int32_t fd = trusted->GetOSFileDescriptor(file_io.pp_resource()); | |
1149 if (fd < 0) | |
1150 return "FileIO::GetOSFileDescriptor() returned a bad file descriptor."; | |
1151 } | |
1152 | |
1153 // Calling WillWrite. | 1144 // Calling WillWrite. |
1154 rv = trusted->WillWrite( | 1145 rv = trusted->WillWrite( |
1155 file_io.pp_resource(), 0, 9, | 1146 file_io.pp_resource(), 0, 9, |
1156 static_cast<pp::CompletionCallback>(callback).pp_completion_callback()); | 1147 static_cast<pp::CompletionCallback>(callback).pp_completion_callback()); |
1157 if (rv == PP_OK_COMPLETIONPENDING) | 1148 if (rv == PP_OK_COMPLETIONPENDING) |
1158 rv = callback.WaitForResult(); | 1149 rv = callback.WaitForResult(); |
1159 if (rv != 9) | 1150 if (rv != 9) |
1160 return ReportError("WillWrite", rv); | 1151 return ReportError("WillWrite", rv); |
1161 | 1152 |
1162 // Writing the actual data. | 1153 // Writing the actual data. |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1295 rv = callback.WaitForResult(); | 1286 rv = callback.WaitForResult(); |
1296 if ((invalid_combination && rv == PP_OK) || | 1287 if ((invalid_combination && rv == PP_OK) || |
1297 (!invalid_combination && ((rv == PP_OK) != create_if_doesnt_exist))) { | 1288 (!invalid_combination && ((rv == PP_OK) != create_if_doesnt_exist))) { |
1298 return ReportOpenError(open_flags); | 1289 return ReportOpenError(open_flags); |
1299 } | 1290 } |
1300 | 1291 |
1301 return std::string(); | 1292 return std::string(); |
1302 } | 1293 } |
1303 | 1294 |
1304 // TODO(viettrungluu): Test Close(). crbug.com/69457 | 1295 // TODO(viettrungluu): Test Close(). crbug.com/69457 |
OLD | NEW |