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

Side by Side Diff: ppapi/thunk/ppb_flash_file_fileref_thunk.cc

Issue 11359097: Refactored the PPB_Flash_File_ModuleLocal/FileRef to the new ppapi resource model (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years 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
« no previous file with comments | « ppapi/thunk/ppb_flash_file_api.h ('k') | ppapi/thunk/ppb_flash_file_modulelocal_thunk.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 "ppapi/c/pp_errors.h" 5 #include "ppapi/c/pp_errors.h"
6 #include "ppapi/c/private/ppb_flash_file.h" 6 #include "ppapi/c/private/ppb_flash_file.h"
7 #include "ppapi/thunk/enter.h" 7 #include "ppapi/thunk/enter.h"
8 #include "ppapi/thunk/ppb_file_ref_api.h" 8 #include "ppapi/thunk/ppb_file_ref_api.h"
9 #include "ppapi/thunk/ppb_flash_api.h" 9 #include "ppapi/thunk/ppb_flash_file_api.h"
10 #include "ppapi/thunk/ppb_instance_api.h"
11 #include "ppapi/thunk/thunk.h" 10 #include "ppapi/thunk/thunk.h"
12 11
13 namespace ppapi { 12 namespace ppapi {
14 namespace thunk { 13 namespace thunk {
15 14
16 namespace { 15 namespace {
17 16
18 // Returns 0 on failure. 17 // Returns 0 on failure.
19 PP_Instance GetInstanceFromFileRef(PP_Resource file_ref) { 18 PP_Instance GetInstanceFromFileRef(PP_Resource file_ref) {
20 thunk::EnterResource<thunk::PPB_FileRef_API> enter(file_ref, true); 19 thunk::EnterResource<thunk::PPB_FileRef_API> enter(file_ref, true);
21 if (enter.failed()) 20 if (enter.failed())
22 return 0; 21 return 0;
23 return enter.resource()->pp_instance(); 22 return enter.resource()->pp_instance();
24 } 23 }
25 24
26 int32_t OpenFile(PP_Resource file_ref_id, int32_t mode, PP_FileHandle* file) { 25 int32_t OpenFile(PP_Resource file_ref_id, int32_t mode, PP_FileHandle* file) {
27 // TODO(brettw): this function should take an instance. 26 // TODO(brettw): this function should take an instance.
28 // To work around this, use the PP_Instance from the resource. 27 // To work around this, use the PP_Instance from the resource.
29 PP_Instance instance = GetInstanceFromFileRef(file_ref_id); 28 PP_Instance instance = GetInstanceFromFileRef(file_ref_id);
30 EnterInstance enter(instance); 29 EnterInstanceAPI<PPB_Flash_File_API> enter(instance);
31 if (enter.failed()) 30 if (enter.failed())
32 return PP_ERROR_BADARGUMENT; 31 return PP_ERROR_BADARGUMENT;
33 return enter.functions()->GetFlashAPI()->OpenFileRef(instance, file_ref_id, 32 return enter.functions()->OpenFileRef(instance, file_ref_id, mode, file);
34 mode, file);
35 } 33 }
36 34
37 int32_t QueryFile(PP_Resource file_ref_id, struct PP_FileInfo* info) { 35 int32_t QueryFile(PP_Resource file_ref_id, struct PP_FileInfo* info) {
38 // TODO(brettw): this function should take an instance. 36 // TODO(brettw): this function should take an instance.
39 // To work around this, use the PP_Instance from the resource. 37 // To work around this, use the PP_Instance from the resource.
40 PP_Instance instance = GetInstanceFromFileRef(file_ref_id); 38 PP_Instance instance = GetInstanceFromFileRef(file_ref_id);
41 EnterInstance enter(instance); 39 EnterInstanceAPI<PPB_Flash_File_API> enter(instance);
42 if (enter.failed()) 40 if (enter.failed())
43 return PP_ERROR_BADARGUMENT; 41 return PP_ERROR_BADARGUMENT;
44 return enter.functions()->GetFlashAPI()->QueryFileRef(instance, file_ref_id, 42 return enter.functions()->QueryFileRef(instance, file_ref_id, info);
45 info);
46 } 43 }
47 44
48 const PPB_Flash_File_FileRef g_ppb_flash_file_fileref_thunk = { 45 const PPB_Flash_File_FileRef g_ppb_flash_file_fileref_thunk = {
49 &OpenFile, 46 &OpenFile,
50 &QueryFile 47 &QueryFile
51 }; 48 };
52 49
53 } // namespace 50 } // namespace
54 51
55 const PPB_Flash_File_FileRef* GetPPB_Flash_File_FileRef_Thunk() { 52 const PPB_Flash_File_FileRef* GetPPB_Flash_File_FileRef_Thunk() {
56 return &g_ppb_flash_file_fileref_thunk; 53 return &g_ppb_flash_file_fileref_thunk;
57 } 54 }
58 55
59 } // namespace thunk 56 } // namespace thunk
60 } // namespace ppapi 57 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/thunk/ppb_flash_file_api.h ('k') | ppapi/thunk/ppb_flash_file_modulelocal_thunk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698