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 PPAPI_SHARED_IMPL_ARRAY_WRITER_H_ | 5 #ifndef PPAPI_SHARED_IMPL_ARRAY_WRITER_H_ |
6 #define PPAPI_SHARED_IMPL_ARRAY_WRITER_H_ | 6 #define PPAPI_SHARED_IMPL_ARRAY_WRITER_H_ |
7 | 7 |
8 #include <string.h> | 8 #include <string.h> |
9 | 9 |
10 #include <vector> | 10 #include <vector> |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 | 67 |
68 if (input) | 68 if (input) |
69 memcpy(dest, input, sizeof(T) * count); | 69 memcpy(dest, input, sizeof(T) * count); |
70 return true; | 70 return true; |
71 } | 71 } |
72 | 72 |
73 // Copies the given array/vector of data to the plugin output array. See | 73 // Copies the given array/vector of data to the plugin output array. See |
74 // comment of StoreArray() for detail. | 74 // comment of StoreArray() for detail. |
75 template <typename T> | 75 template <typename T> |
76 bool StoreVector(const std::vector<T>& input) { | 76 bool StoreVector(const std::vector<T>& input) { |
77 return StoreArray(input.size() ? &input[0] : NULL, input.size()); | 77 return StoreArray(input.size() ? &input[0] : NULL, |
| 78 static_cast<uint32_t>(input.size())); |
78 } | 79 } |
79 | 80 |
80 // Stores the given vector of resources as PP_Resources to the output vector, | 81 // Stores the given vector of resources as PP_Resources to the output vector, |
81 // adding one reference to each. | 82 // adding one reference to each. |
82 // | 83 // |
83 // On failure this returns false, nothing will be copied, and the resource | 84 // On failure this returns false, nothing will be copied, and the resource |
84 // refcounts will be unchanged. In either case, the object will become | 85 // refcounts will be unchanged. In either case, the object will become |
85 // is_null() immediately after the call since one output function should only | 86 // is_null() immediately after the call since one output function should only |
86 // be issued once. | 87 // be issued once. |
87 // | 88 // |
(...skipping 21 matching lines...) Expand all Loading... |
109 | 110 |
110 private: | 111 private: |
111 PP_ArrayOutput pp_array_output_; | 112 PP_ArrayOutput pp_array_output_; |
112 | 113 |
113 DISALLOW_COPY_AND_ASSIGN(ArrayWriter); | 114 DISALLOW_COPY_AND_ASSIGN(ArrayWriter); |
114 }; | 115 }; |
115 | 116 |
116 } // namespace ppapi | 117 } // namespace ppapi |
117 | 118 |
118 #endif // PPAPI_SHARED_IMPL_ARRAY_WRITER_H_ | 119 #endif // PPAPI_SHARED_IMPL_ARRAY_WRITER_H_ |
OLD | NEW |