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; | 179 if (path.empty() || !file) |
180 if (path.empty() || | |
181 !ppapi::PepperFileOpenFlagsToPlatformFileFlags(mode, &flags) || | |
182 !file) | |
183 return PP_ERROR_BADARGUMENT; | 180 return PP_ERROR_BADARGUMENT; |
184 | 181 |
185 PepperFilePath pepper_path(domain_type, base::FilePath::FromUTF8Unsafe(path)); | 182 PepperFilePath pepper_path(domain_type, base::FilePath::FromUTF8Unsafe(path)); |
186 | 183 |
187 IPC::Message unused; | 184 IPC::Message unused; |
188 ResourceMessageReplyParams reply_params; | 185 ResourceMessageReplyParams reply_params; |
189 int32_t error = GenericSyncCall(BROWSER, | 186 int32_t error = GenericSyncCall(BROWSER, |
190 PpapiHostMsg_FlashFile_OpenFile(pepper_path, flags), &unused, | 187 PpapiHostMsg_FlashFile_OpenFile(pepper_path, mode), &unused, |
191 &reply_params); | 188 &reply_params); |
192 if (error != PP_OK) | 189 if (error != PP_OK) |
193 return error; | 190 return error; |
194 | 191 |
195 IPC::PlatformFileForTransit transit_file; | 192 IPC::PlatformFileForTransit transit_file; |
196 if (!reply_params.TakeFileHandleAtIndex(0, &transit_file)) | 193 if (!reply_params.TakeFileHandleAtIndex(0, &transit_file)) |
197 return PP_ERROR_FAILED; | 194 return PP_ERROR_FAILED; |
198 | 195 |
199 *file = IPC::PlatformFileForTransitToPlatformFile(transit_file); | 196 *file = IPC::PlatformFileForTransitToPlatformFile(transit_file); |
200 return PP_OK; | 197 return PP_OK; |
(...skipping 21 matching lines...) Expand all Loading... |
222 info->type = PP_FILETYPE_DIRECTORY; | 219 info->type = PP_FILETYPE_DIRECTORY; |
223 else | 220 else |
224 info->type = PP_FILETYPE_REGULAR; | 221 info->type = PP_FILETYPE_REGULAR; |
225 } | 222 } |
226 | 223 |
227 return error; | 224 return error; |
228 } | 225 } |
229 | 226 |
230 } // namespace proxy | 227 } // namespace proxy |
231 } // namespace ppapi | 228 } // namespace ppapi |
OLD | NEW |