| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 PPAPI_CPP_EXTENSIONS_OUTPUT_TRAITS_H_ | 5 #ifndef PPAPI_CPP_EXTENSIONS_OUTPUT_TRAITS_H_ |
| 6 #define PPAPI_CPP_EXTENSIONS_OUTPUT_TRAITS_H_ | 6 #define PPAPI_CPP_EXTENSIONS_OUTPUT_TRAITS_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "ppapi/c/pp_var.h" | 10 #include "ppapi/c/pp_var.h" |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 } | 69 } |
| 70 | 70 |
| 71 // This must be called exactly once to consume the one PP_Var reference | 71 // This must be called exactly once to consume the one PP_Var reference |
| 72 // assigned to us by the browser. | 72 // assigned to us by the browser. |
| 73 static inline T& StorageToPluginArg(StorageType& t) { | 73 static inline T& StorageToPluginArg(StorageType& t) { |
| 74 return t.output(); | 74 return t.output(); |
| 75 } | 75 } |
| 76 }; | 76 }; |
| 77 | 77 |
| 78 // This class provides storage for a PP_Var and a vector of objects which are | 78 // This class provides storage for a PP_Var and a vector of objects which are |
| 79 // of type T. The PP_Var is used as an output parameter to recevie an array var | 79 // of type T. The PP_Var is used as an output parameter to receive an array var |
| 80 // from the browser. Each element in the array var is converted to a T object, | 80 // from the browser. Each element in the array var is converted to a T object, |
| 81 // using FromVarConverter, and stores in the vector. | 81 // using FromVarConverter, and stores in the vector. |
| 82 template <class T> | 82 template <class T> |
| 83 class ArrayVarOutputAdapterWithStorage { | 83 class ArrayVarOutputAdapterWithStorage { |
| 84 public: | 84 public: |
| 85 ArrayVarOutputAdapterWithStorage() : pp_var_(PP_MakeUndefined()) { | 85 ArrayVarOutputAdapterWithStorage() : pp_var_(PP_MakeUndefined()) { |
| 86 } | 86 } |
| 87 | 87 |
| 88 ~ArrayVarOutputAdapterWithStorage() { | 88 ~ArrayVarOutputAdapterWithStorage() { |
| 89 PP_DCHECK(pp_var_.type == PP_VARTYPE_UNDEFINED); | 89 PP_DCHECK(pp_var_.type == PP_VARTYPE_UNDEFINED); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 static inline std::vector<T>& StorageToPluginArg(StorageType& t) { | 134 static inline std::vector<T>& StorageToPluginArg(StorageType& t) { |
| 135 return t.output(); | 135 return t.output(); |
| 136 } | 136 } |
| 137 }; | 137 }; |
| 138 | 138 |
| 139 } // namespace internal | 139 } // namespace internal |
| 140 } // namespace ext | 140 } // namespace ext |
| 141 } // namespace pp | 141 } // namespace pp |
| 142 | 142 |
| 143 #endif // PPAPI_CPP_EXTENSIONS_OUTPUT_TRAITS_H_ | 143 #endif // PPAPI_CPP_EXTENSIONS_OUTPUT_TRAITS_H_ |
| OLD | NEW |