| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef PPAPI_SHARED_IMPL_FILE_REF_IMPL_H_ | |
| 6 #define PPAPI_SHARED_IMPL_FILE_REF_IMPL_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() : file_system_type(PP_FILESYSTEMTYPE_EXTERNAL) {} | |
| 22 | |
| 23 ppapi::HostResource resource; | |
| 24 int file_system_type; // One of PP_FileSystemType values. | |
| 25 std::string path; | |
| 26 std::string name; | |
| 27 }; | |
| 28 | |
| 29 // This class provides the shared implementation of a FileRef. The functions | |
| 30 // that actually "do stuff" like Touch and MakeDirectory are implemented | |
| 31 // differently for the proxied and non-proxied derived classes. | |
| 32 class PPAPI_SHARED_EXPORT FileRefImpl : public Resource, | |
| 33 public thunk::PPB_FileRef_API { | |
| 34 public: | |
| 35 struct InitAsImpl {}; | |
| 36 struct InitAsProxy {}; | |
| 37 | |
| 38 FileRefImpl(const InitAsImpl&, const PPB_FileRef_CreateInfo& info); | |
| 39 FileRefImpl(const InitAsProxy&, const PPB_FileRef_CreateInfo& info); | |
| 40 virtual ~FileRefImpl(); | |
| 41 | |
| 42 // Resource overrides. | |
| 43 virtual thunk::PPB_FileRef_API* AsPPB_FileRef_API() OVERRIDE; | |
| 44 | |
| 45 // PPB_FileRef_API implementation (partial). | |
| 46 virtual PP_FileSystemType GetFileSystemType() const OVERRIDE; | |
| 47 virtual PP_Var GetName() const OVERRIDE; | |
| 48 virtual PP_Var GetPath() const OVERRIDE; | |
| 49 virtual const PPB_FileRef_CreateInfo& GetCreateInfo() const OVERRIDE; | |
| 50 virtual PP_Var GetAbsolutePath() = 0; | |
| 51 | |
| 52 private: | |
| 53 PPB_FileRef_CreateInfo create_info_; | |
| 54 | |
| 55 // Lazily initialized vars created from the create_info_. This is so we can | |
| 56 // return the identical string object every time they're requested. | |
| 57 mutable scoped_refptr<StringVar> name_var_; | |
| 58 mutable scoped_refptr<StringVar> path_var_; | |
| 59 | |
| 60 DISALLOW_IMPLICIT_CONSTRUCTORS(FileRefImpl); | |
| 61 }; | |
| 62 | |
| 63 } // namespace ppapi | |
| 64 | |
| 65 #endif // PPAPI_SHARED_IMPL_FILE_REF_IMPL_H_ | |
| OLD | NEW |