OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_INTERNAL_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_INTERNAL_H_ |
6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_INTERNAL_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_INTERNAL_H_ |
7 | 7 |
8 #include <new> | 8 #include <new> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 | 325 |
326 template <typename T> | 326 template <typename T> |
327 class Array_Data { | 327 class Array_Data { |
328 public: | 328 public: |
329 typedef ArrayDataTraits<T> Traits; | 329 typedef ArrayDataTraits<T> Traits; |
330 typedef typename Traits::StorageType StorageType; | 330 typedef typename Traits::StorageType StorageType; |
331 typedef typename Traits::Ref Ref; | 331 typedef typename Traits::Ref Ref; |
332 typedef typename Traits::ConstRef ConstRef; | 332 typedef typename Traits::ConstRef ConstRef; |
333 typedef ArraySerializationHelper<T, IsHandle<T>::value> Helper; | 333 typedef ArraySerializationHelper<T, IsHandle<T>::value> Helper; |
334 | 334 |
335 // Returns NULL if |num_elements| or the corresponding storage size cannot be | 335 // Returns null if |num_elements| or the corresponding storage size cannot be |
336 // stored in uint32_t. | 336 // stored in uint32_t. |
337 static Array_Data<T>* New(size_t num_elements, Buffer* buf) { | 337 static Array_Data<T>* New(size_t num_elements, Buffer* buf) { |
338 if (num_elements > Traits::kMaxNumElements) | 338 if (num_elements > Traits::kMaxNumElements) |
339 return NULL; | 339 return nullptr; |
340 | 340 |
341 uint32_t num_bytes = | 341 uint32_t num_bytes = |
342 Traits::GetStorageSize(static_cast<uint32_t>(num_elements)); | 342 Traits::GetStorageSize(static_cast<uint32_t>(num_elements)); |
343 return new (buf->Allocate(num_bytes)) Array_Data<T>( | 343 return new (buf->Allocate(num_bytes)) Array_Data<T>( |
344 num_bytes, static_cast<uint32_t>(num_elements)); | 344 num_bytes, static_cast<uint32_t>(num_elements)); |
345 } | 345 } |
346 | 346 |
347 template <typename Params> | 347 template <typename Params> |
348 static bool Validate(const void* data, BoundsChecker* bounds_checker) { | 348 static bool Validate(const void* data, BoundsChecker* bounds_checker) { |
349 if (!data) | 349 if (!data) |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 }; | 502 }; |
503 | 503 |
504 template <> struct WrapperTraits<String, false> { | 504 template <> struct WrapperTraits<String, false> { |
505 typedef String_Data* DataType; | 505 typedef String_Data* DataType; |
506 }; | 506 }; |
507 | 507 |
508 } // namespace internal | 508 } // namespace internal |
509 } // namespace mojo | 509 } // namespace mojo |
510 | 510 |
511 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_INTERNAL_H_ | 511 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_INTERNAL_H_ |
OLD | NEW |