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

Unified Diff: base/pickle.h

Issue 290173008: Refactor PickleIterator. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/pickle.cc » ('j') | base/pickle.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/pickle.h
===================================================================
--- base/pickle.h (revision 271871)
+++ base/pickle.h (working copy)
@@ -20,7 +20,7 @@
// while the PickleIterator object is in use.
class BASE_EXPORT PickleIterator {
public:
- PickleIterator() : read_ptr_(NULL), read_end_ptr_(NULL) {}
+ PickleIterator() : payload_ptr_(NULL), read_index_(0), end_index_(0) {}
explicit PickleIterator(const Pickle& pickle);
// Methods for reading the payload of the Pickle. To read from the start of
@@ -63,6 +63,9 @@
template <typename Type>
inline bool ReadBuiltinType(Type* result);
+ // Advance read_index_ but do not allow it to exceed end_index_.
+ inline void Advance(size_t size);
+
// Get read pointer for Type and advance read pointer.
template<typename Type>
inline const char* GetReadPointerAndAdvance();
@@ -77,8 +80,9 @@
size_t size_element);
// Pointers to the Pickle data.
- const char* read_ptr_;
- const char* read_end_ptr_;
+ const char* payload_ptr_;
+ size_t read_index_;
+ size_t end_index_;
FRIEND_TEST_ALL_PREFIXES(PickleTest, GetReadPointerAndAdvance);
};
@@ -277,7 +281,9 @@
}
// The payload is the pickle data immediately following the header.
- size_t payload_size() const { return header_->payload_size; }
+ size_t payload_size() const {
+ return header_ ? header_->payload_size : 0;
+ }
const char* payload() const {
return reinterpret_cast<const char*>(header_) + header_size_;
« no previous file with comments | « no previous file | base/pickle.cc » ('j') | base/pickle.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698