Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Side by Side Diff: mojo/public/cpp/bindings/lib/array_internal.h

Issue 399313007: Mojo: Convert assert()s under mojo/public/cpp/bindings/... to MOJO_DCHECK()s. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
11 #include "mojo/public/cpp/bindings/lib/bindings_internal.h" 11 #include "mojo/public/cpp/bindings/lib/bindings_internal.h"
12 #include "mojo/public/cpp/bindings/lib/bindings_serialization.h" 12 #include "mojo/public/cpp/bindings/lib/bindings_serialization.h"
13 #include "mojo/public/cpp/bindings/lib/bounds_checker.h" 13 #include "mojo/public/cpp/bindings/lib/bounds_checker.h"
14 #include "mojo/public/cpp/bindings/lib/buffer.h" 14 #include "mojo/public/cpp/bindings/lib/buffer.h"
15 #include "mojo/public/cpp/bindings/lib/validation_errors.h" 15 #include "mojo/public/cpp/bindings/lib/validation_errors.h"
16 #include "mojo/public/cpp/environment/logging.h"
16 17
17 namespace mojo { 18 namespace mojo {
18 template <typename T> class Array; 19 template <typename T> class Array;
19 class String; 20 class String;
20 21
21 namespace internal { 22 namespace internal {
22 23
23 template <typename T> 24 template <typename T>
24 struct ArrayDataTraits { 25 struct ArrayDataTraits {
25 typedef T StorageType; 26 typedef T StorageType;
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 } 261 }
261 262
262 const Array_Data<T>* object = static_cast<const Array_Data<T>*>(data); 263 const Array_Data<T>* object = static_cast<const Array_Data<T>*>(data);
263 return Helper::ValidateElements(&object->header_, object->storage(), 264 return Helper::ValidateElements(&object->header_, object->storage(),
264 bounds_checker); 265 bounds_checker);
265 } 266 }
266 267
267 size_t size() const { return header_.num_elements; } 268 size_t size() const { return header_.num_elements; }
268 269
269 Ref at(size_t offset) { 270 Ref at(size_t offset) {
270 assert(offset < static_cast<size_t>(header_.num_elements)); 271 MOJO_DCHECK(offset < static_cast<size_t>(header_.num_elements));
271 return Traits::ToRef(storage(), offset); 272 return Traits::ToRef(storage(), offset);
272 } 273 }
273 274
274 ConstRef at(size_t offset) const { 275 ConstRef at(size_t offset) const {
275 assert(offset < static_cast<size_t>(header_.num_elements)); 276 MOJO_DCHECK(offset < static_cast<size_t>(header_.num_elements));
276 return Traits::ToConstRef(storage(), offset); 277 return Traits::ToConstRef(storage(), offset);
277 } 278 }
278 279
279 StorageType* storage() { 280 StorageType* storage() {
280 return reinterpret_cast<StorageType*>( 281 return reinterpret_cast<StorageType*>(
281 reinterpret_cast<char*>(this) + sizeof(*this)); 282 reinterpret_cast<char*>(this) + sizeof(*this));
282 } 283 }
283 284
284 const StorageType* storage() const { 285 const StorageType* storage() const {
285 return reinterpret_cast<const StorageType*>( 286 return reinterpret_cast<const StorageType*>(
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 }; 385 };
385 386
386 template <> struct WrapperTraits<String, false> { 387 template <> struct WrapperTraits<String, false> {
387 typedef String_Data* DataType; 388 typedef String_Data* DataType;
388 }; 389 };
389 390
390 } // namespace internal 391 } // namespace internal
391 } // namespace mojo 392 } // namespace mojo
392 393
393 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_INTERNAL_H_ 394 #endif // MOJO_PUBLIC_CPP_BINDINGS_LIB_ARRAY_INTERNAL_H_
OLDNEW
« no previous file with comments | « no previous file | mojo/public/cpp/bindings/lib/bindings_serialization.cc » ('j') | mojo/public/cpp/bindings/lib/bounds_checker.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698