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/c/pp_file_info.h" | 5 #include "ppapi/c/pp_file_info.h" |
6 #include "ppapi/c/ppb_file_ref.h" | 6 #include "ppapi/c/ppb_file_ref.h" |
7 #include "ppapi/c/pp_completion_callback.h" | 7 #include "ppapi/c/pp_completion_callback.h" |
8 #include "ppapi/c/pp_errors.h" | 8 #include "ppapi/c/pp_errors.h" |
9 #include "ppapi/c/private/ppb_file_ref_private.h" | 9 #include "ppapi/c/private/ppb_file_ref_private.h" |
10 #include "ppapi/shared_impl/ppapi_globals.h" | |
10 #include "ppapi/shared_impl/proxy_lock.h" | 11 #include "ppapi/shared_impl/proxy_lock.h" |
11 #include "ppapi/shared_impl/tracked_callback.h" | 12 #include "ppapi/shared_impl/tracked_callback.h" |
12 #include "ppapi/thunk/enter.h" | 13 #include "ppapi/thunk/enter.h" |
13 #include "ppapi/thunk/thunk.h" | 14 #include "ppapi/thunk/thunk.h" |
14 #include "ppapi/thunk/ppb_file_ref_api.h" | 15 #include "ppapi/thunk/ppb_file_ref_api.h" |
15 #include "ppapi/thunk/ppb_file_system_api.h" | 16 #include "ppapi/thunk/ppb_file_system_api.h" |
16 #include "ppapi/thunk/resource_creation_api.h" | 17 #include "ppapi/thunk/resource_creation_api.h" |
17 | 18 |
18 namespace ppapi { | 19 namespace ppapi { |
19 namespace thunk { | 20 namespace thunk { |
20 | 21 |
21 namespace { | 22 namespace { |
22 | 23 |
23 typedef EnterResource<PPB_FileRef_API> EnterFileRef; | 24 typedef EnterResource<PPB_FileRef_API> EnterFileRef; |
24 | 25 |
25 PP_Resource Create(PP_Resource file_system, const char* path) { | 26 PP_Resource Create(PP_Resource file_system, const char* path) { |
26 ppapi::ProxyAutoLock lock; | 27 ppapi::ProxyAutoLock lock; |
28 | |
29 // Make sure the file_system is one of expected types. | |
palmer
2013/04/25 00:01:23
NIT: "...one of the..."
victorhsieh
2013/04/25 02:21:51
Done.
| |
27 EnterResourceNoLock<PPB_FileSystem_API> enter_file_system(file_system, true); | 30 EnterResourceNoLock<PPB_FileSystem_API> enter_file_system(file_system, true); |
28 if (enter_file_system.failed()) | 31 EnterResourceNoLock<PPB_Ext_CrxFileSystem_Private_API> enter_crxfs( |
32 file_system, true); | |
33 if (enter_file_system.failed() && enter_crxfs.failed()) | |
29 return 0; | 34 return 0; |
30 PP_Instance instance = enter_file_system.resource()->pp_instance(); | 35 |
36 // Since file_system is either type of filesystem above, we don't need to | |
37 // check null-ness below. | |
38 Resource* res = PpapiGlobals::Get()->GetResourceTracker()-> | |
39 GetResource(file_system); | |
40 PP_Instance instance = res->pp_instance(); | |
31 EnterResourceCreationNoLock enter(instance); | 41 EnterResourceCreationNoLock enter(instance); |
32 if (enter.failed()) | 42 if (enter.failed()) |
33 return 0; | 43 return 0; |
34 return enter.functions()->CreateFileRef(instance, file_system, path); | 44 return enter.functions()->CreateFileRef(instance, file_system, path); |
35 } | 45 } |
36 | 46 |
37 PP_Bool IsFileRef(PP_Resource resource) { | 47 PP_Bool IsFileRef(PP_Resource resource) { |
38 EnterFileRef enter(resource, false); | 48 EnterFileRef enter(resource, false); |
39 return PP_FromBool(enter.succeeded()); | 49 return PP_FromBool(enter.succeeded()); |
40 } | 50 } |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
163 const PPB_FileRef_1_1* GetPPB_FileRef_1_1_Thunk() { | 173 const PPB_FileRef_1_1* GetPPB_FileRef_1_1_Thunk() { |
164 return &g_ppb_file_ref_thunk_1_1; | 174 return &g_ppb_file_ref_thunk_1_1; |
165 } | 175 } |
166 | 176 |
167 const PPB_FileRefPrivate_0_1* GetPPB_FileRefPrivate_0_1_Thunk() { | 177 const PPB_FileRefPrivate_0_1* GetPPB_FileRefPrivate_0_1_Thunk() { |
168 return &g_ppb_file_ref_private_thunk; | 178 return &g_ppb_file_ref_private_thunk; |
169 } | 179 } |
170 | 180 |
171 } // namespace thunk | 181 } // namespace thunk |
172 } // namespace ppapi | 182 } // namespace ppapi |
OLD | NEW |