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

Side by Side Diff: third_party/WebKit/Source/platform/SharedBuffer.h

Issue 2530323002: Replace boolean return value SharedBuffer::getAsBytes with DCHECK (Closed)
Patch Set: done Created 4 years 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
3 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. 3 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // } 106 // }
107 HAS_STRICTLY_TYPED_ARG 107 HAS_STRICTLY_TYPED_ARG
108 size_t getSomeData( 108 size_t getSomeData(
109 const char*& data, 109 const char*& data,
110 STRICTLY_TYPED_ARG(position) = static_cast<size_t>(0)) const { 110 STRICTLY_TYPED_ARG(position) = static_cast<size_t>(0)) const {
111 STRICT_ARG_TYPE(size_t); 111 STRICT_ARG_TYPE(size_t);
112 return getSomeDataInternal(data, position); 112 return getSomeDataInternal(data, position);
113 } 113 }
114 114
115 // Returns the content data into "dest" as a flat buffer. "byteLength" must 115 // Returns the content data into "dest" as a flat buffer. "byteLength" must
116 // exactly match with size(). Returns true on success, otherwise the content 116 // exactly match with size(). |dest| must not be null even if |bytesLength|
117 // of "dest" is not guaranteed. 117 // is 0.
118 HAS_STRICTLY_TYPED_ARG 118 HAS_STRICTLY_TYPED_ARG
119 bool getAsBytes(void* dest, STRICTLY_TYPED_ARG(byteLength)) const { 119 void getAsBytes(void* dest, STRICTLY_TYPED_ARG(byteLength)) const {
120 STRICT_ARG_TYPE(size_t); 120 STRICT_ARG_TYPE(size_t);
121 if (byteLength != size()) 121 DCHECK_EQ(byteLength, size());
122 return false; 122 auto result = getAsBytesInternal(dest, 0, byteLength);
123 123 DCHECK(result);
124 return getAsBytesInternal(dest, 0, byteLength);
125 } 124 }
126 125
127 // Copies "byteLength" bytes from "position"-th bytes (0 origin) of the 126 // Copies "byteLength" bytes from "position"-th bytes (0 origin) of the
128 // content data into "dest" as a flat buffer, Returns true on success, 127 // content data into "dest" as a flat buffer, Returns true on success,
129 // otherwise the content of "dest" is not guaranteed. 128 // otherwise the content of "dest" is not guaranteed.
130 HAS_STRICTLY_TYPED_ARG 129 HAS_STRICTLY_TYPED_ARG
131 bool getPartAsBytes(void* dest, 130 bool getPartAsBytes(void* dest,
132 STRICTLY_TYPED_ARG(position), 131 STRICTLY_TYPED_ARG(position),
133 STRICTLY_TYPED_ARG(byteLength)) const { 132 STRICTLY_TYPED_ARG(byteLength)) const {
134 STRICT_ARG_TYPE(size_t); 133 STRICT_ARG_TYPE(size_t);
(...skipping 20 matching lines...) Expand all
155 size_t getSomeDataInternal(const char*& data, size_t position) const; 154 size_t getSomeDataInternal(const char*& data, size_t position) const;
156 155
157 size_t m_size; 156 size_t m_size;
158 mutable Vector<char> m_buffer; 157 mutable Vector<char> m_buffer;
159 mutable Vector<char*> m_segments; 158 mutable Vector<char*> m_segments;
160 }; 159 };
161 160
162 } // namespace blink 161 } // namespace blink
163 162
164 #endif // SharedBuffer_h 163 #endif // SharedBuffer_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698