summaryrefslogtreecommitdiff
path: root/libs/protoutil/include
diff options
context:
space:
mode:
authorYi Jin <jinyithu@google.com>2017-10-11 18:20:24 -0700
committerYi Jin <jinyithu@google.com>2017-10-13 15:44:26 -0700
commit42711a0b4fffd0dc670ec7bc38cc7f954c60e530 (patch)
tree2e4b9a91caffb1098c823af806ee956a0ba207d2 /libs/protoutil/include
parentfcf52c6f5e2276c9cf2ca245757a2f0f4b1d7e4e (diff)
Use ProtoOutputStream to strip Pii sensetive fields in incidentd
The in-place algorithm in ProtoOutputStream will have at most 2 copies of possible nested message values incidentd is getting which makes it more ram-efficient, and minimize allocations. Bug: 65641021 Test: the units pass Change-Id: Ic3fe99b7e27895bd613a129ba0f12ccfca4af317
Diffstat (limited to 'libs/protoutil/include')
-rw-r--r--libs/protoutil/include/android/util/ProtoOutputStream.h14
1 files changed, 10 insertions, 4 deletions
diff --git a/libs/protoutil/include/android/util/ProtoOutputStream.h b/libs/protoutil/include/android/util/ProtoOutputStream.h
index 49ec169b3e5c..0f1ccedeaae2 100644
--- a/libs/protoutil/include/android/util/ProtoOutputStream.h
+++ b/libs/protoutil/include/android/util/ProtoOutputStream.h
@@ -37,7 +37,7 @@ namespace util {
class ProtoOutputStream
{
public:
- ProtoOutputStream(int fd);
+ ProtoOutputStream();
~ProtoOutputStream();
/**
@@ -60,13 +60,19 @@ public:
void end(long long token);
/**
- * Flushes the protobuf data out.
+ * Flushes the protobuf data out to given fd.
*/
- bool flush();
+ size_t size();
+ EncodedBuffer::iterator data();
+ bool flush(int fd);
+
+ // Please don't use the following functions to dump protos unless you are sure about it.
+ void writeRawVarint(uint64_t varint);
+ void writeLengthDelimitedHeader(uint32_t id, size_t size);
+ void writeRawByte(uint8_t byte);
private:
EncodedBuffer mBuffer;
- int mFd;
size_t mCopyBegin;
bool mCompact;
int mDepth;