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/file_io_resource.h" | 5 #include "ppapi/proxy/file_io_resource.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/task_runner_util.h" | 8 #include "base/task_runner_util.h" |
9 #include "ipc/ipc_message.h" | 9 #include "ipc/ipc_message.h" |
10 #include "ppapi/c/pp_errors.h" | 10 #include "ppapi/c/pp_errors.h" |
11 #include "ppapi/proxy/ppapi_messages.h" | 11 #include "ppapi/proxy/ppapi_messages.h" |
12 #include "ppapi/shared_impl/array_writer.h" | 12 #include "ppapi/shared_impl/array_writer.h" |
| 13 #include "ppapi/shared_impl/file_system_util.h" |
13 #include "ppapi/shared_impl/file_type_conversion.h" | 14 #include "ppapi/shared_impl/file_type_conversion.h" |
14 #include "ppapi/shared_impl/ppapi_globals.h" | 15 #include "ppapi/shared_impl/ppapi_globals.h" |
15 #include "ppapi/shared_impl/proxy_lock.h" | 16 #include "ppapi/shared_impl/proxy_lock.h" |
16 #include "ppapi/shared_impl/resource_tracker.h" | 17 #include "ppapi/shared_impl/resource_tracker.h" |
17 #include "ppapi/thunk/enter.h" | 18 #include "ppapi/thunk/enter.h" |
18 #include "ppapi/thunk/ppb_file_ref_api.h" | 19 #include "ppapi/thunk/ppb_file_ref_api.h" |
19 | 20 |
20 using ppapi::thunk::EnterResourceNoLock; | 21 using ppapi::thunk::EnterResourceNoLock; |
21 using ppapi::thunk::PPB_FileIO_API; | 22 using ppapi::thunk::PPB_FileIO_API; |
22 using ppapi::thunk::PPB_FileRef_API; | 23 using ppapi::thunk::PPB_FileRef_API; |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 91 |
91 int32_t FileIOResource::Open(PP_Resource file_ref, | 92 int32_t FileIOResource::Open(PP_Resource file_ref, |
92 int32_t open_flags, | 93 int32_t open_flags, |
93 scoped_refptr<TrackedCallback> callback) { | 94 scoped_refptr<TrackedCallback> callback) { |
94 EnterResourceNoLock<PPB_FileRef_API> enter(file_ref, true); | 95 EnterResourceNoLock<PPB_FileRef_API> enter(file_ref, true); |
95 if (enter.failed()) | 96 if (enter.failed()) |
96 return PP_ERROR_BADRESOURCE; | 97 return PP_ERROR_BADRESOURCE; |
97 | 98 |
98 PPB_FileRef_API* file_ref_api = enter.object(); | 99 PPB_FileRef_API* file_ref_api = enter.object(); |
99 PP_FileSystemType type = file_ref_api->GetFileSystemType(); | 100 PP_FileSystemType type = file_ref_api->GetFileSystemType(); |
100 if (type != PP_FILESYSTEMTYPE_LOCALPERSISTENT && | 101 if (!FileSystemTypeIsValid(type)) { |
101 type != PP_FILESYSTEMTYPE_LOCALTEMPORARY && | |
102 type != PP_FILESYSTEMTYPE_EXTERNAL && | |
103 type != PP_FILESYSTEMTYPE_ISOLATED) { | |
104 NOTREACHED(); | 102 NOTREACHED(); |
105 return PP_ERROR_FAILED; | 103 return PP_ERROR_FAILED; |
106 } | 104 } |
107 file_system_type_ = type; | 105 file_system_type_ = type; |
108 | 106 |
109 int32_t rv = state_manager_.CheckOperationState( | 107 int32_t rv = state_manager_.CheckOperationState( |
110 FileIOStateManager::OPERATION_EXCLUSIVE, false); | 108 FileIOStateManager::OPERATION_EXCLUSIVE, false); |
111 if (rv != PP_OK) | 109 if (rv != PP_OK) |
112 return rv; | 110 return rv; |
113 | 111 |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 *output_handle = IPC::PlatformFileForTransitToPlatformFile(transit_file); | 450 *output_handle = IPC::PlatformFileForTransitToPlatformFile(transit_file); |
453 | 451 |
454 // End this operation now, so the user's callback can execute another FileIO | 452 // End this operation now, so the user's callback can execute another FileIO |
455 // operation, assuming there are no other pending operations. | 453 // operation, assuming there are no other pending operations. |
456 state_manager_.SetOperationFinished(); | 454 state_manager_.SetOperationFinished(); |
457 callback->Run(result); | 455 callback->Run(result); |
458 } | 456 } |
459 | 457 |
460 } // namespace proxy | 458 } // namespace proxy |
461 } // namespace ppapi | 459 } // namespace ppapi |
OLD | NEW |