Chromium Code Reviews| Index: base/pickle.h |
| diff --git a/base/pickle.h b/base/pickle.h |
| index 02bc432ad0bd27564e289f9d8fae0b9ca9408241..cef482534e27d532a4465306e56a77bcca3e55a1 100644 |
| --- a/base/pickle.h |
| +++ b/base/pickle.h |
| @@ -14,6 +14,7 @@ |
| #include "base/compiler_specific.h" |
| #include "base/gtest_prod_util.h" |
| #include "base/logging.h" |
| +#include "base/memory/ref_counted.h" |
| #include "base/strings/string16.h" |
| #include "base/strings/string_piece.h" |
| @@ -123,6 +124,18 @@ class BASE_EXPORT PickleIterator { |
| // |
| class BASE_EXPORT Pickle { |
| public: |
| + // |
|
jam
2016/02/02 18:00:45
nit: add comment
|
| + class BASE_EXPORT Attachment : public RefCountedThreadSafe<Attachment> { |
| + public: |
| + Attachment(); |
| + |
| + protected: |
| + friend class RefCountedThreadSafe<Attachment>; |
| + virtual ~Attachment(); |
| + |
| + DISALLOW_COPY_AND_ASSIGN(Attachment); |
| + }; |
| + |
| // Initialize a Pickle object using the default header size. |
| Pickle(); |
| @@ -206,6 +219,23 @@ class BASE_EXPORT Pickle { |
| // known size. See also WriteData. |
| bool WriteBytes(const void* data, int length); |
| + // WriteAttachment appends |attachment| to the pickle. It returns |
| + // false iff the set is full. |
| + // |
| + // NOTE: It is NOT OK to call this or ReadAttachment() on a simple |
| + // base::Pickle. These must be implemented and called only on subclasses that |
| + // support attachments. |
| + virtual bool WriteAttachment(scoped_refptr<Attachment> attachment); |
| + |
| + // ReadAttachment parses an attachment given the parsing state |iter| and |
| + // writes it to |*attachment|. It returns true on success. |
| + // |
| + // NOTE: It is NOT OK to call this or WriteAttachment() on a simple |
| + // base::Pickle. These must be implemented and called only subclasses that |
| + // support attachments. |
| + virtual bool ReadAttachment(base::PickleIterator* iter, |
| + scoped_refptr<Attachment>* attachment) const; |
| + |
| // Reserves space for upcoming writes when multiple writes will be made and |
| // their sizes are computed in advance. It can be significantly faster to call |
| // Reserve() before calling WriteFoo() multiple times. |