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

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

Issue 293983026: Mojo cpp bindings: remove redundant validation in Decode*(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 #include "mojo/public/cpp/bindings/lib/array_internal.h" 5 #include "mojo/public/cpp/bindings/lib/array_internal.h"
6 6
7 namespace mojo { 7 namespace mojo {
8 namespace internal { 8 namespace internal {
9 9
10 ArrayDataTraits<bool>::BitRef::~BitRef() { 10 ArrayDataTraits<bool>::BitRef::~BitRef() {
(...skipping 26 matching lines...) Expand all
37 // static 37 // static
38 void ArraySerializationHelper<Handle, true>::EncodePointersAndHandles( 38 void ArraySerializationHelper<Handle, true>::EncodePointersAndHandles(
39 const ArrayHeader* header, 39 const ArrayHeader* header,
40 ElementType* elements, 40 ElementType* elements,
41 std::vector<Handle>* handles) { 41 std::vector<Handle>* handles) {
42 for (uint32_t i = 0; i < header->num_elements; ++i) 42 for (uint32_t i = 0; i < header->num_elements; ++i)
43 EncodeHandle(&elements[i], handles); 43 EncodeHandle(&elements[i], handles);
44 } 44 }
45 45
46 // static 46 // static
47 bool ArraySerializationHelper<Handle, true>::DecodePointersAndHandles( 47 void ArraySerializationHelper<Handle, true>::DecodePointersAndHandles(
48 const ArrayHeader* header, 48 const ArrayHeader* header,
49 ElementType* elements, 49 ElementType* elements,
50 Message* message) { 50 std::vector<Handle>* handles) {
51 for (uint32_t i = 0; i < header->num_elements; ++i) { 51 for (uint32_t i = 0; i < header->num_elements; ++i)
52 if (!DecodeHandle(&elements[i], message->mutable_handles())) 52 DecodeHandle(&elements[i], handles);
53 return false;
54 }
55 return true;
56 } 53 }
57 54
58 // static 55 // static
59 bool ArraySerializationHelper<Handle, true>::ValidateElements( 56 bool ArraySerializationHelper<Handle, true>::ValidateElements(
60 const ArrayHeader* header, 57 const ArrayHeader* header,
61 const ElementType* elements, 58 const ElementType* elements,
62 BoundsChecker* bounds_checker) { 59 BoundsChecker* bounds_checker) {
63 for (uint32_t i = 0; i < header->num_elements; ++i) { 60 for (uint32_t i = 0; i < header->num_elements; ++i) {
64 if (!bounds_checker->ClaimHandle(elements[i])) 61 if (!bounds_checker->ClaimHandle(elements[i]))
65 return false; 62 return false;
66 } 63 }
67 return true; 64 return true;
68 } 65 }
69 66
70 } // namespace internal 67 } // namespace internal
71 } // namespace mojo 68 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/array_internal.h ('k') | mojo/public/cpp/bindings/lib/bindings_serialization.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698