summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@google.com>2015-06-06 04:47:56 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-06-06 04:47:56 +0000
commit6f33fbc82bb92fe95e931d7a6b69b9828f874e56 (patch)
treefc98c4e301a102fbf24c11027153f213ec6b2b45 /include
parentd7214d62639f02db9a420eb3f97259a4c909da45 (diff)
parent13b1604018968408bcc5553e1fa5ea9df3e4e009 (diff)
downloadframeworks_native-6f33fbc82bb92fe95e931d7a6b69b9828f874e56.zip
frameworks_native-6f33fbc82bb92fe95e931d7a6b69b9828f874e56.tar.gz
frameworks_native-6f33fbc82bb92fe95e931d7a6b69b9828f874e56.tar.bz2
am 13b16040: Enable more flexible usage of blobs in parcels.
* commit '13b1604018968408bcc5553e1fa5ea9df3e4e009': Enable more flexible usage of blobs in parcels.
Diffstat (limited to 'include')
-rw-r--r--include/binder/Parcel.h22
1 files changed, 17 insertions, 5 deletions
diff --git a/include/binder/Parcel.h b/include/binder/Parcel.h
index ddaf54f..3ada1e9 100644
--- a/include/binder/Parcel.h
+++ b/include/binder/Parcel.h
@@ -60,6 +60,7 @@ public:
status_t appendFrom(const Parcel *parcel,
size_t start, size_t len);
+ bool allowFds() const;
bool pushAllowFds(bool allowFds);
void restoreAllowFds(bool lastValue);
@@ -132,9 +133,16 @@ public:
// Writes a blob to the parcel.
// If the blob is small, then it is stored in-place, otherwise it is
- // transferred by way of an anonymous shared memory region.
+ // transferred by way of an anonymous shared memory region. Prefer sending
+ // immutable blobs if possible since they may be subsequently transferred between
+ // processes without further copying whereas mutable blobs always need to be copied.
// The caller should call release() on the blob after writing its contents.
- status_t writeBlob(size_t len, WritableBlob* outBlob);
+ status_t writeBlob(size_t len, bool mutableCopy, WritableBlob* outBlob);
+
+ // Write an existing immutable blob file descriptor to the parcel.
+ // This allows the client to send the same blob to multiple processes
+ // as long as it keeps a dup of the blob file descriptor handy for later.
+ status_t writeDupImmutableBlobFileDescriptor(int fd);
status_t writeObject(const flat_binder_object& val, bool nullMetaData);
@@ -270,16 +278,19 @@ private:
Blob();
~Blob();
+ void clear();
void release();
inline size_t size() const { return mSize; }
+ inline int fd() const { return mFd; };
+ inline bool isMutable() const { return mMutable; }
protected:
- void init(bool mapped, void* data, size_t size);
- void clear();
+ void init(int fd, void* data, size_t size, bool isMutable);
- bool mMapped;
+ int mFd; // owned by parcel so not closed when released
void* mData;
size_t mSize;
+ bool mMutable;
};
class FlattenableHelperInterface {
@@ -320,6 +331,7 @@ public:
friend class Parcel;
public:
inline const void* data() const { return mData; }
+ inline void* mutableData() { return isMutable() ? mData : NULL; }
};
class WritableBlob : public Blob {