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

Side by Side Diff: base/pickle.h

Issue 6469070: More DCHECK() updates. A mixture of _EQ and _GE. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Updating to follow EXPECTED, ACTUAL pattern on DCHECK_EQ() Created 9 years, 9 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
« no previous file with comments | « base/message_pump_win.cc ('k') | base/platform_file_posix.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 BASE_PICKLE_H__ 5 #ifndef BASE_PICKLE_H__
6 #define BASE_PICKLE_H__ 6 #define BASE_PICKLE_H__
7 #pragma once 7 #pragma once
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 // Payload follows after allocation of Header (header size is customizable). 136 // Payload follows after allocation of Header (header size is customizable).
137 struct Header { 137 struct Header {
138 uint32 payload_size; // Specifies the size of the payload. 138 uint32 payload_size; // Specifies the size of the payload.
139 }; 139 };
140 140
141 // Returns the header, cast to a user-specified type T. The type T must be a 141 // Returns the header, cast to a user-specified type T. The type T must be a
142 // subclass of Header and its size must correspond to the header_size passed 142 // subclass of Header and its size must correspond to the header_size passed
143 // to the Pickle constructor. 143 // to the Pickle constructor.
144 template <class T> 144 template <class T>
145 T* headerT() { 145 T* headerT() {
146 DCHECK(sizeof(T) == header_size_); 146 DCHECK_EQ(sizeof(T), header_size_);
Peter Kasting 2011/02/28 21:42:13 Nit: I think the order here should be reversed
KushalP 2011/02/28 21:54:06 Done.
147 return static_cast<T*>(header_); 147 return static_cast<T*>(header_);
148 } 148 }
149 template <class T> 149 template <class T>
150 const T* headerT() const { 150 const T* headerT() const {
151 DCHECK(sizeof(T) == header_size_); 151 DCHECK_EQ(sizeof(T), header_size_);
152 return static_cast<const T*>(header_); 152 return static_cast<const T*>(header_);
153 } 153 }
154 154
155 // Returns true if the given iterator could point to data with the given 155 // Returns true if the given iterator could point to data with the given
156 // length. If there is no room for the given data before the end of the 156 // length. If there is no room for the given data before the end of the
157 // payload, returns false. 157 // payload, returns false.
158 bool IteratorHasRoomFor(const void* iter, int len) const { 158 bool IteratorHasRoomFor(const void* iter, int len) const {
159 if ((len < 0) || (iter < header_) || iter > end_of_payload()) 159 if ((len < 0) || (iter < header_) || iter > end_of_payload())
160 return false; 160 return false;
161 const char* end_of_region = reinterpret_cast<const char*>(iter) + len; 161 const char* end_of_region = reinterpret_cast<const char*>(iter) + len;
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 size_t capacity_; 233 size_t capacity_;
234 size_t variable_buffer_offset_; // IF non-zero, then offset to a buffer. 234 size_t variable_buffer_offset_; // IF non-zero, then offset to a buffer.
235 235
236 FRIEND_TEST_ALL_PREFIXES(PickleTest, Resize); 236 FRIEND_TEST_ALL_PREFIXES(PickleTest, Resize);
237 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNext); 237 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNext);
238 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNextWithIncompleteHeader); 238 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNextWithIncompleteHeader);
239 FRIEND_TEST_ALL_PREFIXES(PickleTest, IteratorHasRoom); 239 FRIEND_TEST_ALL_PREFIXES(PickleTest, IteratorHasRoom);
240 }; 240 };
241 241
242 #endif // BASE_PICKLE_H__ 242 #endif // BASE_PICKLE_H__
OLDNEW
« no previous file with comments | « base/message_pump_win.cc ('k') | base/platform_file_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698