Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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/thunk.h" | |
|
yzshen1
2012/04/25 20:50:47
Sort this section, please.
| |
| 8 #include "ppapi/thunk/enter.h" | |
| 9 #include "ppapi/thunk/ppb_instance_api.h" | |
| 10 #include "ppapi/thunk/ppb_flash_api.h" | |
| 11 | |
| 12 namespace ppapi { | |
| 13 namespace thunk { | |
| 14 | |
| 15 namespace { | |
| 16 | |
| 17 bool CreateThreadAdapterForInstance(PP_Instance instance) { | |
| 18 EnterInstance enter(instance); | |
| 19 if (enter.failed()) | |
| 20 return PP_FALSE; | |
|
yzshen1
2012/04/25 20:50:47
The return value is bool.
| |
| 21 return enter.functions()->GetFlashAPI()->CreateThreadAdapterForInstance( | |
| 22 instance); | |
| 23 } | |
| 24 | |
| 25 void ClearThreadAdapterForInstance(PP_Instance instance) { | |
| 26 EnterInstance enter(instance); | |
| 27 if (enter.succeeded()) { | |
| 28 return enter.functions()->GetFlashAPI()->ClearThreadAdapterForInstance( | |
| 29 instance); | |
| 30 } | |
| 31 } | |
| 32 | |
| 33 int32_t OpenFile(PP_Instance instance, | |
| 34 const char* path, | |
| 35 int32_t mode, | |
| 36 PP_FileHandle* file) { | |
| 37 EnterInstance enter(instance); | |
| 38 if (enter.failed()) | |
| 39 return PP_ERROR_BADARGUMENT; | |
| 40 return enter.functions()->GetFlashAPI()->OpenFile(instance, path, mode, file); | |
| 41 } | |
| 42 | |
| 43 int32_t RenameFile(PP_Instance instance, | |
| 44 const char* path_from, | |
| 45 const char* path_to) { | |
| 46 EnterInstance enter(instance); | |
| 47 if (enter.failed()) | |
| 48 return PP_ERROR_BADARGUMENT; | |
| 49 return enter.functions()->GetFlashAPI()->RenameFile(instance, | |
| 50 path_from, path_to); | |
| 51 } | |
| 52 | |
| 53 int32_t DeleteFileOrDir(PP_Instance instance, | |
| 54 const char* path, | |
| 55 PP_Bool recursive) { | |
| 56 EnterInstance enter(instance); | |
| 57 if (enter.failed()) | |
| 58 return PP_ERROR_BADARGUMENT; | |
| 59 return enter.functions()->GetFlashAPI()->DeleteFileOrDir(instance, path, | |
| 60 recursive); | |
| 61 } | |
| 62 | |
| 63 int32_t CreateDir(PP_Instance instance, const char* path) { | |
| 64 EnterInstance enter(instance); | |
| 65 if (enter.failed()) | |
| 66 return PP_ERROR_BADARGUMENT; | |
| 67 return enter.functions()->GetFlashAPI()->CreateDir(instance, path); | |
| 68 } | |
| 69 | |
| 70 int32_t QueryFile(PP_Instance instance, const char* path, PP_FileInfo* info) { | |
| 71 EnterInstance enter(instance); | |
| 72 if (enter.failed()) | |
| 73 return PP_ERROR_BADARGUMENT; | |
| 74 return enter.functions()->GetFlashAPI()->QueryFile(instance, path, info); | |
| 75 } | |
| 76 | |
| 77 int32_t GetDirContents(PP_Instance instance, const char* path, | |
|
yzshen1
2012/04/25 20:50:47
Please put each parameter on a separate line.
| |
| 78 PP_DirContents_Dev** contents) { | |
| 79 EnterInstance enter(instance); | |
| 80 if (enter.failed()) | |
| 81 return PP_ERROR_BADARGUMENT; | |
| 82 return enter.functions()->GetFlashAPI()->GetDirContents(instance, path, | |
| 83 contents); | |
| 84 } | |
| 85 | |
| 86 void FreeDirContents(PP_Instance instance, | |
| 87 PP_DirContents_Dev* contents) { | |
| 88 EnterInstance enter(instance); | |
| 89 if (enter.succeeded()) { | |
| 90 return enter.functions()->GetFlashAPI()->FreeDirContents(instance, | |
| 91 contents); | |
| 92 } | |
| 93 } | |
| 94 | |
| 95 const PPB_Flash_File_ModuleLocal g_ppb_flash_file_modulelocal_thunk = { | |
| 96 &CreateThreadAdapterForInstance, | |
| 97 &ClearThreadAdapterForInstance, | |
| 98 &OpenFile, | |
| 99 &RenameFile, | |
| 100 &DeleteFileOrDir, | |
| 101 &CreateDir, | |
| 102 &QueryFile, | |
| 103 &GetDirContents, | |
| 104 &FreeDirContents | |
| 105 }; | |
| 106 | |
| 107 } // namespace | |
| 108 | |
| 109 const PPB_Flash_File_ModuleLocal* GetPPB_Flash_File_ModuleLocal_Thunk() { | |
| 110 return &g_ppb_flash_file_modulelocal_thunk; | |
| 111 } | |
| 112 | |
| 113 } // namespace thunk | |
| 114 } // namespace ppapi | |
| OLD | NEW |