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_IO_PEPPER_INTERFACE_H_ | 5 #ifndef LIBRARIES_NACL_IO_PEPPER_INTERFACE_H_ |
6 #define LIBRARIES_NACL_IO_PEPPER_INTERFACE_H_ | 6 #define LIBRARIES_NACL_IO_PEPPER_INTERFACE_H_ |
7 | 7 |
8 #include <ppapi/c/pp_bool.h> | 8 #include <ppapi/c/pp_bool.h> |
9 #include <ppapi/c/pp_completion_callback.h> | 9 #include <ppapi/c/pp_completion_callback.h> |
10 #include <ppapi/c/pp_errors.h> | 10 #include <ppapi/c/pp_errors.h> |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 // }; | 54 // }; |
55 // | 55 // |
56 // | 56 // |
57 // Note: To add a new interface: | 57 // Note: To add a new interface: |
58 // | 58 // |
59 // 1. Using one of the other interfaces as a template, add your interface to | 59 // 1. Using one of the other interfaces as a template, add your interface to |
60 // all_interfaces.h. | 60 // all_interfaces.h. |
61 // 2. Add the necessary pepper header to the top of this file. | 61 // 2. Add the necessary pepper header to the top of this file. |
62 // 3. Compile and cross your fingers! | 62 // 3. Compile and cross your fingers! |
63 | 63 |
64 | |
65 // Forward declare interface classes. | 64 // Forward declare interface classes. |
66 #include "nacl_io/pepper/undef_macros.h" | 65 #include "nacl_io/pepper/undef_macros.h" |
67 #include "nacl_io/pepper/define_empty_macros.h" | 66 #include "nacl_io/pepper/define_empty_macros.h" |
68 #undef BEGIN_INTERFACE | 67 #undef BEGIN_INTERFACE |
69 #define BEGIN_INTERFACE(BaseClass, PPInterface, InterfaceString) \ | 68 #define BEGIN_INTERFACE(BaseClass, PPInterface, InterfaceString) \ |
70 class BaseClass; | 69 class BaseClass; |
71 #include "nacl_io/pepper/all_interfaces.h" | 70 #include "nacl_io/pepper/all_interfaces.h" |
72 | 71 |
73 int PPErrorToErrno(int32_t err); | 72 int PPErrorToErrno(int32_t err); |
74 | 73 |
75 class PepperInterface { | 74 class PepperInterface { |
76 public: | 75 public: |
77 virtual ~PepperInterface() {} | 76 virtual ~PepperInterface() {} |
78 virtual PP_Instance GetInstance() = 0; | 77 virtual PP_Instance GetInstance() = 0; |
79 | 78 |
80 // Convenience functions. These forward to | 79 // Convenience functions. These forward to |
81 // GetCoreInterface()->{AddRef,Release}Resource. | 80 // GetCoreInterface()->{AddRef,Release}Resource. |
82 void AddRefResource(PP_Resource resource); | 81 void AddRefResource(PP_Resource resource); |
83 void ReleaseResource(PP_Resource resource); | 82 void ReleaseResource(PP_Resource resource); |
84 | 83 |
85 // Interface getters. | 84 // Interface getters. |
86 // | 85 // |
87 // These macros expand to definitions like: | 86 // These macros expand to definitions like: |
88 // | 87 // |
89 // CoreInterface* GetCoreInterface() = 0; | 88 // CoreInterface* GetCoreInterface() = 0; |
90 // | 89 // |
91 #include "nacl_io/pepper/undef_macros.h" | 90 #include "nacl_io/pepper/undef_macros.h" |
92 #include "nacl_io/pepper/define_empty_macros.h" | 91 #include "nacl_io/pepper/define_empty_macros.h" |
93 #undef BEGIN_INTERFACE | 92 #undef BEGIN_INTERFACE |
94 #define BEGIN_INTERFACE(BaseClass, PPInterface, InterfaceString) \ | 93 #define BEGIN_INTERFACE(BaseClass, PPInterface, InterfaceString) \ |
95 virtual BaseClass* Get##BaseClass() = 0; | 94 virtual BaseClass* Get##BaseClass() = 0; |
96 #include "nacl_io/pepper/all_interfaces.h" | 95 #include "nacl_io/pepper/all_interfaces.h" |
97 }; | 96 }; |
98 | 97 |
99 // Interface class definitions. | 98 // Interface class definitions. |
100 // | 99 // |
101 // Each class will be defined with all pure virtual methods, e.g: | 100 // Each class will be defined with all pure virtual methods, e.g: |
102 // | 101 // |
103 // class CoreInterface { | 102 // class CoreInterface { |
104 // public: | 103 // public: |
105 // virtual ~CoreInterface() {} | 104 // virtual ~CoreInterface() {} |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 private: | 149 private: |
151 PepperInterface* ppapi_; | 150 PepperInterface* ppapi_; |
152 PP_Resource resource_; | 151 PP_Resource resource_; |
153 | 152 |
154 DISALLOW_COPY_AND_ASSIGN(ScopedResource); | 153 DISALLOW_COPY_AND_ASSIGN(ScopedResource); |
155 }; | 154 }; |
156 | 155 |
157 } // namespace nacl_io | 156 } // namespace nacl_io |
158 | 157 |
159 #endif // LIBRARIES_NACL_IO_PEPPER_INTERFACE_H_ | 158 #endif // LIBRARIES_NACL_IO_PEPPER_INTERFACE_H_ |
OLD | NEW |