Skip to content

Commit

Permalink
ipc: Add UMA metrics for the unprivileged attachment broker.
Browse files Browse the repository at this point in the history
BUG=493414

Review URL: https://codereview.chromium.org/1373203003

Cr-Commit-Position: refs/heads/master@{#351901}
  • Loading branch information
erikchen authored and Commit bot committed Oct 1, 2015
1 parent 87875e6 commit c6828f1
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 1 deletion.
7 changes: 7 additions & 0 deletions ipc/attachment_broker_unprivileged.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "ipc/attachment_broker_unprivileged.h"

#include "base/metrics/histogram_macros.h"
#include "ipc/ipc_channel.h"
#include "ipc/ipc_endpoint.h"

Expand All @@ -22,4 +23,10 @@ void AttachmentBrokerUnprivileged::DesignateBrokerCommunicationChannel(
endpoint->SetAttachmentBrokerEndpoint(true);
}

void AttachmentBrokerUnprivileged::LogError(UMAError error) {
UMA_HISTOGRAM_ENUMERATION(
"IPC.AttachmentBrokerUnprivileged.BrokerAttachmentError", error,
ERROR_MAX);
}

} // namespace IPC
15 changes: 15 additions & 0 deletions ipc/attachment_broker_unprivileged.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ class IPC_EXPORT AttachmentBrokerUnprivileged : public IPC::AttachmentBroker {
protected:
IPC::Sender* get_sender() { return sender_; }

// Errors that can be reported by subclasses.
// These match tools/metrics/histograms.xml.
// This enum is append-only.
enum UMAError {
// The brokerable attachment was successfully processed.
SUCCESS = 0,
// The brokerable attachment's destination was not the process that received
// the attachment.
WRONG_DESTINATION = 1,
ERROR_MAX
};

// Emits an UMA metric.
void LogError(UMAError error);

private:
// |sender_| is used to send Messages to the privileged broker process.
// |sender_| must live at least as long as this instance.
Expand Down
5 changes: 4 additions & 1 deletion ipc/attachment_broker_unprivileged_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,15 @@ bool AttachmentBrokerUnprivilegedWin::OnMessageReceived(const Message& msg) {
void AttachmentBrokerUnprivilegedWin::OnWinHandleHasBeenDuplicated(
const IPC::internal::HandleAttachmentWin::WireFormat& wire_format) {
// The IPC message was intended for a different process. Ignore it.
if (wire_format.destination_process != base::Process::Current().Pid())
if (wire_format.destination_process != base::Process::Current().Pid()) {
LogError(WRONG_DESTINATION);
return;
}

scoped_refptr<BrokerableAttachment> attachment(
new IPC::internal::HandleAttachmentWin(wire_format));
HandleReceivedAttachment(attachment);
LogError(SUCCESS);
}

} // namespace IPC
19 changes: 19 additions & 0 deletions tools/metrics/histograms/histograms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16280,6 +16280,15 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</summary>
</histogram>

<histogram name="IPC.AttachmentBrokerUnprivileged.BrokerAttachmentError"
enum="IPCAttachmentBrokerUnprivilegedBrokerAttachmentError">
<owner>erikchen@chromium.org</owner>
<summary>
Errors that an unprivileged attachment broker encounters while trying to
broker attachments.
</summary>
</histogram>

<histogram name="Keyboard.KeystrokeDeltas" units="milliseconds">
<owner>Please list the metric's owners. Add more owner tags as needed.</owner>
<summary>
Expand Down Expand Up @@ -62350,6 +62359,16 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</int>
</enum>

<enum name="IPCAttachmentBrokerUnprivilegedBrokerAttachmentError" type="int">
<int value="0" label="SUCCESS">
The brokerable attachment was successfully processed.
</int>
<int value="1" label="DESTINATION_NOT_FOUND">
The brokerable attachment's destination was not the process that received
the attachment.
</int>
</enum>

<enum name="IPPermissionStatus" type="int">
<int value="0" label="Unknown"/>
<int value="1" label="Not requested"/>
Expand Down

0 comments on commit c6828f1

Please sign in to comment.