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_errors.h" | 5 #include "ppapi/c/pp_errors.h" |
6 #include "ppapi/c/private/ppb_flash_file.h" | 6 #include "ppapi/c/private/ppb_flash_file.h" |
7 #include "ppapi/thunk/enter.h" | 7 #include "ppapi/thunk/enter.h" |
8 #include "ppapi/thunk/ppb_flash_file_api.h" | 8 #include "ppapi/thunk/ppb_flash_api.h" |
| 9 #include "ppapi/thunk/ppb_instance_api.h" |
9 #include "ppapi/thunk/thunk.h" | 10 #include "ppapi/thunk/thunk.h" |
10 | 11 |
11 namespace ppapi { | 12 namespace ppapi { |
12 namespace thunk { | 13 namespace thunk { |
13 | 14 |
14 namespace { | 15 namespace { |
15 | 16 |
16 bool CreateThreadAdapterForInstance(PP_Instance instance) { | 17 bool CreateThreadAdapterForInstance(PP_Instance instance) { |
17 return true; | 18 EnterInstance enter(instance); |
| 19 if (enter.failed()) |
| 20 return false; |
| 21 return enter.functions()->GetFlashAPI()->CreateThreadAdapterForInstance( |
| 22 instance); |
18 } | 23 } |
19 | 24 |
20 void ClearThreadAdapterForInstance(PP_Instance instance) { | 25 void ClearThreadAdapterForInstance(PP_Instance instance) { |
| 26 EnterInstance enter(instance); |
| 27 if (enter.succeeded()) { |
| 28 return enter.functions()->GetFlashAPI()->ClearThreadAdapterForInstance( |
| 29 instance); |
| 30 } |
21 } | 31 } |
22 | 32 |
23 int32_t OpenFile(PP_Instance instance, | 33 int32_t OpenFile(PP_Instance instance, |
24 const char* path, | 34 const char* path, |
25 int32_t mode, | 35 int32_t mode, |
26 PP_FileHandle* file) { | 36 PP_FileHandle* file) { |
27 EnterInstanceAPI<PPB_Flash_File_API> enter(instance); | 37 EnterInstance enter(instance); |
28 if (enter.failed()) | 38 if (enter.failed()) |
29 return PP_ERROR_BADARGUMENT; | 39 return PP_ERROR_BADARGUMENT; |
30 return enter.functions()->OpenFile(instance, path, mode, file); | 40 return enter.functions()->GetFlashAPI()->OpenFile(instance, path, mode, file); |
31 } | 41 } |
32 | 42 |
33 int32_t RenameFile(PP_Instance instance, | 43 int32_t RenameFile(PP_Instance instance, |
34 const char* path_from, | 44 const char* path_from, |
35 const char* path_to) { | 45 const char* path_to) { |
36 EnterInstanceAPI<PPB_Flash_File_API> enter(instance); | 46 EnterInstance enter(instance); |
37 if (enter.failed()) | 47 if (enter.failed()) |
38 return PP_ERROR_BADARGUMENT; | 48 return PP_ERROR_BADARGUMENT; |
39 return enter.functions()->RenameFile(instance, path_from, path_to); | 49 return enter.functions()->GetFlashAPI()->RenameFile(instance, |
| 50 path_from, path_to); |
40 } | 51 } |
41 | 52 |
42 int32_t DeleteFileOrDir(PP_Instance instance, | 53 int32_t DeleteFileOrDir(PP_Instance instance, |
43 const char* path, | 54 const char* path, |
44 PP_Bool recursive) { | 55 PP_Bool recursive) { |
45 EnterInstanceAPI<PPB_Flash_File_API> enter(instance); | 56 EnterInstance enter(instance); |
46 if (enter.failed()) | 57 if (enter.failed()) |
47 return PP_ERROR_BADARGUMENT; | 58 return PP_ERROR_BADARGUMENT; |
48 return enter.functions()->DeleteFileOrDir(instance, path, recursive); | 59 return enter.functions()->GetFlashAPI()->DeleteFileOrDir(instance, path, |
| 60 recursive); |
49 } | 61 } |
50 | 62 |
51 int32_t CreateDir(PP_Instance instance, const char* path) { | 63 int32_t CreateDir(PP_Instance instance, const char* path) { |
52 EnterInstanceAPI<PPB_Flash_File_API> enter(instance); | 64 EnterInstance enter(instance); |
53 if (enter.failed()) | 65 if (enter.failed()) |
54 return PP_ERROR_BADARGUMENT; | 66 return PP_ERROR_BADARGUMENT; |
55 return enter.functions()->CreateDir(instance, path); | 67 return enter.functions()->GetFlashAPI()->CreateDir(instance, path); |
56 } | 68 } |
57 | 69 |
58 int32_t QueryFile(PP_Instance instance, const char* path, PP_FileInfo* info) { | 70 int32_t QueryFile(PP_Instance instance, const char* path, PP_FileInfo* info) { |
59 EnterInstanceAPI<PPB_Flash_File_API> enter(instance); | 71 EnterInstance enter(instance); |
60 if (enter.failed()) | 72 if (enter.failed()) |
61 return PP_ERROR_BADARGUMENT; | 73 return PP_ERROR_BADARGUMENT; |
62 return enter.functions()->QueryFile(instance, path, info); | 74 return enter.functions()->GetFlashAPI()->QueryFile(instance, path, info); |
63 } | 75 } |
64 | 76 |
65 int32_t GetDirContents(PP_Instance instance, | 77 int32_t GetDirContents(PP_Instance instance, |
66 const char* path, | 78 const char* path, |
67 PP_DirContents_Dev** contents) { | 79 PP_DirContents_Dev** contents) { |
68 EnterInstanceAPI<PPB_Flash_File_API> enter(instance); | 80 EnterInstance enter(instance); |
69 if (enter.failed()) | 81 if (enter.failed()) |
70 return PP_ERROR_BADARGUMENT; | 82 return PP_ERROR_BADARGUMENT; |
71 return enter.functions()->GetDirContents(instance, path, contents); | 83 return enter.functions()->GetFlashAPI()->GetDirContents(instance, path, |
| 84 contents); |
72 } | 85 } |
73 | 86 |
74 void FreeDirContents(PP_Instance instance, | 87 void FreeDirContents(PP_Instance instance, |
75 PP_DirContents_Dev* contents) { | 88 PP_DirContents_Dev* contents) { |
76 EnterInstanceAPI<PPB_Flash_File_API> enter(instance); | 89 EnterInstance enter(instance); |
77 if (enter.succeeded()) | 90 if (enter.succeeded()) |
78 enter.functions()->FreeDirContents(instance, contents); | 91 enter.functions()->GetFlashAPI()->FreeDirContents(instance, contents); |
79 } | 92 } |
80 | 93 |
81 int32_t CreateTemporaryFile(PP_Instance instance, PP_FileHandle* file) { | 94 int32_t CreateTemporaryFile(PP_Instance instance, PP_FileHandle* file) { |
82 EnterInstanceAPI<PPB_Flash_File_API> enter(instance); | 95 EnterInstance enter(instance); |
83 if (enter.failed()) | 96 if (enter.failed()) |
84 return PP_ERROR_BADARGUMENT; | 97 return PP_ERROR_BADARGUMENT; |
85 | 98 |
86 *file = PP_kInvalidFileHandle; | 99 *file = PP_kInvalidFileHandle; |
87 return enter.functions()->CreateTemporaryFile(instance, file); | 100 return enter.functions()->GetFlashAPI()->CreateTemporaryFile(instance, file); |
88 } | 101 } |
89 | 102 |
90 const PPB_Flash_File_ModuleLocal_2_0 g_ppb_flash_file_modulelocal_thunk_2_0 = { | 103 const PPB_Flash_File_ModuleLocal_2_0 g_ppb_flash_file_modulelocal_thunk_2_0 = { |
91 &CreateThreadAdapterForInstance, | 104 &CreateThreadAdapterForInstance, |
92 &ClearThreadAdapterForInstance, | 105 &ClearThreadAdapterForInstance, |
93 &OpenFile, | 106 &OpenFile, |
94 &RenameFile, | 107 &RenameFile, |
95 &DeleteFileOrDir, | 108 &DeleteFileOrDir, |
96 &CreateDir, | 109 &CreateDir, |
97 &QueryFile, | 110 &QueryFile, |
(...skipping 21 matching lines...) Expand all Loading... |
119 return &g_ppb_flash_file_modulelocal_thunk_2_0; | 132 return &g_ppb_flash_file_modulelocal_thunk_2_0; |
120 } | 133 } |
121 | 134 |
122 const PPB_Flash_File_ModuleLocal_3_0* | 135 const PPB_Flash_File_ModuleLocal_3_0* |
123 GetPPB_Flash_File_ModuleLocal_3_0_Thunk() { | 136 GetPPB_Flash_File_ModuleLocal_3_0_Thunk() { |
124 return &g_ppb_flash_file_modulelocal_thunk_3_0; | 137 return &g_ppb_flash_file_modulelocal_thunk_3_0; |
125 } | 138 } |
126 | 139 |
127 } // namespace thunk | 140 } // namespace thunk |
128 } // namespace ppapi | 141 } // namespace ppapi |
OLD | NEW |