OLD | NEW |
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 #ifndef LIBRARIES_NACL_MOUNTS_PEPPER_INTERFACE_H_ | 5 #ifndef LIBRARIES_NACL_IO_PEPPER_INTERFACE_H_ |
6 #define LIBRARIES_NACL_MOUNTS_PEPPER_INTERFACE_H_ | 6 #define LIBRARIES_NACL_IO_PEPPER_INTERFACE_H_ |
7 | 7 |
8 #include <ppapi/c/dev/ppb_directory_reader_dev.h> | 8 #include <ppapi/c/dev/ppb_directory_reader_dev.h> |
9 #include <ppapi/c/pp_completion_callback.h> | 9 #include <ppapi/c/pp_completion_callback.h> |
10 #include <ppapi/c/pp_file_info.h> | 10 #include <ppapi/c/pp_file_info.h> |
11 #include <ppapi/c/pp_instance.h> | 11 #include <ppapi/c/pp_instance.h> |
12 #include <ppapi/c/pp_resource.h> | 12 #include <ppapi/c/pp_resource.h> |
13 #include <ppapi/c/pp_var.h> | 13 #include <ppapi/c/pp_var.h> |
14 #include <ppapi/c/ppb_console.h> | 14 #include <ppapi/c/ppb_console.h> |
15 #include <ppapi/c/ppb_file_io.h> | 15 #include <ppapi/c/ppb_file_io.h> |
16 #include <ppapi/c/ppb_file_ref.h> | 16 #include <ppapi/c/ppb_file_ref.h> |
17 #include <ppapi/c/ppb_file_system.h> | 17 #include <ppapi/c/ppb_file_system.h> |
18 #include <ppapi/c/ppb_messaging.h> | 18 #include <ppapi/c/ppb_messaging.h> |
19 #include <ppapi/c/ppb_messaging.h> | 19 #include <ppapi/c/ppb_messaging.h> |
20 #include <ppapi/c/ppb_url_loader.h> | 20 #include <ppapi/c/ppb_url_loader.h> |
21 #include <ppapi/c/ppb_url_request_info.h> | 21 #include <ppapi/c/ppb_url_request_info.h> |
22 #include <ppapi/c/ppb_url_response_info.h> | 22 #include <ppapi/c/ppb_url_response_info.h> |
23 #include <ppapi/c/ppb_var.h> | 23 #include <ppapi/c/ppb_var.h> |
24 | 24 |
25 #include <utils/macros.h> | 25 #include <utils/macros.h> |
26 | 26 |
27 // Note: To add a new interface: | 27 // Note: To add a new interface: |
28 // | 28 // |
29 // 1. Using one of the other interfaces as a template, add your interface to | 29 // 1. Using one of the other interfaces as a template, add your interface to |
30 // all_interfaces.h. | 30 // all_interfaces.h. |
31 // 2. Add the necessary pepper header to the top of this file. | 31 // 2. Add the necessary pepper header to the top of this file. |
32 // 3. Compile and cross your fingers! | 32 // 3. Compile and cross your fingers! |
33 | 33 |
34 | 34 |
35 // Forward declare interface classes. | 35 // Forward declare interface classes. |
36 #include "nacl_mounts/pepper/define_empty_macros.h" | 36 #include "nacl_io/pepper/define_empty_macros.h" |
37 #undef BEGIN_INTERFACE | 37 #undef BEGIN_INTERFACE |
38 #define BEGIN_INTERFACE(BaseClass, PPInterface, InterfaceString) \ | 38 #define BEGIN_INTERFACE(BaseClass, PPInterface, InterfaceString) \ |
39 class BaseClass; | 39 class BaseClass; |
40 #include "nacl_mounts/pepper/all_interfaces.h" | 40 #include "nacl_io/pepper/all_interfaces.h" |
41 #include "nacl_mounts/pepper/undef_macros.h" | 41 #include "nacl_io/pepper/undef_macros.h" |
42 | 42 |
43 int PPErrorToErrno(int32_t err); | 43 int PPErrorToErrno(int32_t err); |
44 | 44 |
45 class PepperInterface { | 45 class PepperInterface { |
46 public: | 46 public: |
47 virtual ~PepperInterface() {} | 47 virtual ~PepperInterface() {} |
48 virtual PP_Instance GetInstance() = 0; | 48 virtual PP_Instance GetInstance() = 0; |
49 virtual void AddRefResource(PP_Resource) = 0; | 49 virtual void AddRefResource(PP_Resource) = 0; |
50 virtual void ReleaseResource(PP_Resource) = 0; | 50 virtual void ReleaseResource(PP_Resource) = 0; |
51 | 51 |
52 // Interface getters. | 52 // Interface getters. |
53 #include "nacl_mounts/pepper/define_empty_macros.h" | 53 #include "nacl_io/pepper/define_empty_macros.h" |
54 #undef BEGIN_INTERFACE | 54 #undef BEGIN_INTERFACE |
55 #define BEGIN_INTERFACE(BaseClass, PPInterface, InterfaceString) \ | 55 #define BEGIN_INTERFACE(BaseClass, PPInterface, InterfaceString) \ |
56 virtual BaseClass* Get##BaseClass() = 0; | 56 virtual BaseClass* Get##BaseClass() = 0; |
57 #include "nacl_mounts/pepper/all_interfaces.h" | 57 #include "nacl_io/pepper/all_interfaces.h" |
58 #include "nacl_mounts/pepper/undef_macros.h" | 58 #include "nacl_io/pepper/undef_macros.h" |
59 }; | 59 }; |
60 | 60 |
61 // Interface class definitions. | 61 // Interface class definitions. |
62 #define BEGIN_INTERFACE(BaseClass, PPInterface, InterfaceString) \ | 62 #define BEGIN_INTERFACE(BaseClass, PPInterface, InterfaceString) \ |
63 class BaseClass { \ | 63 class BaseClass { \ |
64 public: \ | 64 public: \ |
65 virtual ~BaseClass() {} | 65 virtual ~BaseClass() {} |
66 #define END_INTERFACE(BaseClass, PPInterface) \ | 66 #define END_INTERFACE(BaseClass, PPInterface) \ |
67 }; | 67 }; |
68 #define METHOD1(Class, ReturnType, MethodName, Type0) \ | 68 #define METHOD1(Class, ReturnType, MethodName, Type0) \ |
69 virtual ReturnType MethodName(Type0) = 0; | 69 virtual ReturnType MethodName(Type0) = 0; |
70 #define METHOD2(Class, ReturnType, MethodName, Type0, Type1) \ | 70 #define METHOD2(Class, ReturnType, MethodName, Type0, Type1) \ |
71 virtual ReturnType MethodName(Type0, Type1) = 0; | 71 virtual ReturnType MethodName(Type0, Type1) = 0; |
72 #define METHOD3(Class, ReturnType, MethodName, Type0, Type1, Type2) \ | 72 #define METHOD3(Class, ReturnType, MethodName, Type0, Type1, Type2) \ |
73 virtual ReturnType MethodName(Type0, Type1, Type2) = 0; | 73 virtual ReturnType MethodName(Type0, Type1, Type2) = 0; |
74 #define METHOD4(Class, ReturnType, MethodName, Type0, Type1, Type2, Type3) \ | 74 #define METHOD4(Class, ReturnType, MethodName, Type0, Type1, Type2, Type3) \ |
75 virtual ReturnType MethodName(Type0, Type1, Type2, Type3) = 0; | 75 virtual ReturnType MethodName(Type0, Type1, Type2, Type3) = 0; |
76 #define METHOD5(Class, ReturnType, MethodName, Type0, Type1, Type2, Type3, \ | 76 #define METHOD5(Class, ReturnType, MethodName, Type0, Type1, Type2, Type3, \ |
77 Type4) \ | 77 Type4) \ |
78 virtual ReturnType MethodName(Type0, Type1, Type2, Type3, Type4) = 0; | 78 virtual ReturnType MethodName(Type0, Type1, Type2, Type3, Type4) = 0; |
79 #include "nacl_mounts/pepper/all_interfaces.h" | 79 #include "nacl_io/pepper/all_interfaces.h" |
80 #include "nacl_mounts/pepper/undef_macros.h" | 80 #include "nacl_io/pepper/undef_macros.h" |
81 | 81 |
82 | 82 |
83 class ScopedResource { | 83 class ScopedResource { |
84 public: | 84 public: |
85 // Does not AddRef by default. | 85 // Does not AddRef by default. |
86 ScopedResource(PepperInterface* ppapi, PP_Resource resource); | 86 ScopedResource(PepperInterface* ppapi, PP_Resource resource); |
87 ~ScopedResource(); | 87 ~ScopedResource(); |
88 | 88 |
89 PP_Resource pp_resource() { return resource_; } | 89 PP_Resource pp_resource() { return resource_; } |
90 | 90 |
91 // Return the resource without decrementing its refcount. | 91 // Return the resource without decrementing its refcount. |
92 PP_Resource Release(); | 92 PP_Resource Release(); |
93 | 93 |
94 private: | 94 private: |
95 PepperInterface* ppapi_; | 95 PepperInterface* ppapi_; |
96 PP_Resource resource_; | 96 PP_Resource resource_; |
97 | 97 |
98 DISALLOW_COPY_AND_ASSIGN(ScopedResource); | 98 DISALLOW_COPY_AND_ASSIGN(ScopedResource); |
99 }; | 99 }; |
100 | 100 |
101 #endif // LIBRARIES_NACL_MOUNTS_PEPPER_INTERFACE_H_ | 101 #endif // LIBRARIES_NACL_IO_PEPPER_INTERFACE_H_ |
OLD | NEW |