| OLD | NEW |
| (Empty) |
| 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 #ifndef PPAPI_SHARED_IMPL_PPB_FILE_REF_SHARED_H_ | |
| 6 #define PPAPI_SHARED_IMPL_PPB_FILE_REF_SHARED_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 | |
| 10 #include "base/compiler_specific.h" | |
| 11 #include "ppapi/shared_impl/resource.h" | |
| 12 #include "ppapi/thunk/ppb_file_ref_api.h" | |
| 13 | |
| 14 namespace ppapi { | |
| 15 | |
| 16 class StringVar; | |
| 17 | |
| 18 // FileRefs are created in a number of places and they include a number of | |
| 19 // return values. This struct encapsulates everything in one place. | |
| 20 struct PPB_FileRef_CreateInfo { | |
| 21 PPB_FileRef_CreateInfo() | |
| 22 : file_system_type(PP_FILESYSTEMTYPE_EXTERNAL), | |
| 23 file_system_plugin_resource(0) {} | |
| 24 | |
| 25 ppapi::HostResource resource; | |
| 26 int file_system_type; // One of PP_FileSystemType values. | |
| 27 std::string path; | |
| 28 std::string name; | |
| 29 | |
| 30 // Since FileRef needs to hold a FileSystem reference, we need to pass the | |
| 31 // resource in this CreateInfo. Note that this is a plugin resource as | |
| 32 // FileSystem is already in new design. | |
| 33 PP_Resource file_system_plugin_resource; | |
| 34 }; | |
| 35 | |
| 36 // This class provides the shared implementation of a FileRef. The functions | |
| 37 // that actually "do stuff" like Touch and MakeDirectory are implemented | |
| 38 // differently for the proxied and non-proxied derived classes. | |
| 39 class PPAPI_SHARED_EXPORT PPB_FileRef_Shared | |
| 40 : public Resource, | |
| 41 public thunk::PPB_FileRef_API { | |
| 42 public: | |
| 43 PPB_FileRef_Shared(ResourceObjectType type, | |
| 44 const PPB_FileRef_CreateInfo& info); | |
| 45 virtual ~PPB_FileRef_Shared(); | |
| 46 | |
| 47 // Resource overrides. | |
| 48 virtual thunk::PPB_FileRef_API* AsPPB_FileRef_API() OVERRIDE; | |
| 49 | |
| 50 // PPB_FileRef_API implementation (partial). | |
| 51 virtual PP_FileSystemType GetFileSystemType() const OVERRIDE; | |
| 52 virtual PP_Var GetName() const OVERRIDE; | |
| 53 virtual PP_Var GetPath() const OVERRIDE; | |
| 54 virtual const PPB_FileRef_CreateInfo& GetCreateInfo() const OVERRIDE; | |
| 55 virtual PP_Var GetAbsolutePath() = 0; | |
| 56 | |
| 57 private: | |
| 58 PPB_FileRef_CreateInfo create_info_; | |
| 59 | |
| 60 // Lazily initialized vars created from the create_info_. This is so we can | |
| 61 // return the identical string object every time they're requested. | |
| 62 mutable scoped_refptr<StringVar> name_var_; | |
| 63 mutable scoped_refptr<StringVar> path_var_; | |
| 64 | |
| 65 DISALLOW_IMPLICIT_CONSTRUCTORS(PPB_FileRef_Shared); | |
| 66 }; | |
| 67 | |
| 68 } // namespace ppapi | |
| 69 | |
| 70 #endif // PPAPI_SHARED_IMPL_PPB_FILE_REF_SHARED_H_ | |
| OLD | NEW |