• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #include "ppapi/c/pp_errors.h"
6 #include "ppapi/c/private/ppb_flash_file.h"
7 #include "ppapi/thunk/enter.h"
8 #include "ppapi/thunk/ppb_flash_file_api.h"
9 #include "ppapi/thunk/thunk.h"
10 
11 namespace ppapi {
12 namespace thunk {
13 
14 namespace {
15 
CreateThreadAdapterForInstance(PP_Instance instance)16 bool CreateThreadAdapterForInstance(PP_Instance instance) {
17   return true;
18 }
19 
ClearThreadAdapterForInstance(PP_Instance instance)20 void ClearThreadAdapterForInstance(PP_Instance instance) {
21 }
22 
OpenFile(PP_Instance instance,const char * path,int32_t mode,PP_FileHandle * file)23 int32_t OpenFile(PP_Instance instance,
24                  const char* path,
25                  int32_t mode,
26                  PP_FileHandle* file) {
27   EnterInstanceAPI<PPB_Flash_File_API> enter(instance);
28   if (enter.failed())
29     return PP_ERROR_BADARGUMENT;
30   return enter.functions()->OpenFile(instance, path, mode, file);
31 }
32 
RenameFile(PP_Instance instance,const char * path_from,const char * path_to)33 int32_t RenameFile(PP_Instance instance,
34                    const char* path_from,
35                    const char* path_to) {
36   EnterInstanceAPI<PPB_Flash_File_API> enter(instance);
37   if (enter.failed())
38     return PP_ERROR_BADARGUMENT;
39   return enter.functions()->RenameFile(instance, path_from, path_to);
40 }
41 
DeleteFileOrDir(PP_Instance instance,const char * path,PP_Bool recursive)42 int32_t DeleteFileOrDir(PP_Instance instance,
43                         const char* path,
44                         PP_Bool recursive) {
45   EnterInstanceAPI<PPB_Flash_File_API> enter(instance);
46   if (enter.failed())
47     return PP_ERROR_BADARGUMENT;
48   return enter.functions()->DeleteFileOrDir(instance, path, recursive);
49 }
50 
CreateDir(PP_Instance instance,const char * path)51 int32_t CreateDir(PP_Instance instance, const char* path) {
52   EnterInstanceAPI<PPB_Flash_File_API> enter(instance);
53   if (enter.failed())
54     return PP_ERROR_BADARGUMENT;
55   return enter.functions()->CreateDir(instance, path);
56 }
57 
QueryFile(PP_Instance instance,const char * path,PP_FileInfo * info)58 int32_t QueryFile(PP_Instance instance, const char* path, PP_FileInfo* info) {
59   EnterInstanceAPI<PPB_Flash_File_API> enter(instance);
60   if (enter.failed())
61     return PP_ERROR_BADARGUMENT;
62   return enter.functions()->QueryFile(instance, path, info);
63 }
64 
GetDirContents(PP_Instance instance,const char * path,PP_DirContents_Dev ** contents)65 int32_t GetDirContents(PP_Instance instance,
66                        const char* path,
67                        PP_DirContents_Dev** contents) {
68   EnterInstanceAPI<PPB_Flash_File_API> enter(instance);
69   if (enter.failed())
70     return PP_ERROR_BADARGUMENT;
71   return enter.functions()->GetDirContents(instance, path, contents);
72 }
73 
FreeDirContents(PP_Instance instance,PP_DirContents_Dev * contents)74 void FreeDirContents(PP_Instance instance,
75                      PP_DirContents_Dev* contents) {
76   EnterInstanceAPI<PPB_Flash_File_API> enter(instance);
77   if (enter.succeeded())
78     enter.functions()->FreeDirContents(instance, contents);
79 }
80 
CreateTemporaryFile(PP_Instance instance,PP_FileHandle * file)81 int32_t CreateTemporaryFile(PP_Instance instance, PP_FileHandle* file) {
82   EnterInstanceAPI<PPB_Flash_File_API> enter(instance);
83   if (enter.failed())
84     return PP_ERROR_BADARGUMENT;
85 
86   *file = PP_kInvalidFileHandle;
87   return enter.functions()->CreateTemporaryFile(instance, file);
88 }
89 
90 const PPB_Flash_File_ModuleLocal_3_0 g_ppb_flash_file_modulelocal_thunk_3_0 = {
91   &CreateThreadAdapterForInstance,
92   &ClearThreadAdapterForInstance,
93   &OpenFile,
94   &RenameFile,
95   &DeleteFileOrDir,
96   &CreateDir,
97   &QueryFile,
98   &GetDirContents,
99   &FreeDirContents,
100   &CreateTemporaryFile
101 };
102 
103 }  // namespace
104 
105 const PPB_Flash_File_ModuleLocal_3_0*
GetPPB_Flash_File_ModuleLocal_3_0_Thunk()106     GetPPB_Flash_File_ModuleLocal_3_0_Thunk() {
107   return &g_ppb_flash_file_modulelocal_thunk_3_0;
108 }
109 
110 }  // namespace thunk
111 }  // namespace ppapi
112