OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/dev/ppb_directory_reader_dev.h" | 5 #include "ppapi/c/dev/ppb_directory_reader_dev.h" |
6 #include "ppapi/c/pp_completion_callback.h" | 6 #include "ppapi/c/pp_completion_callback.h" |
7 #include "ppapi/c/pp_errors.h" | 7 #include "ppapi/c/pp_errors.h" |
| 8 #include "ppapi/thunk/common.h" |
| 9 #include "ppapi/thunk/enter.h" |
8 #include "ppapi/thunk/thunk.h" | 10 #include "ppapi/thunk/thunk.h" |
9 #include "ppapi/thunk/enter.h" | |
10 #include "ppapi/thunk/ppb_directory_reader_api.h" | 11 #include "ppapi/thunk/ppb_directory_reader_api.h" |
11 #include "ppapi/thunk/resource_creation_api.h" | 12 #include "ppapi/thunk/resource_creation_api.h" |
12 | 13 |
13 namespace ppapi { | 14 namespace ppapi { |
14 namespace thunk { | 15 namespace thunk { |
15 | 16 |
16 namespace { | 17 namespace { |
17 | 18 |
18 PP_Resource Create(PP_Resource directory_ref) { | 19 PP_Resource Create(PP_Resource directory_ref) { |
19 EnterFunctionGivenResource<ResourceCreationAPI> enter(directory_ref, true); | 20 EnterFunctionGivenResource<ResourceCreationAPI> enter(directory_ref, true); |
20 if (enter.failed()) | 21 if (enter.failed()) |
21 return 0; | 22 return 0; |
22 return enter.functions()->CreateDirectoryReader(directory_ref); | 23 return enter.functions()->CreateDirectoryReader(directory_ref); |
23 } | 24 } |
24 | 25 |
25 PP_Bool IsDirectoryReader(PP_Resource resource) { | 26 PP_Bool IsDirectoryReader(PP_Resource resource) { |
26 EnterResource<PPB_DirectoryReader_API> enter(resource, false); | 27 EnterResource<PPB_DirectoryReader_API> enter(resource, false); |
27 return PP_FromBool(enter.succeeded()); | 28 return PP_FromBool(enter.succeeded()); |
28 } | 29 } |
29 | 30 |
30 int32_t GetNextEntry(PP_Resource directory_reader, | 31 int32_t GetNextEntry(PP_Resource directory_reader, |
31 PP_DirectoryEntry_Dev* entry, | 32 PP_DirectoryEntry_Dev* entry, |
32 PP_CompletionCallback callback) { | 33 PP_CompletionCallback callback) { |
33 EnterResource<PPB_DirectoryReader_API> enter(directory_reader, true); | 34 EnterResource<PPB_DirectoryReader_API> enter(directory_reader, true); |
34 if (enter.failed()) | 35 if (enter.failed()) |
35 return PP_ERROR_BADRESOURCE; | 36 return MayForceCallback(callback, PP_ERROR_BADRESOURCE); |
36 return enter.object()->GetNextEntry(entry, callback); | 37 int32_t result = enter.object()->GetNextEntry(entry, callback); |
| 38 return MayForceCallback(callback, result); |
37 } | 39 } |
38 | 40 |
39 const PPB_DirectoryReader_Dev g_ppb_directory_reader_thunk = { | 41 const PPB_DirectoryReader_Dev g_ppb_directory_reader_thunk = { |
40 &Create, | 42 &Create, |
41 &IsDirectoryReader, | 43 &IsDirectoryReader, |
42 &GetNextEntry | 44 &GetNextEntry |
43 }; | 45 }; |
44 | 46 |
45 } // namespace | 47 } // namespace |
46 | 48 |
47 const PPB_DirectoryReader_Dev* GetPPB_DirectoryReader_Thunk() { | 49 const PPB_DirectoryReader_Dev* GetPPB_DirectoryReader_Thunk() { |
48 return &g_ppb_directory_reader_thunk; | 50 return &g_ppb_directory_reader_thunk; |
49 } | 51 } |
50 | 52 |
51 } // namespace thunk | 53 } // namespace thunk |
52 } // namespace ppapi | 54 } // namespace ppapi |
OLD | NEW |