Modified code to report caret offset and text selection in all editable text and...
[chromium-blink-merge.git] / ppapi / thunk / ppb_flash_file_modulelocal_thunk.cc
blob11962e41edd6d584d85fa3f8839b41405928f296
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.
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"
11 namespace ppapi {
12 namespace thunk {
14 namespace {
16 bool CreateThreadAdapterForInstance(PP_Instance instance) {
17 return true;
20 void ClearThreadAdapterForInstance(PP_Instance instance) {
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);
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);
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);
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);
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);
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);
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);
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;
86 *file = PP_kInvalidFileHandle;
87 return enter.functions()->CreateTemporaryFile(instance, file);
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
103 } // namespace
105 const PPB_Flash_File_ModuleLocal_3_0*
106 GetPPB_Flash_File_ModuleLocal_3_0_Thunk() {
107 return &g_ppb_flash_file_modulelocal_thunk_3_0;
110 } // namespace thunk
111 } // namespace ppapi