| OLD | NEW |
| 1 // Copyright (c) 2006-2008 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 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 25 // what value types to read and in what order to read them as the Pickle does | 25 // what value types to read and in what order to read them as the Pickle does |
| 26 // not keep track of the type of data written to it. | 26 // not keep track of the type of data written to it. |
| 27 // | 27 // |
| 28 // The Pickle's data has a header which contains the size of the Pickle's | 28 // The Pickle's data has a header which contains the size of the Pickle's |
| 29 // payload. It can optionally support additional space in the header. That | 29 // payload. It can optionally support additional space in the header. That |
| 30 // space is controlled by the header_size parameter passed to the Pickle | 30 // space is controlled by the header_size parameter passed to the Pickle |
| 31 // constructor. | 31 // constructor. |
| 32 // | 32 // |
| 33 class Pickle { | 33 class Pickle { |
| 34 public: | 34 public: |
| 35 virtual ~Pickle(); | |
| 36 | |
| 37 // Initialize a Pickle object using the default header size. | 35 // Initialize a Pickle object using the default header size. |
| 38 Pickle(); | 36 Pickle(); |
| 39 | 37 |
| 40 // Initialize a Pickle object with the specified header size in bytes, which | 38 // Initialize a Pickle object with the specified header size in bytes, which |
| 41 // must be greater-than-or-equal-to sizeof(Pickle::Header). The header size | 39 // must be greater-than-or-equal-to sizeof(Pickle::Header). The header size |
| 42 // will be rounded up to ensure that the header size is 32bit-aligned. | 40 // will be rounded up to ensure that the header size is 32bit-aligned. |
| 43 explicit Pickle(int header_size); | 41 explicit Pickle(int header_size); |
| 44 | 42 |
| 45 // Initializes a Pickle from a const block of data. The data is not copied; | 43 // Initializes a Pickle from a const block of data. The data is not copied; |
| 46 // instead the data is merely referenced by this Pickle. Only const methods | 44 // instead the data is merely referenced by this Pickle. Only const methods |
| 47 // should be used on the Pickle when initialized this way. The header | 45 // should be used on the Pickle when initialized this way. The header |
| 48 // padding size is deduced from the data length. | 46 // padding size is deduced from the data length. |
| 49 Pickle(const char* data, int data_len); | 47 Pickle(const char* data, int data_len); |
| 50 | 48 |
| 51 // Initializes a Pickle as a deep copy of another Pickle. | 49 // Initializes a Pickle as a deep copy of another Pickle. |
| 52 Pickle(const Pickle& other); | 50 Pickle(const Pickle& other); |
| 53 | 51 |
| 52 virtual ~Pickle(); |
| 53 |
| 54 // Performs a deep copy. | 54 // Performs a deep copy. |
| 55 Pickle& operator=(const Pickle& other); | 55 Pickle& operator=(const Pickle& other); |
| 56 | 56 |
| 57 // Returns the size of the Pickle's data. | 57 // Returns the size of the Pickle's data. |
| 58 int size() const { return static_cast<int>(header_size_ + | 58 int size() const { return static_cast<int>(header_size_ + |
| 59 header_->payload_size); } | 59 header_->payload_size); } |
| 60 | 60 |
| 61 // Returns the data for this Pickle. | 61 // Returns the data for this Pickle. |
| 62 const void* data() const { return header_; } | 62 const void* data() const { return header_; } |
| 63 | 63 |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 // Allocation size of payload (or -1 if allocation is const). | 233 // Allocation size of payload (or -1 if allocation is const). |
| 234 size_t capacity_; | 234 size_t capacity_; |
| 235 size_t variable_buffer_offset_; // IF non-zero, then offset to a buffer. | 235 size_t variable_buffer_offset_; // IF non-zero, then offset to a buffer. |
| 236 | 236 |
| 237 FRIEND_TEST_ALL_PREFIXES(PickleTest, Resize); | 237 FRIEND_TEST_ALL_PREFIXES(PickleTest, Resize); |
| 238 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNext); | 238 FRIEND_TEST_ALL_PREFIXES(PickleTest, FindNext); |
| 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__ |
| OLD | NEW |