Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(262)

Side by Side Diff: webkit/plugins/ppapi/ppb_flash_file_impl.cc

Issue 7206016: Convert most remaining resources to use the API/thunk system. The significant (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/dev/pp_file_info_dev.h" 11 #include "ppapi/c/dev/pp_file_info_dev.h"
12 #include "ppapi/c/dev/ppb_file_io_dev.h" 12 #include "ppapi/c/dev/ppb_file_io_dev.h"
13 #include "ppapi/c/private/ppb_flash_file.h" 13 #include "ppapi/c/private/ppb_flash_file.h"
14 #include "ppapi/thunk/enter.h"
14 #include "webkit/plugins/ppapi/common.h" 15 #include "webkit/plugins/ppapi/common.h"
15 #include "webkit/plugins/ppapi/file_path.h" 16 #include "webkit/plugins/ppapi/file_path.h"
16 #include "webkit/plugins/ppapi/file_type_conversions.h" 17 #include "webkit/plugins/ppapi/file_type_conversions.h"
17 #include "webkit/plugins/ppapi/plugin_delegate.h" 18 #include "webkit/plugins/ppapi/plugin_delegate.h"
18 #include "webkit/plugins/ppapi/plugin_module.h" 19 #include "webkit/plugins/ppapi/plugin_module.h"
19 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h" 20 #include "webkit/plugins/ppapi/ppapi_plugin_instance.h"
20 #include "webkit/plugins/ppapi/ppb_file_ref_impl.h" 21 #include "webkit/plugins/ppapi/ppb_file_ref_impl.h"
21 #include "webkit/plugins/ppapi/resource_tracker.h" 22 #include "webkit/plugins/ppapi/resource_tracker.h"
22 23
23 #if defined(OS_WIN) 24 #if defined(OS_WIN)
24 #include "base/utf_string_conversions.h" 25 #include "base/utf_string_conversions.h"
25 #endif 26 #endif
26 27
28 using ppapi::thunk::EnterResource;
29 using ppapi::thunk::PPB_FileRef_API;
30
27 namespace webkit { 31 namespace webkit {
28 namespace ppapi { 32 namespace ppapi {
29 33
30 namespace { 34 namespace {
31 35
32 void FreeDirContents(PP_Instance instance, PP_DirContents_Dev* contents) { 36 void FreeDirContents(PP_Instance instance, PP_DirContents_Dev* contents) {
33 DCHECK(contents); 37 DCHECK(contents);
34 for (int32_t i = 0; i < contents->count; ++i) { 38 for (int32_t i = 0; i < contents->count; ++i) {
35 delete [] contents->entries[i].name; 39 delete [] contents->entries[i].name;
36 } 40 }
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 211
208 namespace { 212 namespace {
209 213
210 int32_t OpenFileRefFile(PP_Resource file_ref_id, 214 int32_t OpenFileRefFile(PP_Resource file_ref_id,
211 int32_t mode, 215 int32_t mode,
212 PP_FileHandle* file) { 216 PP_FileHandle* file) {
213 int flags = 0; 217 int flags = 0;
214 if (!PepperFileOpenFlagsToPlatformFileFlags(mode, &flags) || !file) 218 if (!PepperFileOpenFlagsToPlatformFileFlags(mode, &flags) || !file)
215 return PP_ERROR_BADARGUMENT; 219 return PP_ERROR_BADARGUMENT;
216 220
217 scoped_refptr<PPB_FileRef_Impl> file_ref( 221 EnterResource<PPB_FileRef_API> enter(file_ref_id, true);
218 Resource::GetAs<PPB_FileRef_Impl>(file_ref_id)); 222 if (enter.failed())
219 if (!file_ref)
220 return PP_ERROR_BADRESOURCE; 223 return PP_ERROR_BADRESOURCE;
224 PPB_FileRef_Impl* file_ref = static_cast<PPB_FileRef_Impl*>(enter.object());
221 225
222 PluginInstance* instance = file_ref->instance(); 226 PluginInstance* instance = file_ref->instance();
223 if (!instance) 227 if (!instance)
224 return PP_ERROR_FAILED; 228 return PP_ERROR_FAILED;
225 229
226 base::PlatformFile base_file; 230 base::PlatformFile base_file;
227 base::PlatformFileError result = instance->delegate()->OpenFile( 231 base::PlatformFileError result = instance->delegate()->OpenFile(
228 PepperFilePath::MakeAbsolute(file_ref->GetSystemPath()), 232 PepperFilePath::MakeAbsolute(file_ref->GetSystemPath()),
229 flags, 233 flags,
230 &base_file); 234 &base_file);
231 *file = base_file; 235 *file = base_file;
232 return PlatformFileErrorToPepperError(result); 236 return PlatformFileErrorToPepperError(result);
233 } 237 }
234 238
235 int32_t QueryFileRefFile(PP_Resource file_ref_id, 239 int32_t QueryFileRefFile(PP_Resource file_ref_id,
236 PP_FileInfo_Dev* info) { 240 PP_FileInfo_Dev* info) {
237 scoped_refptr<PPB_FileRef_Impl> file_ref( 241 EnterResource<PPB_FileRef_API> enter(file_ref_id, true);
238 Resource::GetAs<PPB_FileRef_Impl>(file_ref_id)); 242 if (enter.failed())
239 if (!file_ref)
240 return PP_ERROR_BADRESOURCE; 243 return PP_ERROR_BADRESOURCE;
244 PPB_FileRef_Impl* file_ref = static_cast<PPB_FileRef_Impl*>(enter.object());
241 245
242 PluginInstance* instance = file_ref->instance(); 246 PluginInstance* instance = file_ref->instance();
243 if (!instance) 247 if (!instance)
244 return PP_ERROR_FAILED; 248 return PP_ERROR_FAILED;
245 249
246 base::PlatformFileInfo file_info; 250 base::PlatformFileInfo file_info;
247 base::PlatformFileError result = instance->delegate()->QueryFile( 251 base::PlatformFileError result = instance->delegate()->QueryFile(
248 PepperFilePath::MakeAbsolute(file_ref->GetSystemPath()), 252 PepperFilePath::MakeAbsolute(file_ref->GetSystemPath()),
249 &file_info); 253 &file_info);
250 if (result == base::PLATFORM_FILE_OK) { 254 if (result == base::PLATFORM_FILE_OK) {
(...skipping 17 matching lines...) Expand all
268 272
269 } // namespace 273 } // namespace
270 274
271 // static 275 // static
272 const PPB_Flash_File_FileRef* PPB_Flash_File_FileRef_Impl::GetInterface() { 276 const PPB_Flash_File_FileRef* PPB_Flash_File_FileRef_Impl::GetInterface() {
273 return &ppb_flash_file_fileref; 277 return &ppb_flash_file_fileref;
274 } 278 }
275 279
276 } // namespace ppapi 280 } // namespace ppapi
277 } // namespace webkit 281 } // namespace webkit
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698