• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 // From ppb_file_system.idl modified Tue Aug 20 08:13:36 2013.
6 
7 #include "ppapi/c/pp_completion_callback.h"
8 #include "ppapi/c/pp_errors.h"
9 #include "ppapi/c/ppb_file_system.h"
10 #include "ppapi/shared_impl/tracked_callback.h"
11 #include "ppapi/thunk/enter.h"
12 #include "ppapi/thunk/ppapi_thunk_export.h"
13 #include "ppapi/thunk/ppb_file_system_api.h"
14 
15 namespace ppapi {
16 namespace thunk {
17 
18 namespace {
19 
Create(PP_Instance instance,PP_FileSystemType type)20 PP_Resource Create(PP_Instance instance, PP_FileSystemType type) {
21   VLOG(4) << "PPB_FileSystem::Create()";
22   EnterResourceCreation enter(instance);
23   if (enter.failed())
24     return 0;
25   return enter.functions()->CreateFileSystem(instance, type);
26 }
27 
IsFileSystem(PP_Resource resource)28 PP_Bool IsFileSystem(PP_Resource resource) {
29   VLOG(4) << "PPB_FileSystem::IsFileSystem()";
30   EnterResource<PPB_FileSystem_API> enter(resource, false);
31   return PP_FromBool(enter.succeeded());
32 }
33 
Open(PP_Resource file_system,int64_t expected_size,struct PP_CompletionCallback callback)34 int32_t Open(PP_Resource file_system,
35              int64_t expected_size,
36              struct PP_CompletionCallback callback) {
37   VLOG(4) << "PPB_FileSystem::Open()";
38   EnterResource<PPB_FileSystem_API> enter(file_system, callback, true);
39   if (enter.failed())
40     return enter.retval();
41   return enter.SetResult(enter.object()->Open(expected_size, enter.callback()));
42 }
43 
GetType(PP_Resource file_system)44 PP_FileSystemType GetType(PP_Resource file_system) {
45   VLOG(4) << "PPB_FileSystem::GetType()";
46   EnterResource<PPB_FileSystem_API> enter(file_system, true);
47   if (enter.failed())
48     return PP_FILESYSTEMTYPE_INVALID;
49   return enter.object()->GetType();
50 }
51 
52 const PPB_FileSystem_1_0 g_ppb_filesystem_thunk_1_0 = {
53   &Create,
54   &IsFileSystem,
55   &Open,
56   &GetType
57 };
58 
59 }  // namespace
60 
GetPPB_FileSystem_1_0_Thunk()61 PPAPI_THUNK_EXPORT const PPB_FileSystem_1_0* GetPPB_FileSystem_1_0_Thunk() {
62   return &g_ppb_filesystem_thunk_1_0;
63 }
64 
65 }  // namespace thunk
66 }  // namespace ppapi
67