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

Unified Diff: base/pickle.h

Issue 1659003003: IPC::Message -> base::Pickle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: one more mac fix 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..e50fd68eb8e4b82a2a14dc89e285a52ff207f894 100644
--- a/base/pickle.h
+++ b/base/pickle.h
@@ -14,9 +14,14 @@
#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"
+#if defined(OS_POSIX)
+#include "base/files/file.h"
+#endif
+
namespace base {
class Pickle;
@@ -123,6 +128,21 @@ class BASE_EXPORT PickleIterator {
//
class BASE_EXPORT Pickle {
public:
+ // Auxiliary data attached to a Pickle. Pickle must be subclassed along with
+ // this interface in order to provide a concrete implementation of support
+ // for attachments. The base Pickle implementation does not accept
+ // 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 +226,19 @@ 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 or if the Pickle implementation does not 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.
+ virtual bool ReadAttachment(base::PickleIterator* iter,
+ scoped_refptr<Attachment>* attachment) const;
+
+ // Indicates whether the pickle has any attachments.
+ virtual bool HasAttachments() 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