| 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/proxy/flash_file_resource.h" | 5 #include "ppapi/proxy/flash_file_resource.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "ipc/ipc_message.h" | 8 #include "ipc/ipc_message.h" |
| 9 #include "ppapi/c/pp_errors.h" | 9 #include "ppapi/c/pp_errors.h" |
| 10 #include "ppapi/proxy/ppapi_messages.h" | 10 #include "ppapi/proxy/ppapi_messages.h" |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 PP_Resource file_ref, | 169 PP_Resource file_ref, |
| 170 PP_FileInfo* info) { | 170 PP_FileInfo* info) { |
| 171 return QueryFileHelper(GetPathFromFileRef(file_ref), | 171 return QueryFileHelper(GetPathFromFileRef(file_ref), |
| 172 PepperFilePath::DOMAIN_ABSOLUTE, info); | 172 PepperFilePath::DOMAIN_ABSOLUTE, info); |
| 173 } | 173 } |
| 174 | 174 |
| 175 int32_t FlashFileResource::OpenFileHelper(const std::string& path, | 175 int32_t FlashFileResource::OpenFileHelper(const std::string& path, |
| 176 PepperFilePath::Domain domain_type, | 176 PepperFilePath::Domain domain_type, |
| 177 int32_t mode, | 177 int32_t mode, |
| 178 PP_FileHandle* file) { | 178 PP_FileHandle* file) { |
| 179 int flags = 0; | |
| 180 if (path.empty() || | 179 if (path.empty() || |
| 181 !ppapi::PepperFileOpenFlagsToPlatformFileFlags(mode, &flags) || | 180 !ppapi::PepperFileOpenFlagsToPlatformFileFlags(mode, NULL) || |
| 182 !file) | 181 !file) |
| 183 return PP_ERROR_BADARGUMENT; | 182 return PP_ERROR_BADARGUMENT; |
| 184 | 183 |
| 185 PepperFilePath pepper_path(domain_type, base::FilePath::FromUTF8Unsafe(path)); | 184 PepperFilePath pepper_path(domain_type, base::FilePath::FromUTF8Unsafe(path)); |
| 186 | 185 |
| 187 IPC::Message unused; | 186 IPC::Message unused; |
| 188 ResourceMessageReplyParams reply_params; | 187 ResourceMessageReplyParams reply_params; |
| 189 int32_t error = GenericSyncCall(BROWSER, | 188 int32_t error = GenericSyncCall(BROWSER, |
| 190 PpapiHostMsg_FlashFile_OpenFile(pepper_path, flags), &unused, | 189 PpapiHostMsg_FlashFile_OpenFile(pepper_path, mode), &unused, |
| 191 &reply_params); | 190 &reply_params); |
| 192 if (error != PP_OK) | 191 if (error != PP_OK) |
| 193 return error; | 192 return error; |
| 194 | 193 |
| 195 IPC::PlatformFileForTransit transit_file; | 194 IPC::PlatformFileForTransit transit_file; |
| 196 if (!reply_params.TakeFileHandleAtIndex(0, &transit_file)) | 195 if (!reply_params.TakeFileHandleAtIndex(0, &transit_file)) |
| 197 return PP_ERROR_FAILED; | 196 return PP_ERROR_FAILED; |
| 198 | 197 |
| 199 *file = IPC::PlatformFileForTransitToPlatformFile(transit_file); | 198 *file = IPC::PlatformFileForTransitToPlatformFile(transit_file); |
| 200 return PP_OK; | 199 return PP_OK; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 222 info->type = PP_FILETYPE_DIRECTORY; | 221 info->type = PP_FILETYPE_DIRECTORY; |
| 223 else | 222 else |
| 224 info->type = PP_FILETYPE_REGULAR; | 223 info->type = PP_FILETYPE_REGULAR; |
| 225 } | 224 } |
| 226 | 225 |
| 227 return error; | 226 return error; |
| 228 } | 227 } |
| 229 | 228 |
| 230 } // namespace proxy | 229 } // namespace proxy |
| 231 } // namespace ppapi | 230 } // namespace ppapi |
| OLD | NEW |