Bug 1262671 - Remove unused TrimWriteData (r=froydnj)
authorBill McCloskey <billm@mozilla.com>
Wed, 20 Apr 2016 16:10:32 -0700
changeset 372284 fff9ee7eaf1072bc237e6eaa48fb4705027cae5b
parent 372283 64fcfbf2da25d2563d53fcb518fa355eb72cb2c5
child 372285 63f6395614e8085c33d552e8c56e312df5c763a3
push id19496
push userdmitchell@mozilla.com
push dateFri, 27 May 2016 22:17:17 +0000
reviewersfroydnj
bugs1262671
milestone49.0a1
Bug 1262671 - Remove unused TrimWriteData (r=froydnj)
ipc/chromium/src/base/pickle.cc
ipc/chromium/src/base/pickle.h
--- a/ipc/chromium/src/base/pickle.cc
+++ b/ipc/chromium/src/base/pickle.cc
@@ -572,33 +572,16 @@ char* Pickle::BeginWriteData(int length)
       data_ptr - reinterpret_cast<char*>(header_) - sizeof(int);
 
   // EndWrite doesn't necessarily have to be called after the write operation,
   // so we call it here to pad out what the caller will eventually write.
   EndWrite(data_ptr, length);
   return data_ptr;
 }
 
-void Pickle::TrimWriteData(int new_length) {
-  DCHECK(variable_buffer_offset_ != 0);
-
-  // Fetch the the variable buffer size
-  int* cur_length = reinterpret_cast<int*>(
-      reinterpret_cast<char*>(header_) + variable_buffer_offset_);
-
-  if (new_length < 0 || new_length > *cur_length) {
-    NOTREACHED() << "Invalid length in TrimWriteData.";
-    return;
-  }
-
-  // Update the payload size and variable buffer size
-  header_->payload_size -= (*cur_length - new_length);
-  *cur_length = new_length;
-}
-
 void Pickle::Resize(uint32_t new_capacity) {
   new_capacity = ConstantAligner<kPayloadUnit>::align(new_capacity);
 
   void* p = moz_xrealloc(header_, new_capacity);
 
   header_ = reinterpret_cast<Header*>(p);
   capacity_ = new_capacity;
 }
--- a/ipc/chromium/src/base/pickle.h
+++ b/ipc/chromium/src/base/pickle.h
@@ -171,28 +171,16 @@ class Pickle {
   // Pickle. This saves a copy in cases where the data is not already
   // available in a buffer. The caller should take care to not write more
   // than the length it declares it will. Use ReadData to get the data.
   // Returns NULL on failure.
   //
   // The returned pointer will only be valid until the next write operation
   // on this Pickle.
   char* BeginWriteData(int length);
-
-  // For Pickles which contain variable length buffers (e.g. those created
-  // with BeginWriteData), the Pickle can
-  // be 'trimmed' if the amount of data required is less than originally
-  // requested.  For example, you may have created a buffer with 10K of data,
-  // but decided to only fill 10 bytes of that data.  Use this function
-  // to trim the buffer so that we don't send 9990 bytes of unused data.
-  // You cannot increase the size of the variable buffer; only shrink it.
-  // This function assumes that the length of the variable buffer has
-  // not been changed.
-  void TrimWriteData(int length);
-
   void EndRead(void* iter) const {
     DCHECK(iter == end_of_payload());
   }
 
   // Payload follows after allocation of Header (header size is customizable).
   struct Header {
     uint32_t payload_size;  // Specifies the size of the payload.
   };