Bug 1264662 - Record IPC message capacity instead of size. r=billm, a=ritu

Capacity includes internal fragmentation, while size does not.

This requires making capacity() public, but that seems benign.
This commit is contained in:
Andrew McCreight 2016-04-14 17:46:52 -07:00
parent fcdaa31bf9
commit c091b719b6
2 changed files with 12 additions and 9 deletions

View File

@ -62,6 +62,11 @@ class Pickle {
int size() const { return static_cast<int>(header_size_ +
header_->payload_size); }
// Return the full size of the memory allocated for this Pickle's data.
uint32_t capacity() const {
return capacity_;
}
// Returns the data for this Pickle.
const void* data() const { return header_; }
@ -234,10 +239,6 @@ class Pickle {
return header_ ? payload() + payload_size() : nullptr;
}
uint32_t capacity() const {
return capacity_;
}
// Resizes the buffer for use when writing the specified amount of data. The
// location that the data should be written at is returned, or NULL if there
// was an error. Call EndWrite with the returned offset and the given length

View File

@ -118,7 +118,7 @@ static MessageChannel* gParentProcessBlocker;
namespace mozilla {
namespace ipc {
static const int kMinTelemetryMessageSize = 8192;
static const uint32_t kMinTelemetryMessageSize = 8192;
const int32_t MessageChannel::kNoTimeout = INT32_MIN;
@ -751,8 +751,9 @@ MessageChannel::Echo(Message* aMsg)
bool
MessageChannel::Send(Message* aMsg)
{
if (aMsg->size() >= kMinTelemetryMessageSize) {
Telemetry::Accumulate(Telemetry::IPC_MESSAGE_SIZE, nsCString(aMsg->name()), aMsg->size());
if (aMsg->capacity() >= kMinTelemetryMessageSize) {
Telemetry::Accumulate(Telemetry::IPC_MESSAGE_SIZE,
nsCString(aMsg->name()), aMsg->capacity());
}
CxxStackFrame frame(*this, OUT_MESSAGE, aMsg);
@ -1039,8 +1040,9 @@ MessageChannel::ProcessPendingRequests(AutoEnterTransaction& aTransaction)
bool
MessageChannel::Send(Message* aMsg, Message* aReply)
{
if (aMsg->size() >= kMinTelemetryMessageSize) {
Telemetry::Accumulate(Telemetry::IPC_MESSAGE_SIZE, nsCString(aMsg->name()), aMsg->size());
if (aMsg->capacity() >= kMinTelemetryMessageSize) {
Telemetry::Accumulate(Telemetry::IPC_MESSAGE_SIZE,
nsCString(aMsg->name()), aMsg->capacity());
}
nsAutoPtr<Message> msg(aMsg);