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 "webkit/plugins/ppapi/ppb_flash_file_impl.h" | 5 #include "webkit/plugins/ppapi/ppb_flash_file_impl.h" |
6 | 6 |
7 #include <string.h> | 7 #include <string.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "ppapi/c/pp_file_info.h" | 11 #include "ppapi/c/pp_file_info.h" |
12 #include "ppapi/c/ppb_file_io.h" | 12 #include "ppapi/c/ppb_file_io.h" |
13 #include "ppapi/c/private/ppb_flash_file.h" | 13 #include "ppapi/c/private/ppb_flash_file.h" |
14 #include "ppapi/shared_impl/time_conversion.h" | 14 #include "ppapi/shared_impl/time_conversion.h" |
15 #include "ppapi/thunk/enter.h" | 15 #include "ppapi/thunk/enter.h" |
16 #include "webkit/plugins/ppapi/common.h" | 16 #include "webkit/plugins/ppapi/common.h" |
17 #include "webkit/plugins/ppapi/file_path.h" | 17 #include "webkit/plugins/ppapi/file_path.h" |
18 #include "webkit/plugins/ppapi/file_type_conversions.h" | 18 #include "webkit/plugins/ppapi/file_type_conversions.h" |
| 19 #include "webkit/plugins/ppapi/host_globals.h" |
19 #include "webkit/plugins/ppapi/plugin_delegate.h" | 20 #include "webkit/plugins/ppapi/plugin_delegate.h" |
20 #include "webkit/plugins/ppapi/plugin_module.h" | 21 #include "webkit/plugins/ppapi/plugin_module.h" |
21 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" | 22 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" |
22 #include "webkit/plugins/ppapi/ppb_file_ref_impl.h" | 23 #include "webkit/plugins/ppapi/ppb_file_ref_impl.h" |
23 #include "webkit/plugins/ppapi/resource_helper.h" | 24 #include "webkit/plugins/ppapi/resource_helper.h" |
24 #include "webkit/plugins/ppapi/resource_tracker.h" | 25 #include "webkit/plugins/ppapi/resource_tracker.h" |
25 | 26 |
26 #if defined(OS_WIN) | 27 #if defined(OS_WIN) |
27 #include "base/utf_string_conversions.h" | 28 #include "base/utf_string_conversions.h" |
28 #endif | 29 #endif |
(...skipping 30 matching lines...) Expand all Loading... |
59 } | 60 } |
60 | 61 |
61 int32_t OpenModuleLocalFile(PP_Instance pp_instance, | 62 int32_t OpenModuleLocalFile(PP_Instance pp_instance, |
62 const char* path, | 63 const char* path, |
63 int32_t mode, | 64 int32_t mode, |
64 PP_FileHandle* file) { | 65 PP_FileHandle* file) { |
65 int flags = 0; | 66 int flags = 0; |
66 if (!path || !PepperFileOpenFlagsToPlatformFileFlags(mode, &flags) || !file) | 67 if (!path || !PepperFileOpenFlagsToPlatformFileFlags(mode, &flags) || !file) |
67 return PP_ERROR_BADARGUMENT; | 68 return PP_ERROR_BADARGUMENT; |
68 | 69 |
69 PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance); | 70 PluginInstance* instance = |
| 71 HostGlobals::Get()->host_resource_tracker()->GetInstance(pp_instance); |
70 if (!instance) | 72 if (!instance) |
71 return PP_ERROR_FAILED; | 73 return PP_ERROR_FAILED; |
72 | 74 |
73 base::PlatformFile base_file; | 75 base::PlatformFile base_file; |
74 base::PlatformFileError result = instance->delegate()->OpenFile( | 76 base::PlatformFileError result = instance->delegate()->OpenFile( |
75 PepperFilePath::MakeModuleLocal(instance->module(), path), | 77 PepperFilePath::MakeModuleLocal(instance->module(), path), |
76 flags, | 78 flags, |
77 &base_file); | 79 &base_file); |
78 *file = base_file; | 80 *file = base_file; |
79 return PlatformFileErrorToPepperError(result); | 81 return PlatformFileErrorToPepperError(result); |
80 } | 82 } |
81 | 83 |
82 int32_t RenameModuleLocalFile(PP_Instance pp_instance, | 84 int32_t RenameModuleLocalFile(PP_Instance pp_instance, |
83 const char* from_path, | 85 const char* from_path, |
84 const char* to_path) { | 86 const char* to_path) { |
85 if (!from_path || !to_path) | 87 if (!from_path || !to_path) |
86 return PP_ERROR_BADARGUMENT; | 88 return PP_ERROR_BADARGUMENT; |
87 | 89 |
88 PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance); | 90 PluginInstance* instance = |
| 91 HostGlobals::Get()->host_resource_tracker()->GetInstance(pp_instance); |
89 if (!instance) | 92 if (!instance) |
90 return PP_ERROR_FAILED; | 93 return PP_ERROR_FAILED; |
91 | 94 |
92 base::PlatformFileError result = instance->delegate()->RenameFile( | 95 base::PlatformFileError result = instance->delegate()->RenameFile( |
93 PepperFilePath::MakeModuleLocal(instance->module(), from_path), | 96 PepperFilePath::MakeModuleLocal(instance->module(), from_path), |
94 PepperFilePath::MakeModuleLocal(instance->module(), to_path)); | 97 PepperFilePath::MakeModuleLocal(instance->module(), to_path)); |
95 return PlatformFileErrorToPepperError(result); | 98 return PlatformFileErrorToPepperError(result); |
96 } | 99 } |
97 | 100 |
98 int32_t DeleteModuleLocalFileOrDir(PP_Instance pp_instance, | 101 int32_t DeleteModuleLocalFileOrDir(PP_Instance pp_instance, |
99 const char* path, | 102 const char* path, |
100 PP_Bool recursive) { | 103 PP_Bool recursive) { |
101 if (!path) | 104 if (!path) |
102 return PP_ERROR_BADARGUMENT; | 105 return PP_ERROR_BADARGUMENT; |
103 | 106 |
104 PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance); | 107 PluginInstance* instance = |
| 108 HostGlobals::Get()->host_resource_tracker()->GetInstance(pp_instance); |
105 if (!instance) | 109 if (!instance) |
106 return PP_ERROR_FAILED; | 110 return PP_ERROR_FAILED; |
107 | 111 |
108 base::PlatformFileError result = instance->delegate()->DeleteFileOrDir( | 112 base::PlatformFileError result = instance->delegate()->DeleteFileOrDir( |
109 PepperFilePath::MakeModuleLocal(instance->module(), path), | 113 PepperFilePath::MakeModuleLocal(instance->module(), path), |
110 PPBoolToBool(recursive)); | 114 PPBoolToBool(recursive)); |
111 return PlatformFileErrorToPepperError(result); | 115 return PlatformFileErrorToPepperError(result); |
112 } | 116 } |
113 | 117 |
114 int32_t CreateModuleLocalDir(PP_Instance pp_instance, const char* path) { | 118 int32_t CreateModuleLocalDir(PP_Instance pp_instance, const char* path) { |
115 if (!path) | 119 if (!path) |
116 return PP_ERROR_BADARGUMENT; | 120 return PP_ERROR_BADARGUMENT; |
117 | 121 |
118 PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance); | 122 PluginInstance* instance = |
| 123 HostGlobals::Get()->host_resource_tracker()->GetInstance(pp_instance); |
119 if (!instance) | 124 if (!instance) |
120 return PP_ERROR_FAILED; | 125 return PP_ERROR_FAILED; |
121 | 126 |
122 base::PlatformFileError result = instance->delegate()->CreateDir( | 127 base::PlatformFileError result = instance->delegate()->CreateDir( |
123 PepperFilePath::MakeModuleLocal(instance->module(), path)); | 128 PepperFilePath::MakeModuleLocal(instance->module(), path)); |
124 return PlatformFileErrorToPepperError(result); | 129 return PlatformFileErrorToPepperError(result); |
125 } | 130 } |
126 | 131 |
127 int32_t QueryModuleLocalFile(PP_Instance pp_instance, | 132 int32_t QueryModuleLocalFile(PP_Instance pp_instance, |
128 const char* path, | 133 const char* path, |
129 PP_FileInfo* info) { | 134 PP_FileInfo* info) { |
130 if (!path || !info) | 135 if (!path || !info) |
131 return PP_ERROR_BADARGUMENT; | 136 return PP_ERROR_BADARGUMENT; |
132 | 137 |
133 PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance); | 138 PluginInstance* instance = |
| 139 HostGlobals::Get()->host_resource_tracker()->GetInstance(pp_instance); |
134 if (!instance) | 140 if (!instance) |
135 return PP_ERROR_FAILED; | 141 return PP_ERROR_FAILED; |
136 | 142 |
137 base::PlatformFileInfo file_info; | 143 base::PlatformFileInfo file_info; |
138 base::PlatformFileError result = instance->delegate()->QueryFile( | 144 base::PlatformFileError result = instance->delegate()->QueryFile( |
139 PepperFilePath::MakeModuleLocal(instance->module(), path), | 145 PepperFilePath::MakeModuleLocal(instance->module(), path), |
140 &file_info); | 146 &file_info); |
141 if (result == base::PLATFORM_FILE_OK) { | 147 if (result == base::PLATFORM_FILE_OK) { |
142 info->size = file_info.size; | 148 info->size = file_info.size; |
143 info->creation_time = TimeToPPTime(file_info.creation_time); | 149 info->creation_time = TimeToPPTime(file_info.creation_time); |
144 info->last_access_time = TimeToPPTime(file_info.last_accessed); | 150 info->last_access_time = TimeToPPTime(file_info.last_accessed); |
145 info->last_modified_time = TimeToPPTime(file_info.last_modified); | 151 info->last_modified_time = TimeToPPTime(file_info.last_modified); |
146 info->system_type = PP_FILESYSTEMTYPE_EXTERNAL; | 152 info->system_type = PP_FILESYSTEMTYPE_EXTERNAL; |
147 if (file_info.is_directory) | 153 if (file_info.is_directory) |
148 info->type = PP_FILETYPE_DIRECTORY; | 154 info->type = PP_FILETYPE_DIRECTORY; |
149 else | 155 else |
150 info->type = PP_FILETYPE_REGULAR; | 156 info->type = PP_FILETYPE_REGULAR; |
151 } | 157 } |
152 return PlatformFileErrorToPepperError(result); | 158 return PlatformFileErrorToPepperError(result); |
153 } | 159 } |
154 | 160 |
155 int32_t GetModuleLocalDirContents(PP_Instance pp_instance, | 161 int32_t GetModuleLocalDirContents(PP_Instance pp_instance, |
156 const char* path, | 162 const char* path, |
157 PP_DirContents_Dev** contents) { | 163 PP_DirContents_Dev** contents) { |
158 if (!path || !contents) | 164 if (!path || !contents) |
159 return PP_ERROR_BADARGUMENT; | 165 return PP_ERROR_BADARGUMENT; |
160 PluginInstance* instance = ResourceTracker::Get()->GetInstance(pp_instance); | 166 PluginInstance* instance = |
| 167 HostGlobals::Get()->host_resource_tracker()->GetInstance(pp_instance); |
161 if (!instance) | 168 if (!instance) |
162 return PP_ERROR_FAILED; | 169 return PP_ERROR_FAILED; |
163 | 170 |
164 *contents = NULL; | 171 *contents = NULL; |
165 DirContents pepper_contents; | 172 DirContents pepper_contents; |
166 base::PlatformFileError result = instance->delegate()->GetDirContents( | 173 base::PlatformFileError result = instance->delegate()->GetDirContents( |
167 PepperFilePath::MakeModuleLocal(instance->module(), path), | 174 PepperFilePath::MakeModuleLocal(instance->module(), path), |
168 &pepper_contents); | 175 &pepper_contents); |
169 | 176 |
170 if (result != base::PLATFORM_FILE_OK) | 177 if (result != base::PLATFORM_FILE_OK) |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 | 282 |
276 } // namespace | 283 } // namespace |
277 | 284 |
278 // static | 285 // static |
279 const PPB_Flash_File_FileRef* PPB_Flash_File_FileRef_Impl::GetInterface() { | 286 const PPB_Flash_File_FileRef* PPB_Flash_File_FileRef_Impl::GetInterface() { |
280 return &ppb_flash_file_fileref; | 287 return &ppb_flash_file_fileref; |
281 } | 288 } |
282 | 289 |
283 } // namespace ppapi | 290 } // namespace ppapi |
284 } // namespace webkit | 291 } // namespace webkit |
OLD | NEW |