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

Unified Diff: base/pickle.h

Issue 1659003003: IPC::Message -> base::Pickle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix missing comment Created 4 years, 11 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') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/pickle.h
diff --git a/base/pickle.h b/base/pickle.h
index 02bc432ad0bd27564e289f9d8fae0b9ca9408241..2487aebc3e6bbb74551204b9e56ee58c89f88e00 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,19 @@ class BASE_EXPORT PickleIterator {
//
class BASE_EXPORT Pickle {
public:
+ // A base attachment type for a Pickle subclass to implement if it supports
+ // reading and writing attachments.
+ 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 +220,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
Tom Sepez 2016/02/02 19:25:55 It feels wrong to design a virtual API that requir
+ // 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.
« no previous file with comments | « no previous file | base/pickle.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698